Clarify the MA0095 comment about the Equals(object) lookup
What changed
The comment above the MA0095 check in EqualityShouldBeCorrectlyImplementedAnalyzer said:
Check the entire type hierarchy for an Equals(object) override
but the code calls symbol.GetMembers(), which only returns the members declared by the type itself — a base-type override is not visible there. The comment now states what the code does and why.
Why
The behavior is correct and intentional: a type that introduces new equality semantics through IEquatable<T> must override Equals(object) itself, otherwise object.Equals (inherited from the base) and IEquatable<T>.Equals would disagree. This exact shape is listed as non-compliant in docs/Rules/MA0095.md. Only the comment was misleading — it suggested a bug where there is none, and could prompt a "fix" that breaks the rule.
Notes for reviewers
- Comment-only change; no behavior change.
- No new test needed:
InheritedIEquatable_WithDirectImplementationToo_ShouldTriggeralready locks in the scenario (base overridesEquals(object), derived implementsIEquatable<Derived>→ MA0095 reported). - Verified:
Meziantou.Analyzer.roslyn5.9builds with 0 warnings, the 46EqualityShouldBeCorrectlyImplementedAnalyzerTeststests pass, anddotnet run --project src/DocumentationGeneratorexits 0 with no markdown changes.