-
Notifications
You must be signed in to change notification settings - Fork 289
Add MSTEST0059: Detect conflicting Parallelize and DoNotParallelize attributes #6823
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
base: main
Are you sure you want to change the base?
Conversation
…ze attributes Co-authored-by: Evangelink <[email protected]>
Evangelink
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot some tests are broken
test/UnitTests/MSTest.Analyzers.UnitTests/UseParallelizeAttributeAnalyzerTests.cs#L34
test/UnitTests/MSTest.Analyzers.UnitTests/UseParallelizeAttributeAnalyzerTests.cs(34,1): error : Test method MSTest.Analyzers.Test.UseParallelizeAttributeAnalyzerTests.WhenBothAttributesSetInDifferentOrder_Diagnostic threw exception:
System.InvalidOperationException: Context: Diagnostics of test state
Mismatch between number of diagnostics returned, expected "1" actual "0"
Diagnostics:
NONE.
Co-authored-by: Evangelink <[email protected]>
Fixed in c458eb3. The issue was that the test adapter check was happening before the conflicting attributes check, preventing MSTEST0058 from being reported when the adapter wasn't referenced. I've reordered the logic so MSTEST0058 is now reported regardless of test adapter presence, while MSTEST0001 (missing attributes) still only reports when the adapter is referenced. 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
src/Analyzers/MSTest.Analyzers/UseParallelizeAttributeAnalyzer.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Evangelink <[email protected]>
Co-authored-by: Youssef Victor <[email protected]>
…ma-separated values Co-authored-by: Evangelink <[email protected]>
Add analyzer MSTEST0058 to prevent having both Parallelize and DoNotParallelize assembly attributes
Summary
This PR implements a new analyzer (MSTEST0058) that detects and reports a warning when an assembly has both
[Parallelize]and[DoNotParallelize]attributes, which creates an ambiguous configuration.Implementation Details
Analyzer Logic:
Test Coverage:
[assembly: Parallelize(...), MyAsm])Localization:
{Locked="..."}) to resource strings to prevent translation of attribute names[Parallelize]and[DoNotParallelize]{Locked=...}instead of comma-separated valuesDocumentation:
[DoNotParallelize]takes precedence and parallelization will be disabledBug Fix:
Improvements:
Changed from no-location diagnostics to location-specific diagnostics on both conflicting attributes
Users now see exactly where the conflicting attributes are declared, improving the developer experience
Fixes MSTEST0001: Explicitly enable or disable tests parallelization #6822
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.