-
-
Notifications
You must be signed in to change notification settings - Fork 96
Fix missing namespace issues in TestMetadataGenerator generated code #2814
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 <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
TestMetadataGenerator generates incorrect code|
Claude finished @Copilot's task —— View job PR Review Complete ✅I've thoroughly reviewed the pull request that fixes missing namespace issues in TestMetadataGenerator generated code. Todo List:
📋 Code Review Feedback✅ Strengths
✅ Code Quality AssessmentTestMetadataGenerator.cs changes ( // Before: if (result is Task task)
// After: if (result is global::System.Threading.Tasks.Task task)
MetadataGenerationHelper.cs changes ( // Before: .FirstOrDefault(...)
// After: global::System.Linq.Enumerable.FirstOrDefault(...)
✅ Security & Performance
🔍 Potential Considerations
✅ Test Coverage Assessment
📝 Final AssessmentThis is a high-quality, focused fix that:
Recommendation: ✅ APPROVE - This PR is ready to merge. |
The
TestMetadataGeneratorwas generating code that usedTaskandFirstOrDefaultwithout fully qualified names, causing compilation errors CS0246 and CS1061 when the generated code didn't have the necessary using statements.Problem
When generating test metadata for generic methods with constraints (e.g.,
IBinaryInteger<T>), the source generator produced code like:Solution
Updated the generator to use fully qualified names consistent with the rest of the codebase:
Tasktoglobal::System.Threading.Tasks.Taskin async method invocation.FirstOrDefault(...)toglobal::System.Linq.Enumerable.FirstOrDefault(...)in reflection info generationExample
The generated code now correctly compiles:
Fixes #2813.
💡 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.