Repository navigation
SA1114: Allow comment lines before parameter and argument lists - #4270
Merged
Merged
Conversation
Allow comment-only gaps before the first list item without allowing blank lines or changing directive handling. Add the regression for #2917 and coverage for every affected list kind. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4270 +/- ##
=======================================
Coverage 97.61% 97.61%
=======================================
Files 1285 1285
Lines 137307 137404 +97
Branches 4451 4461 +10
=======================================
+ Hits 134029 134125 +96
Misses 2113 2113
- Partials 1165 1166 +1 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation preserves existing fast paths and is comprehensively covered across affected syntax shapes and edge cases.
0 open findings
What changed in this PR
Updates SA1114 so comment-only lines do not count as blank lines, while preserving diagnostics for actual blank lines and directives.
Changes:
- Adds trivia-based comment detection across supported list types.
- Adds comprehensive regression and boundary tests.
- Documents the exemption in English, Russian, and Czech.
| File | Description |
|---|---|
SA1114UnitTests.cs |
Adds comment, blank-line, list-shape, and directive coverage. |
SA1114ParameterListMustFollowDeclaration.cs |
Implements comment-aware blank-line detection. |
documentation/SA1114.md |
Documents the exemption in English. |
documentation/ru-ru/SA1114.md |
Adds Russian documentation. |
documentation/cs-cz/SA1114.md |
Adds Czech documentation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Nov 11, 2026
Bump StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.180
microsoftgraph/aspnetcore-webhooks-sample#436
Open
Closed
Open
This was referenced Nov 20, 2026
[DPDBT] Bump Microsoft.CodeAnalysis.Analyzers and 6 others
sergey-rybalkin/CommandLine.Generators#63
Open
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.
Fixes #2917
SA1114 compared the opening bracket and first item's line numbers directly, incorrectly treating comment lines as blank lines. The analyzer now checks the intervening trivia only when the existing line-distance check would report. Comments are allowed, while blank lines before or after comments still report at the first item. The check is shared across SA1114's parameter, argument, attribute, and array-rank lists; existing directive handling is preserved. The English, Russian, and Czech rule documentation describes this exemption.
The exact grouped-string-and-number argument regression was added first and fails on master
5fb0ffaf999434bf5b78b7c8bb86c8334ac46b37: expected 0 diagnostics, actual SA1114 at line 9, column 1 (the first string argument). Before any product changes, the base rule suite had 36 comment-only regression failures and 131 passes, including the blank-line near misses. Additional coverage checks all seven list shapes, single-line and multiline comments, comments starting on the opening-bracket line, blank lines around comments, blank lines inside block comments, and unchanged conditional-directive behavior.Performance: No new registrations, semantic-model calls, allocations, or tree walks. Same-line and immediately-next-line lists follow the unchanged fast path. Only existing diagnostic candidates inspect the opening token's trailing trivia and first item's leading trivia, stopping at the first blank line or unsupported trivia. Cost is linear in those two trivia lists; no benchmark-based speed claim.
Validation: SDK 10.0.401;
dotnet build -c Release -maxcpucount:1succeeded with zero warnings and errors. All SA1114 tests passed in Release onnet10.0for C# 6–15 (2,862 tests total), plus the C# 6 and C# 15 suites onnet472(568 tests). The base Debug rule suite also passed after the initial fix. PR intentionally remains draft for CI and human review.