-
Notifications
You must be signed in to change notification settings - Fork 289
Fix MSTEST0037: Report diagnostic for BCL types with user-defined operators #6803
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
Open
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/fix-mstest0037-reporting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Add IsBCLType helper method to check if a type is from BCL by comparing assembly public key - Update RecognizeComparisonCheck to allow user-defined operators from BCL types - Update RecognizeEqualityCheck to allow user-defined operators from BCL types - Update IsEqualsNullBinaryOperator and IsNotEqualsNullBinaryOperator for BCL types - Add comprehensive tests for TimeSpan and DateTime comparisons Co-authored-by: Evangelink <[email protected]>
Co-authored-by: Evangelink <[email protected]>
Copilot
AI
changed the title
[WIP] Fix MSTEST0037 not reported for IComparable<T> types
Fix MSTEST0037: Report diagnostic for BCL types with user-defined operators
Oct 26, 2025
Copilot finished work on behalf of
Evangelink
October 26, 2025 11:29
Evangelink
reviewed
Oct 27, 2025
test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
…dsAnalyzerTests.cs
…dsAnalyzerTests.cs
Evangelink
reviewed
Oct 27, 2025
test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
Evangelink
reviewed
Oct 27, 2025
test/UnitTests/MSTest.Analyzers.UnitTests/UseProperAssertMethodsAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
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.
MSTEST0037 was not reporting diagnostics for BCL types like
TimeSpanandDateTimebecause their comparison operators are user-defined. The analyzer conservatively excluded all user-defined operators to avoid false positives.Changes
Added
IsBCLTypehelper - Identifies BCL types by comparing assembly public keys (same approach as existingIsBCLCollectionType)Updated operator recognition methods to allow user-defined operators from BCL types:
RecognizeComparisonCheck- comparison operators (>, >=, <, <=)RecognizeEqualityCheck- equality operators (==, !=)IsEqualsNullBinaryOperator,IsNotEqualsNullBinaryOperator- null checksRecognizeNullCheck- wrapper for null checksAdded tests for
TimeSpan,DateTime, and user-defined types to prevent regressionsExample
Before:
After:
User-defined types remain unaffected:
Fixes #3982
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
7tjvsblobprodcus341.vsblob.vsassets.io/home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/11.0.0-beta.25524.1.txt(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.