Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JsonStringEnumConverter to KnownConverters #16913

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

hishamco
Copy link
Member

Fixes #16879

@hishamco
Copy link
Member Author

@hieucd04 could you please try this PR at your end

@hieucd04
Copy link

@hishamco I can only help testing nuget packages, pulling them into my code base on my end then run the code and check if they work or not. I've never built Orchard's code base from source. I'm sorry!

@hishamco
Copy link
Member Author

I already tested the PR and works great

@@ -16,6 +16,7 @@ public static class JOptions
PathStringJsonConverter.Instance,
TimeSpanJsonConverter.Instance,
DateTimeJsonConverter.Instance,
new JsonStringEnumConverter()
Copy link
Member

Choose a reason for hiding this comment

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

First, you should create a static instance of this converter and the static instance. This will fix the issue. However, this will change the behavior of how we store enum moving forward from int to string.

But it could increase the size of data being transmitted from and to the server. Personally, I am okay with storing strings instead of int since this will ensure we don't have enum problem if someone adds a new enum value in position other than the end of the enum.

I would also document this change in the release notes to ensure people are aware of this change.

@sebastienros thought on this global behavior?

Copy link
Member

Choose a reason for hiding this comment

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

Related discussion #13154

Copy link
Member

Choose a reason for hiding this comment

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

If we don't own the converter it's fine to not have the Instance property.
Does it work with both int and string as input, to be sure it's not breaking any.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't own the converter

Does it work with both int and string as input, to be sure it's not breaking any.

It should, but I will try another test

Copy link
Member

Choose a reason for hiding this comment

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

@sebastienros yes it works with both int and string. However, it will write string moving forward and not int. It won't break anyone but will change the behavior.

Copy link
Member

@sebastienros sebastienros left a comment

Choose a reason for hiding this comment

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

Approve pending comment

@MikeAlhayek MikeAlhayek merged commit 70edc48 into main Oct 25, 2024
12 checks passed
@MikeAlhayek MikeAlhayek deleted the hishamco/enum-json-converter branch October 25, 2024 19:17
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.

Recipe step -> OpenIdServerSettings -> AccessTokenFormat doesn't work
4 participants