Skip to content

Add JsonSourceGenerationOptions.UseStringEnumConverter #88984

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

Merged

Conversation

eiriktsarpalis
Copy link
Member

This PR:

  • Implements the JsonSourceGenerationOptionsAttribuet.UseStringEnumConverter property.
  • Implements the JsonNumberEnumConverter<TEnum> converter.

Fix #87195.

@ghost
Copy link

ghost commented Jul 17, 2023

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned eiriktsarpalis Jul 17, 2023
@ghost
Copy link

ghost commented Jul 17, 2023

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

This PR:

  • Implements the JsonSourceGenerationOptionsAttribuet.UseStringEnumConverter property.
  • Implements the JsonNumberEnumConverter<TEnum> converter.

Fix #87195.

Author: eiriktsarpalis
Assignees: -
Labels:

area-System.Text.Json, new-api-needs-documentation

Milestone: -

@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jul 17, 2023
@eiriktsarpalis eiriktsarpalis requested review from layomia and krwq July 17, 2023 08:15
@eiriktsarpalis eiriktsarpalis merged commit f83580d into dotnet:main Jul 17, 2023
@eiriktsarpalis eiriktsarpalis deleted the feature/json-string-enum-flag branch July 17, 2023 19:28
@svrooij
Copy link

svrooij commented Aug 16, 2023

Any idea when such a feature will be rolled out?

@eiriktsarpalis
Copy link
Member Author

It should be available starting with .NET 8 Preview 7

@svrooij
Copy link

svrooij commented Aug 16, 2023

@eiriktsarpalis any chance it will be backported to .NET7? Thanks for the super fast answer.

@eiriktsarpalis
Copy link
Member Author

The bar for servicing .NET 7 is security issues or substantially broken .NET 7 features. You can still use the latest STJ version in .NET 7 using the NuGet package though.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 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.

JsonSourceGenerationOptionsAttribute should provide an option for enabling string enum serialization globally
4 participants