Skip to content

Conversation

@Evangelink
Copy link
Member

Fixes #7174

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 improves the robustness of the UseProperAssertMethodsAnalyzer by replacing string-based type comparison (ToDisplayString()) with proper symbol-based comparison using SymbolEqualityComparer.Default.Equals(). This is a best practice in Roslyn analyzers that prevents potential issues with type name resolution.

Changes:

  • Added SystemLinqEnumerable constant to WellKnownTypeNames helper class
  • Modified analyzer to retrieve and pass System.Linq.Enumerable type symbol through analysis methods
  • Replaced all string comparisons against "System.Linq.Enumerable" with symbol equality comparisons
  • Added proper null handling for the optional enumerableTypeSymbol parameter

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Analyzers/MSTest.Analyzers/Helpers/WellKnownTypeNames.cs Added constant for System.Linq.Enumerable type name
src/Analyzers/MSTest.Analyzers/UseProperAssertMethodsAnalyzer.cs Replaced string-based type comparison with symbol comparison for LINQ type checks; added proper null handling for optional symbol

@Evangelink Evangelink merged commit f6a183d into main Jan 19, 2026
16 of 17 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/symbol branch January 19, 2026 13:08
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.

Revise UseProperAssertMethodsAnalyzer

3 participants