Skip to content

Commit 86c9393

Browse files
Copilotstephentoub
andcommitted
Fix IL2026 trimming warning by providing type info to JsonSerializer.SerializeToNode
Co-authored-by: stephentoub <[email protected]>
1 parent 0d3b47f commit 86c9393

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ModelContextProtocol.Core/Server/AIFunctionMcpServerTool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,14 @@ internal static IReadOnlyList<object> CreateMetadata(MethodInfo method)
372372
var metaAttributes = method.GetCustomAttributes<McpMetaAttribute>();
373373

374374
JsonObject? meta = seedMeta;
375+
JsonSerializerOptions options = serializerOptions ?? McpJsonUtilities.DefaultOptions;
375376
foreach (var attr in metaAttributes)
376377
{
377378
meta ??= new JsonObject();
378379
// Only add the attribute property if it doesn't already exist in the seed
379380
if (!meta.ContainsKey(attr.Name))
380381
{
381-
meta[attr.Name] = JsonSerializer.SerializeToNode(attr.Value, serializerOptions ?? McpJsonUtilities.DefaultOptions);
382+
meta[attr.Name] = JsonSerializer.SerializeToNode(attr.Value, options.GetTypeInfo(typeof(object)));
382383
}
383384
}
384385

0 commit comments

Comments
 (0)