Skip to content

Refactoring records + primary constructor instrumentation#1761

Draft
daveMueller wants to merge 1 commit into
coverlet-coverage:masterfrom
daveMueller:1576_Records
Draft

Refactoring records + primary constructor instrumentation#1761
daveMueller wants to merge 1 commit into
coverlet-coverage:masterfrom
daveMueller:1576_Records

Conversation

@daveMueller
Copy link
Copy Markdown
Collaborator

closes #1576

@Bertk Bertk requested a review from Copilot July 1, 2025 11:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors record tests and primary constructor instrumentation by moving record-related samples into a dedicated file and simplifying auto-property instrumentation logic.

  • Migrate record-related test cases from Instrumentation.AutoProps.cs to a new Instrumentation.Records.cs file.
  • Simplify auto-property instrumentation logic in CecilSymbolHelper.cs by removing the constructor check and the related default initialization skip.

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.

File Description
test/coverlet.core.coverage.tests/Samples/Instrumentation.Records.cs Introduces various record types and tests covering records with primary constructors, inheritance, and abstract records.
test/coverlet.core.coverage.tests/Samples/Instrumentation.AutoProps.cs Removes duplicate record-related test cases that were relocated.
src/coverlet.core/Symbols/CecilSymbolHelper.cs Adjusts the auto-property instrumentation logic by removing the constructor check and skipping default initialization handling.
Comments suppressed due to low confidence (2)

src/coverlet.core/Symbols/CecilSymbolHelper.cs:1367

  • The removal of the constructor check (methodDefinition.IsConstructor) changes when auto-property instrumentation is applied. Please confirm that applying instrumentation to non-constructor methods does not lead to unexpected behavior.
      if (!skipAutoProps) return false;

test/coverlet.core.coverage.tests/Samples/Instrumentation.Records.cs:5

  • [nitpick] Consider adding brief inline comments to clarify the intent and differences between the various record test types to improve code readability and maintainability.
    public record RecordWithPropertyInit

@daveMueller
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Bertk Bertk added the enhancement General enhancement request label Dec 9, 2025
@Bertk Bertk requested a review from Copilot February 23, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 6 changed files in this pull request and generated 3 comments.

{
TestInstrumentationHelper.GetCoverageResult(path)
.Document("Instrumentation.Records.cs")
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 12,13)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in method call arguments. There should be a space after the comma between arguments (12,13 should be 12, 13). This inconsistency is visible when comparing with line 44 which has proper spacing.

Suggested change
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 12,13)
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 12, 13)

Copilot uses AI. Check for mistakes.
.AssertLinesCovered(BuildConfiguration.Debug, (29, 1), (31, 1), (32, 1), (33, 1), (34, 1))
.AssertLinesCovered(BuildConfiguration.Release, (29, 1), (31, 1), (33, 1));
.Document("Instrumentation.AutoProps.cs")
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 38, 45) // go on here
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO comment "go on here" should be removed before merging. This appears to be a leftover development comment that doesn't add value to the production code.

Suggested change
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 38, 45) // go on here
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 38, 45)

Copilot uses AI. Check for mistakes.
TestInstrumentationHelper.GetCoverageResult(path)
.Document("Instrumentation.AutoProps.cs")
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55)
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate assertion on line 222. This line is identical to line 221 but should be asserting for BuildConfiguration.Release instead of BuildConfiguration.Debug. The pattern in other tests shows that the first assertion should be for Debug and the second for Release.

Suggested change
.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55);
.AssertLinesCoveredFromTo(BuildConfiguration.Release, 52, 55);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coverlet-core enhancement General enhancement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Treat records equal to classes

3 participants