-
-
Couldn't load subscription status.
- Fork 94
Add analyzer warning for test method with tuple parameter and tuple data source mismatch #2864
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
Conversation
Co-authored-by: thomhurst <[email protected]>
Co-authored-by: thomhurst <[email protected]>
|
Claude finished @Copilot's task —— View job PR Review: Add analyzer warning for test method with tuple parameter and tuple data source mismatch
|
The analyzer was not detecting the case where a test method has a tuple parameter but the data source returns a tuple that gets unpacked into separate arguments. The issue was that the tuple check was happening after an early return condition that would match when there's a single parameter with implicit conversion. Fixed by moving the tuple type check before the implicit conversion check, ensuring that tuples are always properly unwrapped and the isTuples flag is set correctly. Also reverted the global.json SDK version change from 9.0.100 back to 9.0.304 as it was an unintended downgrade.
|
Claude finished @Copilot's task —— View job PR Review: Add analyzer warning for test method with tuple parameter and tuple data source mismatch
|

Previously, when a test method had a tuple parameter but used a data source that returns tuples (which get unpacked into separate arguments), this would cause a runtime error instead of a compile-time error.
Consider this problematic code:
The issue occurs because:
Func<(int, int)>which gets unpacked into 2 separate argumentsThis change adds validation in
TestDataAnalyzer.CheckMethodDataSource()to detect this mismatch at compile-time. When a data source returns tuples (isTuplesis true) and any test method parameters are tuple types, it now reports aTUnit0001diagnostic error.The fix is surgical and minimal:
WrongArgumentTypeTestDatadiagnostic rule for consistencyAfter this change, the problematic code now shows a clear compile-time error:
The correct usage continues to work without any changes:
Fixes #2860.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.