In this post I explore how ASP.NET Core works together with the source generated JSON serializer. In .NET 8 the streaming JSON serialization can be enabled to use serialization-optimization mode with ASP.NET Core. However, using the default settings does not enable this fast-path. In this post I will explore how to enable the fast-path serialization by exploring the inner workings of JsonTypeInfo.cs
. For this post I use .NET 8 with the corresponding ASP.NET Core release.
The .NET 8 runtime comes with three built-in JSON serializer modes:
- Reflection
- Source generation (Metadata-based mode)
- Source generation (Serialization-optimization mode)