Skip to content

Add C# 10 language feature audit tests - #4132

Merged
AArnott merged 11 commits into
masterfrom
csharp10-audit-tests
Oct 8, 2026
Merged

AArnott merged 11 commits into
masterfrom
csharp10-audit-tests

Conversation

@AArnott

@AArnott AArnott commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Part of #4042

This PR adds tests for C# 10 features that need no product change. It covers these sub-issues: #3979, #3980, #3981, #3983, #3984, #3986, #3988, #3989 and #3991.

Six commits are Björn Hellander's tests from his fork, cherry-picked with -x. He is kept as the author. Each commit message notes how it was adapted: tests merged into the existing upstream test classes, ConfigureAwait(false), and WorkItem attributes. The other three commits add new tests.

Sub-issue Tests Source
#3986 explicit lambda return types SA1008, SA1009, SA1121 Björn c4d41b551. His SA1009 product change was left out because master already reports SA1009 for (int, int) () and his tests pass without it.
#3988 constant interpolated strings SA1131, SA1404 Björn 212fff80b. His SA1122 test was left out because it depends on a separate SA1122 behavior change (see below).
#3980 struct improvements SA1101 (with on structs and anonymous types), SA1129, SA1642 Björn 043704336
#3984 extended property patterns SA1019 Björn 40709c682. His SA1024 product change and tests were left out because master already has them (300a473).
#3983 file-scoped namespaces SA1002, SA1101 Björn c033cbf23
#3979 record structs SA1008, SA1009, SA1127, SA1300, SA1401, SA1516 Björn 79e011ac9. Changes that only added TODO comments were left out. The SA1516 test uses a property followed by a method, because upstream SA1516 allows consecutive single-line properties.
#3989 sealed ToString in records SA1206 (both sealed override orders, plus the access-modifier fix), SA1100 (base.ToString() with a sealed base, with a synthesized ToString, and inside the sealed override), SA1648 new
#3981 interpolated string handlers SA1405 (an interpolated message that binds to the Debug.Assert handler overload), SA1122 ([InterpolatedStringHandlerArgument("")]) new
#3991 CallerArgumentExpression SA1611 (a documented parameter) new

No product code changes.

Open questions, deliberately left out of this PR:

  • SA1122 and $"": SA1122 doesn't currently report the empty interpolated string $"". Björn's fork (5ec345e25) changes SA1122 to report $"" and empty raw string literals. That's a behavior change, so it would need its own PR.
  • SA1611 and caller-info parameters: SA1611 reports an undocumented [CallerArgumentExpression] parameter, just as it already does for [CallerMemberName], [CallerFilePath] and [CallerLineNumber] parameters. This PR keeps that behavior.

The C# 10 product fixes are in separate PRs: #4131 (attributes on lambdas) and #4133 (SA1130 and natural types, #3985).

bjornhellander and others added 9 commits October 7, 2026 20:51
From bjornhellander/NewStyleCopAnalyzers#161. Adapted while cherry-picking: upstream SA1009 already
reports a missing space after a tuple return type, so the SA1009 change in the original commit is
not needed and was left out; the tests use ConfigureAwait(false) and WorkItem(3986).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c4d41b551bf0bcb9702f32f3ba0805634733e772)
From bjornhellander/NewStyleCopAnalyzers#163. Adapted while cherry-picking: the tests were merged
into the existing upstream test classes and use ConfigureAwait(false) and WorkItem(3988). The SA1122
test was left out because it depends on a separate SA1122 change that reports empty interpolated
strings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 212fff80bf6685c71bbc733bd0ac2fd82d852ac9)
From bjornhellander/NewStyleCopAnalyzers#155.

Adapted while cherry-picking: the tests were merged into the existing upstream test classes and use
ConfigureAwait(false) and WorkItem(3980).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 043704336166fb1336e044ffd8787604074ce0bc)
From bjornhellander/NewStyleCopAnalyzers#158.

Adapted while cherry-picking: the tests were merged into the existing upstream test classes and use
ConfigureAwait(false) and WorkItem(3983).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c033cbf235b805b4fd4735475c04ff81fdf9a128)
…d SA1516

From bjornhellander/NewStyleCopAnalyzers#154.

Adapted while cherry-picking: the tests were merged into the existing upstream test classes and use
ConfigureAwait(false) and WorkItem(3979). The TODO review notes were left out, as were the changes
that only added TODO comments (SA1300UnitTests, SA1300CSharp9UnitTests, SA1401FieldsMustBePrivate).
The SA1516 record test now uses a property followed by a method, because upstream SA1516 allows
consecutive single-line properties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 79e011ac93d3b1f5a3554117903518dc632f87bd)
Covers SA1206 (both modifier orders, plus the access modifier code fix), SA1100 (base.ToString() with
and without a sealed base ToString, and with a synthesized ToString), and SA1648 (inheritdoc on a
sealed ToString). No product change was needed.

Part of #3989
Covers SA1405 (an interpolated message that binds to the Debug.Assert interpolated string handler
overload) and SA1122 (the empty string in [InterpolatedStringHandlerArgument("")]). No product
change was needed.

Part of #3981
No product change was needed. SA1611 still reports an undocumented [CallerArgumentExpression]
parameter, the same as [CallerMemberName] parameters.

Part of #3991
From bjornhellander/NewStyleCopAnalyzers#159 ("Update SA1024 to check colons in extended property
patterns, and add SA1019 tests for them").

Adapted while cherry-picking: only the SA1019 test is kept, with ConfigureAwait(false) and
WorkItem(3984). The SA1024 product change and its tests were left out because master already has
them (300a473, TestExtendedPropertyPatternSpacingAsync and TestPropertyPatternColonSpacingAsync).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 40709c68258a58ad99079478b5aafd53ac7c1853)
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (f26d21b) to head (42dfd4c).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4132      +/-   ##
==========================================
+ Coverage   97.41%   97.42%   +0.01%     
==========================================
  Files        1118     1129      +11     
  Lines      124962   125493     +531     
  Branches     4203     4203              
==========================================
+ Hits       121734   122266     +532     
+ Misses       2116     2115       -1     
  Partials     1112     1112              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AArnott
AArnott marked this pull request as ready for review October 8, 2026 03:37
@AArnott
AArnott enabled auto-merge October 8, 2026 14:06
# Conflicts:
#	StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1101CSharp10UnitTests.cs
@AArnott
AArnott merged commit b7b0d95 into master Oct 8, 2026
25 checks passed
@AArnott
AArnott deleted the csharp10-audit-tests branch October 8, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants