Skip to content

Split type inheritdoc rule into MA0197/MA0198/MA0199#1143

Merged
meziantou merged 3 commits into
mainfrom
meziantou/inheritdoc-type-rules
May 8, 2026
Merged

Split type inheritdoc rule into MA0197/MA0198/MA0199#1143
meziantou merged 3 commits into
mainfrom
meziantou/inheritdoc-type-rules

Conversation

@meziantou
Copy link
Copy Markdown
Owner

Type-level <inheritdoc /> usage needed more precise guidance than a single warning. This change separates recommendation, ambiguity, and invalid-source cases so users get the right severity and actionable fixes.

What changed

  • Kept MA0197 for type <inheritdoc />, but changed it to a suggestion with messaging focused on writing dedicated type documentation.
  • Added MA0198 as a warning for ambiguous type inheritdoc when there is no base type and multiple declared interfaces.
  • Added MA0199 as a warning for type inheritdoc with no cref, no base type, and no declared interfaces.
  • Added a code fix for MA0198 that offers one cref option per declared interface.
  • Expanded analyzer/code-fix tests and updated rule docs (MA0197, new MA0198, new MA0199).
  • Regenerated repository documentation/config outputs (README.md, docs/README.md, and analyzer pack editorconfig files).

Notes for review

  • "No base type" is treated as System.Object or System.ValueType.
  • Ambiguity logic only considers declared interfaces (INamedTypeSymbol.Interfaces), not interfaces inherited through those interfaces.

Keep MA0197 as a suggestion for dedicated type documentation. Add MA0198/MA0199 warning diagnostics for ambiguous and missing inheritdoc sources on types. Add MA0198 code fixes to suggest cref from declared interfaces, and update tests and generated documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Meziantou.Analyzer.CodeFixers/Rules/InheritdocShouldNotBeUsedOnTypesFixer.cs Outdated
Comment thread src/Meziantou.Analyzer/Rules/InheritdocShouldNotBeUsedOnTypesAnalyzer.cs Outdated
Split MA0197, MA0198, and MA0199 into dedicated analyzers with shared helper logic, split tests into three corresponding classes, and update MA0198 cref generation to use DocumentationCommentId for code fixes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Meziantou.Analyzer.CodeFixers/Rules/InheritdocShouldNotBeUsedOnTypesFixer.cs Outdated
Comment thread src/Meziantou.Analyzer/Rules/InheritdocShouldHaveSourceOnTypesAnalyzer.cs Outdated
Comment thread src/Meziantou.Analyzer/Rules/InheritdocShouldNotBeAmbiguousOnTypesAnalyzer.cs Outdated
Use DocumentationCommentId.CreateReferenceId for generated cref values, apply requested analyzer registration style updates, and add valid-case coverage for MA0198/MA0199 test classes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@meziantou meziantou merged commit 4c4a435 into main May 8, 2026
13 checks passed
@meziantou meziantou deleted the meziantou/inheritdoc-type-rules branch May 8, 2026 20:32
This was referenced May 8, 2026
This was referenced May 11, 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.

1 participant