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
Dotnet 8 JsonSerializerOptions Breaking change #55692
Comments
Note that you shouldn't create a new instance of the options each time either. |
@MoishyS presumably this is using trimming or Native AOT? You appear to be impacted by this intentional breaking change: https://learn.microsoft.com/en-us/dotnet/core/compatibility/serialization/8.0/publishtrimmed. If you are using trimming or Native AOT, then you should consider using the source generator instead of the reflection-based |
@eiriktsarpalis i am having this issue for a regular aspnet app, without trimming or Native AOT |
@MoishyS can you share a minimal reproduction that demonstrates the issue? |
That repo is not public, it would help if you could extract a self contained console app or a ZIP file that everyone reading the issue can access. |
@eiriktsarpalis i made it public |
Thanks. This looks like a moderately sized project that I won't be able to take a look at right now. It would help immensely if you could reduce the bug to the smallest possible console app (one that fits in a github comment). Thanks. |
@eiriktsarpalis i used
|
Moving to aspnetcore for further triage. The error should be expected with Native AOT or |
I have a Attribute to change JSON serialization from camelCase to PascalCase, which worked fine in dotnet 7, but in dotnet 8 i am getting an error
System.InvalidOperationException: JsonSerializerOptions instance must specify a TypeInfoResolver setting before being marked as read-only
Adding
TypeInfoResolver = new DefaultJsonTypeInfoResolver()
fixes the issue, but i couldn't find any documentation on this breaking change.The text was updated successfully, but these errors were encountered: