@@ -19,6 +19,14 @@ public sealed class XmlToDescriptionGenerator : IIncrementalGenerator
1919{
2020 private const string GeneratedFileName = "ModelContextProtocol.Descriptions.g.cs" ;
2121
22+ /// <summary>
23+ /// A display format that produces fully-qualified type names with "global::" prefix
24+ /// and includes nullability annotations.
25+ /// </summary>
26+ private static readonly SymbolDisplayFormat s_fullyQualifiedFormatWithNullability =
27+ SymbolDisplayFormat . FullyQualifiedFormat . AddMiscellaneousOptions (
28+ SymbolDisplayMiscellaneousOptions . IncludeNullableReferenceTypeModifier ) ;
29+
2230 public void Initialize ( IncrementalGeneratorInitializationContext context )
2331 {
2432 // Extract method information for all MCP tools, prompts, and resources.
@@ -125,7 +133,7 @@ private static MethodToGenerate ExtractMethodInfo(
125133 . Where ( m => ! m . IsKind ( SyntaxKind . AsyncKeyword ) )
126134 . Select ( m => m . Text ) ;
127135 string modifiersStr = string . Join ( " " , modifiers ) ;
128- string returnType = methodSymbol . ReturnType . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) ;
136+ string returnType = methodSymbol . ReturnType . ToDisplayString ( s_fullyQualifiedFormatWithNullability ) ;
129137 string methodName = methodSymbol . Name ;
130138
131139 // Extract parameters
@@ -137,7 +145,7 @@ private static MethodToGenerate ExtractMethodInfo(
137145 var paramSyntax = i < parameterSyntaxList . Count ? parameterSyntaxList [ i ] : null ;
138146
139147 parameters [ i ] = new ParameterInfo (
140- ParameterType : param . Type . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat ) ,
148+ ParameterType : param . Type . ToDisplayString ( s_fullyQualifiedFormatWithNullability ) ,
141149 Name : param . Name ,
142150 HasDescriptionAttribute : descriptionAttribute is not null && HasAttribute ( param , descriptionAttribute ) ,
143151 XmlDescription : xmlDocs ? . Parameters . TryGetValue ( param . Name , out var pd ) == true && ! string . IsNullOrWhiteSpace ( pd ) ? pd : null ,
0 commit comments