We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
EnumConverter is internally using Enum.Parse method that assumes that the parsed value matches the name of the enum value.
EnumConverter
Enum.Parse
System.Runtime.Serialization has an EnumMemberAttribute (https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.enummemberattribute) that can be used to decorate each field and specify a different value:
System.Runtime.Serialization
EnumMemberAttribute
public enum Position { [EnumMember(Value = "Emp")] Employee, [EnumMember(Value = "Mgr")] Manager, [EnumMember(Value = "Ctr")] Contractor }
This allows for easy definition of mapings between 'proper' names of enum options and the actual string values that will be serialized.
I would like to extend EnumConverter to utilize the EnumMemberAttribute during conversion.
Please let me know if you would be interested in my PR for this change.
The text was updated successfully, but these errors were encountered:
Bump
Sorry, something went wrong.
No branches or pull requests
EnumConverter
is internally usingEnum.Parse
method that assumes that the parsed value matches the name of the enum value.System.Runtime.Serialization
has anEnumMemberAttribute
(https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.enummemberattribute) that can be used to decorate each field and specify a different value:This allows for easy definition of mapings between 'proper' names of enum options and the actual string values that will be serialized.
I would like to extend
EnumConverter
to utilize theEnumMemberAttribute
during conversion.Please let me know if you would be interested in my PR for this change.
The text was updated successfully, but these errors were encountered: