Fully qualify more types in source generated code to avoid namespace clashes - #2797
#2797Fully qualify more types in source generated code to avoid namespace clashes#2797thomhurst merged 3 commits intomainthomhurst/TUnit:mainfrom feature/globally-qualify-souce-gen-06082025thomhurst/TUnit:feature/globally-qualify-souce-gen-06082025Copy head branch name to clipboard
Conversation
Ensure all generated code uses globally qualified type names to prevent compilation errors when types are not in scope or have naming conflicts. Changes: - Fixed unqualified generic types in method signatures (IAsyncEnumerable, Func, Task) - Added global:: prefix to System.Collections.IEnumerable references - Qualified all exception types (InvalidOperationException, ArgumentException, NotSupportedException) - Qualified System.Diagnostics.Debug.WriteLine calls - Fixed CancellationToken, CancellationTokenSource, and TimeSpan references - Qualified all System.Reflection.BindingFlags usages This resolves compilation errors in projects using TUnit where generated code references types like Func<>, IAsyncEnumerable<>, and Task<> without proper qualification. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @thomhurst's task —— View job PR Review: Fully qualify more types in source generated codeThis PR addresses namespace clashes by globally qualifying type references throughout the source generator. Here's my comprehensive review: ✅ Code Quality & Best PracticesExcellent approach: The consistent use of
Clean implementation: The ✅ Potential Issues - None CriticalNo significant bugs found. The changes are mechanical and safe:
Edge case consideration: The special handling for generic type parameters ( ✅ Performance ConsiderationsMinimal impact:
AOT-friendly: The fully qualified names improve compatibility with AOT scenarios by removing ambiguity. ✅ Security ConcernsNo security issues: These are syntactic changes to generated code that don't introduce vulnerabilities. The qualification actually improves security by preventing potential type confusion attacks. ✅ Test Coverage ImpactComprehensive test coverage:
Pattern validation: The verified test files show consistent application across different code generation scenarios (metadata, hooks, AOT optimization). 📋 SummaryThis is a high-quality, low-risk change that significantly improves the robustness of the source generator by preventing namespace clashes. The implementation is:
Recommendation: ✅ Approve - This change enhances the reliability of the source generator without introducing risks.
|
No description provided.