Skip to content

Fix FP with proper assert analyzer and IComparable#7405

Merged
Evangelink merged 2 commits intomainfrom
dev/amauryleve/fp-icomparable
Feb 16, 2026
Merged

Fix FP with proper assert analyzer and IComparable#7405
Evangelink merged 2 commits intomainfrom
dev/amauryleve/fp-icomparable

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Fix #7343

Copy link
Copy Markdown
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 fixes a false positive in the UseProperAssertMethodsAnalyzer where it would incorrectly suggest using Assert.IsGreaterThan and similar comparison methods for types that don't implement IComparable<T>, specifically nullable value types like TimeSpan?.

Changes:

  • Added IComparable validation before suggesting comparison assert methods
  • Added test case for nullable value type comparisons

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 Added CanUseTypesWithComparableAsserts and related helper methods to validate types implement IComparable before suggesting comparison assert methods
test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs Added test to verify nullable value types don't trigger comparison assert suggestions

Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Evangelink Evangelink enabled auto-merge February 14, 2026 20:49
@Evangelink Evangelink merged commit 75779f8 into main Feb 16, 2026
10 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/fp-icomparable branch February 16, 2026 08:54
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.

Possible false positive for proper assert method analyzer

3 participants