-
Notifications
You must be signed in to change notification settings - Fork 396
Refactoring records + primary constructor instrumentation #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
daveMueller
wants to merge
1
commit into
coverlet-coverage:master
Choose a base branch
from
daveMueller:1576_Records
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,19 +16,20 @@ public partial class CoverageTests | |||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void SkipAutoProps(bool skipAutoProps) | ||||||
| public void SkipClassWithAutoProps(bool skipAutoProps) | ||||||
| { | ||||||
| string path = Path.GetTempFileName(); | ||||||
| try | ||||||
| { | ||||||
| FunctionExecutor.Run(async (string[] parameters) => | ||||||
| { | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<AutoProps>(instance => | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<ClassWithAutoProps>(instance => | ||||||
| { | ||||||
| instance.AutoPropsNonInit = 10; | ||||||
| instance.AutoPropsInit = 20; | ||||||
| int readValue = instance.AutoPropsNonInit; | ||||||
| readValue = instance.AutoPropsInit; | ||||||
| readValue = instance.AutoPropsInitKeyword; | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
|
|
@@ -40,8 +41,8 @@ public void SkipAutoProps(bool skipAutoProps) | |||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 12, 13) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 12, 13) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 12, 14) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 12, 14) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 9, 11) | ||||||
| .AssertLinesCovered(BuildConfiguration.Debug, (7, 1)) | ||||||
| .AssertLinesCovered(BuildConfiguration.Release, (10, 1)); | ||||||
|
|
@@ -50,9 +51,9 @@ public void SkipAutoProps(bool skipAutoProps) | |||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 7, 13) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 7, 14) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 10, 10) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 12, 13); | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 12, 14); | ||||||
| } | ||||||
| } | ||||||
| finally | ||||||
|
|
@@ -64,42 +65,39 @@ public void SkipAutoProps(bool skipAutoProps) | |||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void SkipAutoPropsInRecords(bool skipAutoProps) | ||||||
| public void SkipClassWithAutoPropsPrimaryConstructor(bool skipAutoProps) | ||||||
| { | ||||||
| string path = Path.GetTempFileName(); | ||||||
| try | ||||||
| { | ||||||
| FunctionExecutor.Run(async (string[] parameters) => | ||||||
| { | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<RecordWithPropertyInit>(instance => | ||||||
| { | ||||||
| instance.RecordAutoPropsNonInit = string.Empty; | ||||||
| instance.RecordAutoPropsInit = string.Empty; | ||||||
| string readValue = instance.RecordAutoPropsInit; | ||||||
| readValue = instance.RecordAutoPropsNonInit; | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<ClassWithAutoPropsPrimaryConstructor>(instance => | ||||||
| { | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
|
|
||||||
| return 0; | ||||||
| }, [path, skipAutoProps.ToString()]); | ||||||
|
|
||||||
| if (skipAutoProps) | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 23, 24) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 23, 24) | ||||||
| .AssertLinesCovered(BuildConfiguration.Debug, (18, 1), (20, 1), (21, 1), (22, 1)) | ||||||
| .AssertLinesCovered(BuildConfiguration.Release, (21, 1)); | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 28, 28) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 28, 28) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 30, 31, 32) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 30, 31, 32); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 18, 24) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 21, 21) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 23, 24); | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 28, 28) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 30, 32) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 28, 28) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 30, 32); | ||||||
| } | ||||||
| } | ||||||
| finally | ||||||
|
|
@@ -111,37 +109,44 @@ public void SkipAutoPropsInRecords(bool skipAutoProps) | |||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void SkipRecordWithProperties(bool skipAutoProps) | ||||||
| public void SkipRecordWithAutoProps(bool skipAutoProps) | ||||||
| { | ||||||
| string path = Path.GetTempFileName(); | ||||||
| try | ||||||
| { | ||||||
| FunctionExecutor.Run(async (string[] parameters) => | ||||||
| { | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<ClassWithRecordsAutoProperties>(instance => | ||||||
| { | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<RecordWithAutoProps>(instance => | ||||||
| { | ||||||
| instance.AutoPropsNonInit = 10; | ||||||
| instance.AutoPropsInit = 20; | ||||||
| int readValue = instance.AutoPropsNonInit; | ||||||
| readValue = instance.AutoPropsInit; | ||||||
| readValue = instance.AutoPropsInitKeyword; | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
|
|
||||||
| return 0; | ||||||
| }, [path, skipAutoProps.ToString()]); | ||||||
|
|
||||||
| if (skipAutoProps) | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 29, 29) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 29, 29) | ||||||
| .AssertLinesCovered(BuildConfiguration.Debug, (32, 1), (33, 1), (34, 1)) | ||||||
| .AssertLinesCovered(BuildConfiguration.Release, (33, 1)); | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 43, 45) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 43, 45) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 40, 42) | ||||||
| .AssertLinesCovered(BuildConfiguration.Debug, (39, 1)) | ||||||
| .AssertLinesCovered(BuildConfiguration.Release, (39, 1)); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .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 | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 39, 39) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 41, 45); | ||||||
| } | ||||||
| } | ||||||
| finally | ||||||
|
|
@@ -153,14 +158,14 @@ public void SkipRecordWithProperties(bool skipAutoProps) | |||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void SkipInheritingRecordsWithProperties(bool skipAutoProps) | ||||||
| public void SkipRecordWithAutoPropsPrimaryConstructor(bool skipAutoProps) | ||||||
| { | ||||||
| string path = Path.GetTempFileName(); | ||||||
| try | ||||||
| { | ||||||
| FunctionExecutor.Run(async (string[] parameters) => | ||||||
| { | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<ClassWithInheritingRecordsAndAutoProperties>(instance => | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<RecordsWithPrimaryConstructor>(instance => | ||||||
| { | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
|
|
@@ -173,18 +178,57 @@ public void SkipInheritingRecordsWithProperties(bool skipAutoProps) | |||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Debug, 39, 39) | ||||||
| .AssertNonInstrumentedLines(BuildConfiguration.Release, 39, 39) | ||||||
| .AssertLinesCovered(BuildConfiguration.Debug, (41, 1), (44, 1), (45, 1), (46, 1)) | ||||||
| .AssertLinesCovered(BuildConfiguration.Release, (45, 1)); | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 50, 50) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 50, 50); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 50, 50) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 50, 50); | ||||||
| } | ||||||
| } | ||||||
| finally | ||||||
| { | ||||||
| File.Delete(path); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| [Theory] | ||||||
| [InlineData(true)] | ||||||
| [InlineData(false)] | ||||||
| public void SkipRecordWithAutoPropsPrimaryConstructorMultiline(bool skipAutoProps) | ||||||
| { | ||||||
| string path = Path.GetTempFileName(); | ||||||
| try | ||||||
| { | ||||||
| FunctionExecutor.Run(async (string[] parameters) => | ||||||
| { | ||||||
| CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<RecordsWithPrimaryConstructor>(instance => | ||||||
| { | ||||||
| return Task.CompletedTask; | ||||||
| }, | ||||||
| persistPrepareResultToFile: parameters[0], skipAutoProps: bool.Parse(parameters[1])); | ||||||
|
|
||||||
| return 0; | ||||||
| }, [path, skipAutoProps.ToString()]); | ||||||
|
|
||||||
| if (skipAutoProps) | ||||||
| { | ||||||
| TestInstrumentationHelper.GetCoverageResult(path) | ||||||
| .Document("Instrumentation.AutoProps.cs") | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55) | ||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55); | ||||||
|
||||||
| .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 52, 55); | |
| .AssertLinesCoveredFromTo(BuildConfiguration.Release, 52, 55); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.