Skip to content

SA1653: Detect conflicting summary documentation on partial types - #4299

Merged
AArnott merged 2 commits into
masterfrom
aarnott-partial-summary-analyzer
Oct 14, 2026
Merged

AArnott merged 2 commits into
masterfrom
aarnott-partial-summary-analyzer

Conversation

@AArnott

@AArnott AArnott commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Multiple parts of a partial type can each provide <summary> documentation, producing duplicated or conflicting type documentation and confusing interactions with SA1619. This adds SA1653 to identify those conflicts without raising the minimum supported Roslyn version.

Fixes #2908

Approach

  • Register a named-type symbol action and inspect declaration documentation only when the symbol has multiple declarations. No newer APIs, light-up wrappers, compilation-end state, or member-body walks are required.
  • Report every declaration containing a conflicting explicit top-level <summary>. The user chooses which declaration retains the summary and replaces the others with <content>; no automatic fix is offered.
  • Enable the rule as a warning. Existing documentation is checked regardless of accessibility-based documentation requirements. Generated declarations contribute to conflicts, but diagnostics are reported only on non-generated declarations.
  • Do not expand <include> or <inheritdoc> or count nested summaries. These boundaries are documented and covered by tests.

Includes Czech, Russian, and Simplified Chinese diagnostic resources and documentation, with localized rule indexes and navigation. Other resource locales retain English fallback. The translations have not had native-speaker review.

Validation

The original two-file generic partial-class example first failed against a no-op SA1653 scaffold with two expected diagnostics and none returned. SA1653 tests now pass across all ten compiler generations, C# 6 through C# 15, including records and record structs. Related SA1601/SA1619 and resource/configuration suites also pass on the oldest and newest compilers. Full Release solution build completed with zero warnings and errors; generated resource accessors are included.

Performance

The new callback runs for named types and immediately returns for symbols with fewer than two declarations. Only multi-declaration types have their declaration trivia inspected; there is no shared cache or additional semantic-model lookup.

Release StyleCopTester /id:SA1653 /force /stats .\StyleCopAnalyzers.slnx runs over 27 projects and 2,426 documents took 15.75 s and 15.11 s for analysis, compared with 14.97 s and 15.81 s using the existing no-op SA1650 analyzer. These end-to-end timings are noisy and do not establish an isolated overhead figure. The workspace also reports existing compiler diagnostics during these runs.

Report partial declarations with conflicting explicit summary documentation without requiring newer Roslyn APIs. Include cross-version coverage and localized resources and documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AArnott
AArnott marked this pull request as ready for review October 14, 2026 02:24
Copilot AI balanced review requested due to automatic review settings October 14, 2026 02:24
Translate the new no-code-fix reason in all localized status reports and preserve the shared code examples required by documentation localization tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is focused, compatible with supported Roslyn versions, and thoroughly covered by tests and documentation.

0 open findings

What changed in this PR

Adds SA1653 to detect conflicting <summary> documentation across partial-type declarations.

Changes:

  • Implements the warning-only analyzer.
  • Adds comprehensive cross-version tests, including records and generated code.
  • Adds release metadata, resources, and localized documentation.
File Description
test/​StyleCop.Analyzers.Test/​DocumentationRules/​SA1653UnitTests.cs Tests core behavior and edge cases.
test/​StyleCop.Analyzers.Test.CSharp9/​DocumentationRules/​SA1653CSharp9UnitTests.cs Tests partial records.
test/​StyleCop.Analyzers.Test.CSharp10/​DocumentationRules/​SA1653CSharp10UnitTests.cs Tests partial record structs.
src/​StyleCop.Analyzers/​Lightup/​.generated/​Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/​Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/​DocumentationResources.Designer.cs Adds generated resource accessors.
src/​StyleCop.Analyzers/​DocumentationRules/​SA1653OnlyOnePartialDeclarationShouldContainSummaryDocumentation.cs Implements SA1653 analysis.
src/​StyleCop.Analyzers/​DocumentationRules/​DocumentationResources.zh-CN.resx Adds Chinese diagnostics.
src/​StyleCop.Analyzers/​DocumentationRules/​DocumentationResources.ru-RU.resx Adds Russian diagnostics.
src/​StyleCop.Analyzers/​DocumentationRules/​DocumentationResources.resx Adds neutral diagnostic resources.
src/​StyleCop.Analyzers/​DocumentationRules/​DocumentationResources.cs-CZ.resx Adds Czech diagnostics.
src/​StyleCop.Analyzers/​AnalyzerReleases.Unshipped.md Registers the unshipped rule.
src/​StyleCop.Analyzers.CodeFixes/​rulesets/​StyleCopAnalyzersDefault.ruleset Enables SA1653 as a warning.
documentation/​zh-cn/​toc.yml Adds Chinese navigation.
documentation/​zh-cn/​SA1653.md Documents SA1653 in Chinese.
documentation/​zh-cn/​DocumentationRules.md Adds the Chinese rule index entry.
documentation/​toc.yml Adds English navigation.
documentation/​SA1653.md Documents SA1653 behavior and remediation.
documentation/​ru-ru/​toc.yml Adds Russian navigation.
documentation/​ru-ru/​SA1653.md Documents SA1653 in Russian.
documentation/​ru-ru/​DocumentationRules.md Adds the Russian rule index entry.
documentation/​DocumentationRules.md Adds the English rule index entry.
documentation/​cs-cz/​toc.yml Adds Czech navigation.
documentation/​cs-cz/​SA1653.md Documents SA1653 in Czech.
documentation/​cs-cz/​DocumentationRules.md Adds the Czech rule index entry.
Files not reviewed (1)
  • src/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/DocumentationResources.Designer.cs: Generated file

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 02:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is focused, compatible with supported Roslyn versions, and comprehensively tested and documented.

0 open findings

Files not reviewed (1)
  • src/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/DocumentationResources.Designer.cs: Generated file

🧠 Review effort: Balanced

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.57143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.60%. Comparing base (ed09d10) to head (599cb3a).
⚠️ Report is 22 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4299    +/-   ##
========================================
  Coverage   97.60%   97.60%            
========================================
  Files        1296     1300     +4     
  Lines      140096   140404   +308     
  Branches     4633     4639     +6     
========================================
+ Hits       136741   137046   +305     
- Misses       2155     2157     +2     
- Partials     1200     1201     +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AArnott
AArnott merged commit 152d6a9 into master Oct 14, 2026
29 of 30 checks passed
@AArnott
AArnott deleted the aarnott-partial-summary-analyzer branch October 14, 2026 02:45
This was referenced Nov 11, 2026
This was referenced Nov 23, 2026
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.

Provide an analyzer for multiple instances of <summary> on a partial type

2 participants