Repository navigation
Add tests for types with primary constructors (stacked on #4142) - #4143
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4143 +/- ##
==========================================
+ Coverage 97.44% 97.47% +0.02%
==========================================
Files 1154 1212 +58
Lines 126586 127945 +1359
Branches 4206 4207 +1
==========================================
+ Hits 123357 124719 +1362
+ Misses 2115 2114 -1
+ Partials 1114 1112 -2 🚀 New features to boost your workflow:
|
AArnott
marked this pull request as ready for review
October 8, 2026 04:41
AArnott
force-pushed
the
csharp12-primary-constructor-types
branch
from
October 8, 2026 16:24
3f158e8 to
9530fee
Compare
…and SA1629 code fixes to handle duplicate diagnostics From bjornhellander/NewStyleCopAnalyzers#147. Adapted while cherry-picking: the tests were merged into the existing upstream test classes and use ConfigureAwait(false) and WorkItem(4006). The IndentationCodeFixProvider change was applied to the upstream code, which did not yet skip duplicate text changes. The SA1201 expectations use the upstream message arguments ("A field", "a property"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 50f071c475a82407585b599603f920f4a39b4214)
AArnott
force-pushed
the
csharp12-primary-constructor-types
branch
from
October 8, 2026 17:36
9530fee to
4057d07
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #4044 / #4006 (C# 12 primary constructors).
Stacked on #4142 (record handling). Many of these tests run on
record/record structas well asclass/structwith primary constructors, and they only pass once #4142's record fixes are in. Please review and merge #4142 first.This ports @bjornhellander's 50f071c47 (bjornhellander/NewStyleCopAnalyzers#147) with his authorship kept. It adds tests for types with primary constructor parameter lists across these rules: SA1137, SA1201–SA1206, SA1214, SA1400, SA1505, SA1600, SA1601, SA1604–SA1608, SA1613, SA1614, SA1616, SA1618, SA1619, SA1620–SA1622, SA1625, SA1629 and SA1648. The tests were merged into the existing upstream test classes, use
ConfigureAwait(false)and[WorkItem(4006)], and the SA1201 expectations were updated to upstream's message arguments ("A field" / "a property").Behavior change (code fixes only)
Older Roslyn versions report some diagnostics twice: on positional records (dotnet/roslyn#53136) and in files with top-level statements (dotnet/roslyn#58561). When that happens, the fix-all for two code fixes ended up with duplicate or overlapping text changes:
SA1629CodeFixProvidernow adds each period only once.IndentationCodeFixProvider(SA1137) now skips text changes it has already added.Analyzer diagnostics don't change in this PR. The tests expect the duplicate diagnostics where older compilers produce them, through overridable
GetExpectedResult…methods.Tests
On Linux, all primary-constructor tests pass on C# 9–15 except the SA1201–SA1204/SA1214 code-fix tests, which fail only because of CRLF line endings, the same way existing ordering fix tests do on Linux. CI (Windows) is the real check.