-
-
Couldn't load subscription status.
- Fork 61
MA0169 - Detect equality operators that should be replaced with Equals method #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new analyzer (MA0169) that detects when the equality operators (==, !=) are used on types that override Equals.
- Added analyzer implementation in src/Meziantou.Analyzer/Rules/UseEqualsMethodInsteadOfOperatorAnalyzer.cs
- Created corresponding tests in tests/Meziantou.Analyzer.Test/Rules/UseEqualsMethodInsteadOfOperatorAnalyzerTests.cs
- Updated rule identifiers, documentation, and README files to include the new rule
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Meziantou.Analyzer.Test/Rules/UseEqualsMethodInsteadOfOperatorAnalyzerTests.cs | Adds tests covering various scenarios for the new rule |
| src/Meziantou.Analyzer/Rules/UseEqualsMethodInsteadOfOperatorAnalyzer.cs | Implements the analyzer logic to report diagnostics for improper usage |
| src/Meziantou.Analyzer/RuleIdentifiers.cs | Adds the identifier constant for MA0169 |
| src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs | Introduces extension methods to support the analyzer’s functionality |
| docs/Rules/MA0169.md | Provides documentation and usage examples for the new rule |
| docs/README.md, README.md | Updates rule tables to reflect the addition of MA0169 |
Files not reviewed (2)
- src/Meziantou.Analyzer.Pack/configuration/default.editorconfig: Language not supported
- src/Meziantou.Analyzer.Pack/configuration/none.editorconfig: Language not supported
src/Meziantou.Analyzer/Rules/UseEqualsMethodInsteadOfOperatorAnalyzer.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a new analyzer (MA0169) to detect when equality operators are used on types that override Equals, suggesting that the Equals method should be used instead. Key changes include the addition of analyzer tests, the new analyzer implementation and updated helper methods, as well as corresponding documentation updates in the docs and README files.
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Meziantou.Analyzer.Test/Rules/UseEqualsMethodInsteadOfOperatorAnalyzerTests.cs | New tests covering various scenarios, including special cases for primitive types and records |
| src/Meziantou.Analyzer/Rules/UseEqualsMethodInsteadOfOperatorAnalyzer.cs | Analyzer implementation to flag equality operator usage when Equals is overridden |
| src/Meziantou.Analyzer/RuleIdentifiers.cs | Addition of new rule identifier MA0169 |
| src/Meziantou.Analyzer/Internals/MethodSymbolExtensions.cs | Added extension methods for method symbol comparisons |
| docs/Rules/MA0169.md & docs/README.md & README.md | Documentation updates for the new rule |
Files not reviewed (2)
- src/Meziantou.Analyzer.Pack/configuration/default.editorconfig: Language not supported
- src/Meziantou.Analyzer.Pack/configuration/none.editorconfig: Language not supported
No description provided.