The non-generic overloads AddStartupDiagnosticsSection(this IReadOnlySettings, string, object) and StartupDiagnosticEntries.Add(string, object) use reflection-based serialization via JsonSerializer.Serialize(object, JsonSerializerOptions), which is not compatible with trimming or NativeAOT.
Generic overloads AddStartupDiagnosticsSection<T>(IReadOnlySettings, string, T, JsonTypeInfo<T>) and StartupDiagnosticEntries.Add<T>(string, T, JsonTypeInfo<T>) were added in #7882 to provide an AOT-safe path using source-generated JsonSerializerContext.
The non-generic overloads
AddStartupDiagnosticsSection(this IReadOnlySettings, string, object)andStartupDiagnosticEntries.Add(string, object)use reflection-based serialization viaJsonSerializer.Serialize(object, JsonSerializerOptions), which is not compatible with trimming or NativeAOT.Generic overloads
AddStartupDiagnosticsSection<T>(IReadOnlySettings, string, T, JsonTypeInfo<T>)andStartupDiagnosticEntries.Add<T>(string, T, JsonTypeInfo<T>)were added in #7882 to provide an AOT-safe path using source-generatedJsonSerializerContext.