Skip to content

Add missing cases to UseProperAssertMethod analyzer#7406

Open
Evangelink wants to merge 1 commit intomainfrom
dev/amauryleve/analyzer
Open

Add missing cases to UseProperAssertMethod analyzer#7406
Evangelink wants to merge 1 commit intomainfrom
dev/amauryleve/analyzer

Conversation

@Evangelink
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a 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 extends the UseProperAssertMethodsAnalyzer to recognize two additional patterns that were previously missed:

  1. Reversed null comparisons where null is the left operand (e.g., null == x instead of x == null)
  2. 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

@Evangelink Evangelink enabled auto-merge February 14, 2026 20:15
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