Skip to content

Test and document the records in MA0197, MA0198 and MA0199 - #1555

Merged
meziantou merged 3 commits into
mainfrom
fix/ma0197-record-inheritdoc
Sep 23, 2026
Merged

meziantou merged 3 commits into
mainfrom
fix/ma0197-record-inheritdoc

Conversation

@meziantou

@meziantou meziantou commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

What

The compiler implements IEquatable<T> on every record, and this interface is part of the interfaces of the record in the XML documentation. So a documentation tool that resolves <inheritdoc /> on a record sees it as a source:

  • record Sample; has one source (IEquatable<Sample>): MA0197
  • record Sample : ITest; has two sources (ITest, IEquatable<Sample>): MA0198
  • record Sample : IEquatable<Sample>; has one source, as the compiler merges the declared interface with the one it implements: MA0197

This is the current behavior of the rules, but it was not tested nor documented, and it can look surprising (MA0199 is never reported on a record).

Changes

After the review, the change of behavior initially proposed in this PR (ignoring the synthesized IEquatable<T>) was dropped. The PR now only:

  • documents the behavior on records in MA0198 and MA0199
  • adds tests for records to InheritdocShouldNotBeUsedOnTypesAnalyzerTests (MA0197), InheritdocShouldNotBeAmbiguousOnTypesAnalyzerTests (MA0198, including the code fix and a record declaring IEquatable<int>) and InheritdocShouldHaveSourceOnTypesAnalyzerTests (MA0199 not reported on record and record struct)

No analyzer or code fix change. The Rules.Inheritdoc tests pass on roslyn5.9 and roslyn4.8 (39 tests each).

@meziantou meziantou changed the title Ignore the IEquatable<T> interface synthesized on records in MA0197, MA0198 and MA0199 Test and document the records in MA0197, MA0198 and MA0199 Sep 23, 2026
@meziantou
meziantou marked this pull request as ready for review September 23, 2026 14:04
@meziantou
meziantou merged commit 3b75a50 into main Sep 23, 2026
14 checks passed
@meziantou
meziantou deleted the fix/ma0197-record-inheritdoc branch September 23, 2026 14:04
This was referenced Sep 23, 2026
This was referenced Sep 28, 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