Skip to content

suggestion: backward compatibility to deserialize same enum type option to itself #32

@ShirlyAr

Description

@ShirlyAr

In case of using a custom converter policy for example:
options.Converters.Add(new JsonStringEnumMemberConverter(new UpperSnakeCaseNamingPolicy(), false));

 class public enum Days
{
   SundayDay,
   MondayDay,
   FridayDay
}

In POST action , when trying to deserialize "SUNDAY_DAY " the input can be :

  • "Sunday_Day"
  • "SUnday_DAY"
  • "sunday_day"
    the result of deserialize will be correct -> Days.SundayDay

We might want to support backward compatibility to deserialize same enum type option to itself.
So in POST action , when trying to deserialize "SundayDay " to -> Days.SundayDay it will work.

Adding this line of code, will accomplish that:

_TransformedToRaw[typedValue.ToString()] = new EnumInfo(name, typedValue, rawValue);

Please consider adding this capability to the code.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions