ProtocolJsonSerializer.ApplyExtensionOptions Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before itβs released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Applies a transformation function to SerializationOptions, replacing it with the result. This is an advanced escape hatch β prefer ApplyExtensionConverters(IList<JsonConverter>) or AddTypeInfoResolver(IJsonTypeInfoResolver) for typical extensions.
public static void ApplyExtensionOptions(Func<System.Text.Json.JsonSerializerOptions,System.Text.Json.JsonSerializerOptions> applyFunc);
static member ApplyExtensionOptions : Func<System.Text.Json.JsonSerializerOptions, System.Text.Json.JsonSerializerOptions> -> unit
Public Sub ApplyExtensionOptions (applyFunc As Func(Of JsonSerializerOptions, JsonSerializerOptions))
Parameters
- applyFunc
- Func<JsonSerializerOptions,JsonSerializerOptions>
A function that receives the current options and returns the new options.
Remarks
Important: If your function replaces TypeInfoResolver, you must include CoreJsonContext.Default in the new resolver chain. Omitting it silently removes source-generated metadata for all core model types. Use Combine(IJsonTypeInfoResolver[]) to chain resolvers:
options.TypeInfoResolver = JsonTypeInfoResolver.Combine(
YourContext.Default,
CoreJsonContext.Default,
new DefaultJsonTypeInfoResolver());