Repository navigation
EnumMemberAttribute support - #41648
CodeBlanch wants to merge 1 commit into
Conversation
…en/read from JSON when processing enums. Fixed JsonNamingPolicy round-trip issue.
|
I've also created a project + NuGet which extends the JsonStringEnumConverter to supports attributes like For details, see https://github.com/StefH/System.Text.Json.EnumExtensions |
|
Thank you for your contribution. As announced in dotnet/coreclr#27549 this repository will be moving to dotnet/runtime on November 13. If you would like to continue working on this PR after this date, the easiest way to move the change to dotnet/runtime is:
|
|
Can we first close on the discussion of wether or not we want this feature before adding the PR? It's unusual for us to support a single attribute from System.Runtime.Serialization without supporting all the extensibility points defined here. I'd like for folks to weigh on that discussion before moving forward with a PR. Thank you for your contribution and let's move discussion over to #41578. |
Example:
In that example MyCustomEnum.Third will round-trip as "third value" in JSON.
This gives System.Text.Json parity with Json.Net wrt Enums.
If for some reason you define a JsonNamingPolicy that builds values Enum.Parse won't understand, than enums won't round-trip.
Example:
That JsonNamingPolicy will create values during serialization that won't be understood during deserialization.
Issues
Resolves https://github.com/dotnet/corefx/issues/41578