-
-
Notifications
You must be signed in to change notification settings - Fork 95
Fix TUnit0001 analyzer to use ITypedDataSourceAttribute interface detection #2803
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
…aSourceGeneratorAttribute Co-authored-by: thomhurst <[email protected]>
…implementations Co-authored-by: thomhurst <[email protected]>
Co-authored-by: thomhurst <[email protected]>
|
@copilot Can you instead look for |
…DataSourceAttribute interface lookup Co-authored-by: thomhurst <[email protected]>
Changed the analyzer to look for |
|
Claude finished @Copilot's task —— View job PR Review CompleteTodo List:
SummaryThis PR successfully fixes TUnit0001 false positive errors for custom data source generators by replacing fragile string-based base class detection with robust interface-based detection using Code Quality & Best Practices ✅Excellent improvements:
Code structure:
Potential Bugs/Issues ✅No bugs identified. The implementation correctly:
Edge cases handled:
Performance Considerations ✅Performance is maintained or improved:
No performance regressions introduced. Security Concerns ✅No security issues identified.
Test Coverage ✅Comprehensive test coverage added:
Test quality:
Specific Technical ReviewKey change in if (attribute.AttributeClass?.AllInterfaces.FirstOrDefault(x => x.IsGenericType &&
x.ConstructedFrom.GloballyQualified() == WellKnown.AttributeFullyQualifiedClasses.ITypedDataSourceAttribute.WithGlobalPrefix + "`1")
is { } typedDataSourceInterface)
{
typeArguments = typedDataSourceInterface.TypeArguments;
}This correctly:
Overall AssessmentThis is an excellent fix that:
Recommendation: Approve and merge. The implementation is solid, well-tested, and addresses the root cause effectively. |
|
@copilot The analyzer tests need fixing |
…roach and update test expectations Co-authored-by: thomhurst <[email protected]>
Fixed! The analyzer tests were failing due to missing |
The TUnit0001 analyzer was incorrectly reporting type mismatch errors for custom data source generators that implement
ITypedDataSourceAttribute<T>with wrapper types.Problem
After upgrading from TUnit 0.25 to 0.52.25, users experienced false positive TUnit0001 warnings when using custom data source generators like:
Root Cause
The
CheckDataGeneratormethod was using string-based detection of base class names to extract type arguments, which was fragile and didn't align with the interface-based approach used by the source generator.Solution
Modified the analyzer to use the same approach as the source generator by looking for the
ITypedDataSourceAttribute<T>interface to extract type arguments. This provides a more robust and consistent method that:ITypedDataSourceAttribute<T>interface implementations firstApplicationFixture<IGantryMethods>from the interface instead ofIGantryMethodsfrom the attribute's type parametersThe fix correctly handles both single-type and tuple scenarios while maintaining full backward compatibility with existing code.
Fixes #2801.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.