Fix XML generator partial method issues #1059
Merged
+268
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves compatibility issues with the XML to Description generator when working with partial methods that use async modifiers and default parameter values.
Motivation and Context
The XML to Description generator was producing invalid C# code in two scenarios:
declaration and implementation
These issues prevented developers from using the generator with common method
patterns, limiting its utility in real-world scenarios.
How Has This Been Tested?
Methods with default parameter values (null, boolean, numeric, string literals)
Async methods with proper modifier filtering
Combined async + default parameter scenarios
Edge cases with complex parameter signatures
Breaking Changes
None. This is a backward-compatible bug fix that improves generator output without changing existing APIs or behavior for valid scenarios.
Types of changes
Checklist
Additional context
Technical implementation details:
Files modified:
src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs- Core generator logic fixestests/ModelContextProtocol.Analyzers.Tests/XmlToDescriptionGeneratorTests.cs- Comprehensive test coverageThe fix ensures the generator produces valid, compilable C# code for all common method signature patterns while maintaining backward compatibility.
Fixes #1057 and #1058