Repository navigation
SA1653: Detect conflicting summary documentation on partial types - #4299
Conversation
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>
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>
There was a problem hiding this comment.
🟢 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.
There was a problem hiding this comment.
🟢 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 Report❌ Patch coverage is 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:
|
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
<summary>. The user chooses which declaration retains the summary and replaces the others with<content>; no automatic fix is offered.<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.slnxruns 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.