Add missing cases to UseProperAssertMethod analyzer#7406
Open
Evangelink wants to merge 1 commit intomainfrom
Open
Add missing cases to UseProperAssertMethod analyzer#7406Evangelink wants to merge 1 commit intomainfrom
Evangelink wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the UseProperAssertMethodsAnalyzer to recognize two additional patterns that were previously missed:
- Reversed null comparisons where null is the left operand (e.g.,
null == xinstead ofx == null) - Mixed numeric type comparisons (e.g.,
int > long)
Changes:
- Removed TODO comments indicating these cases were not yet implemented
- Enhanced null comparison detection to check both left and right operands for null literals
- Added comprehensive test coverage for the newly supported patterns
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Analyzers/MSTest.Analyzers/UseProperAssertMethodsAnalyzer.cs | Enhanced IsEqualsNullBinaryOperator and IsNotEqualsNullBinaryOperator to check both operands for null, enabling detection of reversed null comparisons |
| test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs | Added WhenAssertUsesReversedNullComparisons test to verify all reversed null comparison scenarios and WhenAssertIsTrueWithMixedNumericComparison test for mixed numeric types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.