Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ModelContextProtocol/McpJsonUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ internal static bool IsValidMcpToolSchema(JsonElement element)
// Keep in sync with CreateDefaultOptions above.
[JsonSourceGenerationOptions(JsonSerializerDefaults.Web,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
NumberHandling = JsonNumberHandling.AllowReadingFromString)]
NumberHandling = JsonNumberHandling.AllowReadingFromString
#if NET9_0_OR_GREATER
,UseStringEnumConverter = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want different behaviors here based on which build is being used.
cc: @eiriktsarpalis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this doesn't address the issue at hand. UseStringEnumConverter tells the source generator to use the string-based converter for enums that it can see at compile time. It can't apply the same behavior to types introduced by the user since it can't be done in a AOT compatible manner.

#endif
)]

// JSON-RPC
[JsonSerializable(typeof(JsonRpcMessage))]
Expand Down