Refactoring records + primary constructor instrumentation#1761
Refactoring records + primary constructor instrumentation#1761daveMueller wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
67b249f to
d542718
Compare
| { | ||
| TestInstrumentationHelper.GetCoverageResult(path) | ||
| .Document("Instrumentation.Records.cs") | ||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 12,13) |
There was a problem hiding this comment.
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.
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 12,13) | |
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 12, 13) |
| .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 |
There was a problem hiding this comment.
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.
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 38, 45) // go on here | |
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 38, 45) |
| TestInstrumentationHelper.GetCoverageResult(path) | ||
| .Document("Instrumentation.AutoProps.cs") | ||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55) | ||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55); |
There was a problem hiding this comment.
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.
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55); | |
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 52, 55); |
closes #1576