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

Questions about 'JsonStringEnumConverter' not using namingPolicy when deserializing the object. #41138

Closed
liui opened this issue Aug 21, 2020 · 1 comment

Comments

@liui
Copy link

liui commented Aug 21, 2020

Use the obtained string value directly here. But why not use _namingPolicy'?

like:

        internal override T ReadWithQuotes(ref Utf8JsonReader reader)
        {
            string? enumString = reader.GetString();
            
            var v =  _namingPolicy == null ? enumString : FormatEnumValueToString(enumString, encoder);
             
            // Try parsing case sensitive first
            if (!Enum.TryParse(v, out T value)
                && !Enum.TryParse(v, ignoreCase: true, out value))
            {
                ThrowHelper.ThrowJsonException();
            }

            return value;
        }
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Aug 21, 2020
@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Aug 26, 2020
@layomia layomia added this to the 5.0.0 milestone Aug 26, 2020
@layomia
Copy link
Contributor

layomia commented Aug 26, 2020

Duplicate of #31619.

@layomia layomia closed this as completed Aug 26, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants