Skip to content

Map enum properties as strings as specified#461

Closed
yinzara wants to merge 1 commit intomodelcontextprotocol:mainfrom
yinzara:main
Closed

Map enum properties as strings as specified#461
yinzara wants to merge 1 commit intomodelcontextprotocol:mainfrom
yinzara:main

Conversation

@yinzara
Copy link
Copy Markdown

@yinzara yinzara commented May 29, 2025

Fixes #459

NumberHandling = JsonNumberHandling.AllowReadingFromString)]
NumberHandling = JsonNumberHandling.AllowReadingFromString
#if NET9_0_OR_GREATER
,UseStringEnumConverter = true
Copy link
Copy Markdown
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
Copy Markdown
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.

@yinzara
Copy link
Copy Markdown
Author

yinzara commented May 29, 2025 via email

@eiriktsarpalis
Copy link
Copy Markdown
Member

Superseded by #463. I'm going to close this, but thank you for the contribution regardless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

McpJsonUtilities does not function as documented - Enums get serialized to integer, not string

4 participants