Map enum properties as strings as specified#461
Closed
yinzara wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
Map enum properties as strings as specified#461yinzara wants to merge 1 commit intomodelcontextprotocol:mainfrom
yinzara wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
stephentoub
reviewed
May 29, 2025
| NumberHandling = JsonNumberHandling.AllowReadingFromString)] | ||
| NumberHandling = JsonNumberHandling.AllowReadingFromString | ||
| #if NET9_0_OR_GREATER | ||
| ,UseStringEnumConverter = true |
Contributor
There was a problem hiding this comment.
I don't think we want different behaviors here based on which build is being used.
cc: @eiriktsarpalis
Member
There was a problem hiding this comment.
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.
Author
|
It was only introduced in .NET 8 I guess I can remove it if that’s the
lowest sdk we support
…On Wed, May 28, 2025 at 8:55 PM Stephen Toub ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/ModelContextProtocol/McpJsonUtilities.cs
<#461 (comment)>
:
> @@ -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
I don't think we want different behaviors here based on which build is
being used.
cc: @eiriktsarpalis <https://github.com/eiriktsarpalis>
—
Reply to this email directly, view it on GitHub
<#461 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFEA34KZM4RNYUOXXE26U33A2ALHAVCNFSM6AAAAAB6EJSAUKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDQNZWHE4DIMZZGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Member
|
Superseded by #463. I'm going to close this, but thank you for the contribution regardless. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #459