Repository navigation
SA1604: honor private documentation settings for excluded declarations - #4274
Merged
Merged
Conversation
Honor private-element and private-field documentation settings instead of unconditionally suppressing summary checks. Add the exact #3094 regression and near-miss, settings, declaration, and include coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AArnott
marked this pull request as ready for review
October 13, 2026 16:02
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4274 +/- ##
=======================================
Coverage 97.61% 97.61%
=======================================
Files 1285 1285
Lines 137307 137401 +94
Branches 4451 4462 +11
=======================================
+ Hits 134029 134123 +94
Misses 2113 2113
Partials 1165 1165 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Interface settings can bypass the new private-documentation behavior for excluded declarations.
1 open finding
What changed in this PR
Updates SA1604 so top-level <exclude/> declarations follow private-documentation settings.
Changes:
- Adds direct and included
<exclude/>handling. - Passes cached settings through the shared summary analyzer.
- Adds regression tests and localized documentation.
| File | Description |
|---|---|
test/.../SA1604UnitTests.cs |
Adds regression and settings tests. |
src/.../XmlCommentHelper.cs |
Defines the exclude tag constant. |
src/.../SA1606ElementDocumentationMustHaveSummaryText.cs |
Adopts the updated handler signature. |
src/.../SA1604ElementDocumentationMustHaveSummary.cs |
Implements exclude handling. |
src/.../ElementDocumentationSummaryBase.cs |
Passes settings to summary handlers. |
documentation/SA1604.md |
Documents the new behavior. |
documentation/ru-ru/SA1604.md |
Adds Russian documentation. |
documentation/cs-cz/SA1604.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.
Comment on lines
+83
to
+85
| bool documentPrivate = context.Node.IsKind(SyntaxKind.FieldDeclaration) | ||
| ? settings.DocumentationRules.DocumentPrivateFields | ||
| : settings.DocumentationRules.DocumentPrivateElements; |
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 23, 2026
[DPDBT] Bump Microsoft.CodeAnalysis.Analyzers and 6 others
sergey-rybalkin/CommandLine.Generators#63
Open
Open
Open
Closed
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 #3094
Treat declarations with a top-level
<exclude/>as private for SA1604, following the maintainer guidance in #3121, rather than disabling all documentation checks. Missing summaries remain diagnostics whendocumentPrivateElementsis enabled, ordocumentPrivateFieldsfor fields. Exclude tags are recognized both directly and through expanded<include>documentation. Nested<exclude/>and differently cased<Exclude/>do not suppress diagnostics.This PR is intentionally limited to SA1604. The shared summary base passes its already-cached settings through to the handler; SA1606 behavior is unchanged. English, Czech, and Russian rule documentation describes the behavior (localized wording has not received native-speaker review).
Regression and validation
The exact reported example was added first to the C# 6 SA1604 suite. The test fails on master
5fb0ffaf999434bf5b78b7c8bb86c8334ac46b37, before any product edits: expected 0 diagnostics, actual 1,SA1604: Element documentation should have summaryat line 2, column 14. It passes with this change.Added 42 cases covering declaration kinds, both settings outcomes, independent private-field/private-element settings, multiple field/event locations, valid summaries, near misses, and inline/included exclude tags.
global.json.dotnet build -c Release -maxcpucount:1: succeeded, 0 warnings, 0 errors.net10.0Release; 373 passing in the oldest/newest projects onnet472Release; 163 passing in the C# 6 project onnet10.0Debug. No failures or skipped tests.FullyQualifiedName~SA1604|FullyQualifiedName~SA1606.git diff --checkpasses; generated files are unchanged.Analyzer cost
No new registrations, semantic-model calls, symbol walks, reflection, or caches. Existing cached settings are passed through. The new work occurs only after the existing summary/inheritdoc and documentation-required checks would otherwise report SA1604: a private-setting check and a top-level exclude lookup. Declarations without documentation or with summaries retain their existing early exits. The lookup uses the existing XML helper and incurs its iterator/name-string costs on missing-summary comments; includes reuse the already-expanded XML.
A local synthetic comparison used the master and fixed Debug analyzer DLLs with Roslyn 5.0.0 and .NET 10, single-threaded
CompilationWithAnalyzers, 2,000 public classes per corpus, 5 warmups + 20 measured iterations per process, three baseline/fixed process pairs. Medians of the three per-process analyzer-time medians:<summary>Summary.</summary><remarks>Remark.</remarks><exclude/>Passing-summary timings were noisy (master 7.636–8.948 ms; fixed 4.937–14.174 ms), so these are not a throughput guarantee. On the deliberately all-missing-summary remarks corpus, the measured increase was about 1.57 ms per 2,000 declarations (0.8 μs each). Whole-driver allocation medians were 19,480,232 → 19,787,040 bytes for remarks and 18,494,624 → 17,214,096 bytes for exclude. These include Roslyn allocations and are not per-rule allocation accounting.
To reproduce the comparison: preserve the master Debug DLL, build the fixed Debug DLL, load each explicitly in a separate process, parse 2,000 unique public classes whose documentation is one of the three rows above using
DocumentationMode.Diagnose, reuse the compilation but create a fresh analyzer driver for each iteration withconcurrentAnalysis: falseandlogAnalyzerExecutionTime: true, and collectGetAnalyzerTelemetryInfoAsync(...).ExecutionTimeafter five warmups. The expected common-path cost is only forwarding the existing settings reference; the additional syntax lookup is confined to comments that would otherwise be diagnosed.