Skip to content

Make the soure generator format enums using their identifiers rather than numeric values. - #87557

Merged
eiriktsarpalis merged 2 commits into
dotnet:mainfrom
eiriktsarpalis:improve/enum-formatting
Jun 15, 2023
Merged

eiriktsarpalis merged 2 commits into
dotnet:mainfrom
eiriktsarpalis:improve/enum-formatting

Conversation

@eiriktsarpalis

Copy link
Copy Markdown
Member

Updates the enum literal value formatter so that they are specified using their names rather than numeric values. For example the source generated code:

NumberHandling = (global::System.Text.Json.Serialization.JsonNumberHandling)3,

is now changed to

NumberHandling = global::System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | global::System.Text.Json.Serialization.JsonNumberHandling.WriteAsString,

Contributes to #79534.

@ghost

ghost commented Jun 14, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Updates the enum literal value formatter so that they are specified using their names rather than numeric values. For example the source generated code:

NumberHandling = (global::System.Text.Json.Serialization.JsonNumberHandling)3,

is now changed to

NumberHandling = global::System.Text.Json.Serialization.JsonNumberHandling.AllowReadingFromString | global::System.Text.Json.Serialization.JsonNumberHandling.WriteAsString,

Contributes to #79534.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@eiriktsarpalis
eiriktsarpalis requested review from krwq and layomia June 14, 2023 13:05
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jun 14, 2023
@eiriktsarpalis
eiriktsarpalis merged commit a2f4a94 into dotnet:main Jun 15, 2023
@eiriktsarpalis
eiriktsarpalis deleted the improve/enum-formatting branch June 15, 2023 12:32
@ghost ghost locked as resolved and limited conversation to collaborators Jul 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants