Dotnet 8 JsonSerializerOptions Breaking change
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
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`
```
public class PascalCaseJson : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext context)
{
if (context.Result is ObjectResult objectResult)
objectResult.Formatters.Add(new SystemTextJsonOutputFormatter(new JsonSerializerOptions()));
}
}
```
Adding `TypeInfoResolver = new DefaultJsonTypeInfoResolver()` fixes the issue, but i couldn't find any documentation on this breaking change.
Contributor guide
Assessment
This issue has not been assessed yet.