From f47b5f42441976616441cf0e7d95581a010428d4 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 13 Jul 2023 14:51:49 -0700 Subject: [PATCH 1/4] Set default JSON type resolver if not set --- .../src/Microsoft.AspNetCore.Http.Extensions.csproj | 1 + .../src/Microsoft.AspNetCore.Http.Results.csproj | 1 + .../Routing/src/Microsoft.AspNetCore.Routing.csproj | 1 + .../src/Formatters/SystemTextJsonOutputFormatter.cs | 1 + .../Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj | 1 + src/Shared/Json/EmptyJsonTypeInfoResolver.cs | 11 +++++++++++ src/Shared/Json/JsonSerializerExtensions.cs | 1 + 7 files changed, 17 insertions(+) create mode 100644 src/Shared/Json/EmptyJsonTypeInfoResolver.cs diff --git a/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj b/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj index bae329c37d92..de56d748727a 100644 --- a/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj +++ b/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj @@ -23,6 +23,7 @@ + diff --git a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj index 435b47be5bd7..1b2702a66cc4 100644 --- a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj +++ b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj @@ -19,6 +19,7 @@ + diff --git a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj index dc069991aaed..a5dacd9b0e1f 100644 --- a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj +++ b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj @@ -30,6 +30,7 @@ + diff --git a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs index 273b11d6f65d..c93f62c1211a 100644 --- a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs +++ b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs @@ -23,6 +23,7 @@ public SystemTextJsonOutputFormatter(JsonSerializerOptions jsonSerializerOptions { SerializerOptions = jsonSerializerOptions; + jsonSerializerOptions.TypeInfoResolver ??= new EmptyJsonTypeInfoResolver(); jsonSerializerOptions.MakeReadOnly(); SupportedEncodings.Add(Encoding.UTF8); diff --git a/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj b/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj index 9311815e0d31..b31f0881604b 100644 --- a/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj +++ b/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj @@ -34,6 +34,7 @@ Microsoft.AspNetCore.Mvc.RouteAttribute + diff --git a/src/Shared/Json/EmptyJsonTypeInfoResolver.cs b/src/Shared/Json/EmptyJsonTypeInfoResolver.cs new file mode 100644 index 000000000000..75b7911b1e5e --- /dev/null +++ b/src/Shared/Json/EmptyJsonTypeInfoResolver.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; +using System.Text.Json.Serialization.Metadata; + +internal sealed class EmptyJsonTypeInfoResolver : IJsonTypeInfoResolver +{ + /// + public JsonTypeInfo? GetTypeInfo(Type type, JsonSerializerOptions options) => null; +} diff --git a/src/Shared/Json/JsonSerializerExtensions.cs b/src/Shared/Json/JsonSerializerExtensions.cs index 7068649a63f5..ea65cb793ecb 100644 --- a/src/Shared/Json/JsonSerializerExtensions.cs +++ b/src/Shared/Json/JsonSerializerExtensions.cs @@ -18,6 +18,7 @@ public static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(fa public static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) { + options.TypeInfoResolver ??= new EmptyJsonTypeInfoResolver(); options.MakeReadOnly(); return options.GetTypeInfo(type); } From f7ddbaf390c97de15a53d704faba153e7ee75a07 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 14 Jul 2023 09:45:15 -0700 Subject: [PATCH 2/4] Use JsonTypeInfoResolver.Combine and add tests --- ...icrosoft.AspNetCore.Http.Extensions.csproj | 1 - .../test/RequestDelegateFactoryTests.cs | 40 +++++++++++++++++ .../Microsoft.AspNetCore.Http.Results.csproj | 1 - .../src/Microsoft.AspNetCore.Routing.csproj | 1 - .../SystemTextJsonOutputFormatter.cs | 2 +- .../src/Microsoft.AspNetCore.Mvc.Core.csproj | 1 - .../SystemTextJsonOutputFormatterTest.cs | 43 ++++++++++++++++++- src/Shared/Json/EmptyJsonTypeInfoResolver.cs | 11 ----- src/Shared/Json/JsonSerializerExtensions.cs | 2 +- 9 files changed, 83 insertions(+), 19 deletions(-) delete mode 100644 src/Shared/Json/EmptyJsonTypeInfoResolver.cs diff --git a/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj b/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj index de56d748727a..bae329c37d92 100644 --- a/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj +++ b/src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj @@ -23,7 +23,6 @@ - diff --git a/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs b/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs index d37206d6b411..e9ac8b23dff0 100644 --- a/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs +++ b/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs @@ -29,6 +29,7 @@ using Microsoft.AspNetCore.Http.Metadata; using Microsoft.AspNetCore.Routing.Patterns; using Microsoft.AspNetCore.Testing; +using Microsoft.DotNet.RemoteExecutor; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; @@ -2903,6 +2904,45 @@ static void TestAction([AsParameters] ParameterListMixedRequiredStringsFromDiffe } #nullable enable + [ConditionalFact] + [RemoteExecutionSupported] + public void RequestDelegateFactory_WhenJsonIsReflectionEnabledByDefaultFalse() + { + var options = new RemoteInvokeOptions(); + options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", false.ToString()); + + using var remoteHandle = RemoteExecutor.Invoke(static () => + { + // Arrange + var @delegate = (string task) => new Todo(); + + // IsReflectionEnabledByDefault defaults to `false` when `PublishTrimmed=true`. For these scenarios, we + // expect users to configure JSON source generation as instructed in the `NotSupportedException` message. + var exception = Assert.Throws(() => RequestDelegateFactory.Create(@delegate)); + Assert.Equal( + "JsonTypeInfo metadata for type 'Microsoft.AspNetCore.Routing.Internal.RequestDelegateFactoryTests+Todo' was not provided by TypeInfoResolver of type '[]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.", + exception.Message); + }, options); + } + + [ConditionalFact] + [RemoteExecutionSupported] + public void RequestDelegateFactory_WhenJsonIsReflectionEnabledByDefaultTrue() + { + var options = new RemoteInvokeOptions(); + options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", true.ToString()); + + using var remoteHandle = RemoteExecutor.Invoke(static () => + { + // Arrange + var @delegate = (string task) => new Todo(); + + // Assert + var exception = Record.Exception(() => RequestDelegateFactory.Create(@delegate)); + Assert.Null(exception); + }, options); + } + private DefaultHttpContext CreateHttpContext() { var responseFeature = new TestHttpResponseFeature(); diff --git a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj index 1b2702a66cc4..435b47be5bd7 100644 --- a/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj +++ b/src/Http/Http.Results/src/Microsoft.AspNetCore.Http.Results.csproj @@ -19,7 +19,6 @@ - diff --git a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj index a5dacd9b0e1f..dc069991aaed 100644 --- a/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj +++ b/src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj @@ -30,7 +30,6 @@ - diff --git a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs index c93f62c1211a..8dab688904a9 100644 --- a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs +++ b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs @@ -23,7 +23,7 @@ public SystemTextJsonOutputFormatter(JsonSerializerOptions jsonSerializerOptions { SerializerOptions = jsonSerializerOptions; - jsonSerializerOptions.TypeInfoResolver ??= new EmptyJsonTypeInfoResolver(); + jsonSerializerOptions.TypeInfoResolver ??= JsonTypeInfoResolver.Combine(); jsonSerializerOptions.MakeReadOnly(); SupportedEncodings.Add(Encoding.UTF8); diff --git a/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj b/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj index b31f0881604b..9311815e0d31 100644 --- a/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj +++ b/src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj @@ -34,7 +34,6 @@ Microsoft.AspNetCore.Mvc.RouteAttribute - diff --git a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs index 203f03590831..c3afd566dc69 100644 --- a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs +++ b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs @@ -6,6 +6,8 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.Text.Json.Serialization.Metadata; +using Microsoft.AspNetCore.Testing; +using Microsoft.DotNet.RemoteExecutor; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; @@ -254,13 +256,50 @@ private static async IAsyncEnumerable GetPeopleAsync() } [Fact] - public void WriteResponseBodyAsync_Throws_WhenTypeResolverIsNull() + public void WriteResponseBodyAsync_Works_WhenTypeResolverIsNull() { // Arrange var jsonOptions = new JsonOptions(); jsonOptions.JsonSerializerOptions.TypeInfoResolver = null; - Assert.Throws(() => SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions)); + var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); + Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + } + + [ConditionalFact] + [RemoteExecutionSupported] + public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDefaultFalse() + { + var options = new RemoteInvokeOptions(); + options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", false.ToString()); + + using var remoteHandle = RemoteExecutor.Invoke(static () => + { + // Arrange + var jsonOptions = new JsonOptions(); + + // Assert + var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); + Assert.IsAssignableFrom(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + }, options); + } + + [ConditionalFact] + [RemoteExecutionSupported] + public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDefaultTrue() + { + var options = new RemoteInvokeOptions(); + options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", true.ToString()); + + using var remoteHandle = RemoteExecutor.Invoke(static () => + { + // Arrange + var jsonOptions = new JsonOptions(); + + // Assert + var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); + Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + }, options); } private class Person diff --git a/src/Shared/Json/EmptyJsonTypeInfoResolver.cs b/src/Shared/Json/EmptyJsonTypeInfoResolver.cs deleted file mode 100644 index 75b7911b1e5e..000000000000 --- a/src/Shared/Json/EmptyJsonTypeInfoResolver.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text.Json; -using System.Text.Json.Serialization.Metadata; - -internal sealed class EmptyJsonTypeInfoResolver : IJsonTypeInfoResolver -{ - /// - public JsonTypeInfo? GetTypeInfo(Type type, JsonSerializerOptions options) => null; -} diff --git a/src/Shared/Json/JsonSerializerExtensions.cs b/src/Shared/Json/JsonSerializerExtensions.cs index ea65cb793ecb..d7fd2f03b87f 100644 --- a/src/Shared/Json/JsonSerializerExtensions.cs +++ b/src/Shared/Json/JsonSerializerExtensions.cs @@ -18,7 +18,7 @@ public static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(fa public static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) { - options.TypeInfoResolver ??= new EmptyJsonTypeInfoResolver(); + options.TypeInfoResolver ??= JsonTypeInfoResolver.Combine(); options.MakeReadOnly(); return options.GetTypeInfo(type); } From 310c148c6b6c6438d08d75fa1111f844e461fc4d Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 14 Jul 2023 10:19:23 -0700 Subject: [PATCH 3/4] Add comment and fix test assertion --- .../Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs | 1 + .../test/Formatters/SystemTextJsonOutputFormatterTest.cs | 2 +- src/Shared/Json/JsonSerializerExtensions.cs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs index 8dab688904a9..35000cb21ae2 100644 --- a/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs +++ b/src/Mvc/Mvc.Core/src/Formatters/SystemTextJsonOutputFormatter.cs @@ -23,6 +23,7 @@ public SystemTextJsonOutputFormatter(JsonSerializerOptions jsonSerializerOptions { SerializerOptions = jsonSerializerOptions; + // Use JsonTypeInfoResolver.Combine() to produce an empty TypeInfoResolver jsonSerializerOptions.TypeInfoResolver ??= JsonTypeInfoResolver.Combine(); jsonSerializerOptions.MakeReadOnly(); diff --git a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs index c3afd566dc69..a7cf8e461642 100644 --- a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs +++ b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs @@ -263,7 +263,7 @@ public void WriteResponseBodyAsync_Works_WhenTypeResolverIsNull() jsonOptions.JsonSerializerOptions.TypeInfoResolver = null; var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); - Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); } [ConditionalFact] diff --git a/src/Shared/Json/JsonSerializerExtensions.cs b/src/Shared/Json/JsonSerializerExtensions.cs index d7fd2f03b87f..36f823efbd56 100644 --- a/src/Shared/Json/JsonSerializerExtensions.cs +++ b/src/Shared/Json/JsonSerializerExtensions.cs @@ -18,6 +18,7 @@ public static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(fa public static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) { + // Use JsonTypeInfoResolver.Combine() to produce an empty TypeInfoResolver options.TypeInfoResolver ??= JsonTypeInfoResolver.Combine(); options.MakeReadOnly(); return options.GetTypeInfo(type); From 565d21f2805dd0bc23e7673f3647541f5b4a335d Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Fri, 14 Jul 2023 11:15:22 -0700 Subject: [PATCH 4/4] Tweak tests --- .../test/RequestDelegateFactoryTests.cs | 5 ++- .../SystemTextJsonOutputFormatterTest.cs | 33 +++++++------------ 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs b/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs index e9ac8b23dff0..0de35134714b 100644 --- a/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs +++ b/src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs @@ -2919,9 +2919,8 @@ public void RequestDelegateFactory_WhenJsonIsReflectionEnabledByDefaultFalse() // IsReflectionEnabledByDefault defaults to `false` when `PublishTrimmed=true`. For these scenarios, we // expect users to configure JSON source generation as instructed in the `NotSupportedException` message. var exception = Assert.Throws(() => RequestDelegateFactory.Create(@delegate)); - Assert.Equal( - "JsonTypeInfo metadata for type 'Microsoft.AspNetCore.Routing.Internal.RequestDelegateFactoryTests+Todo' was not provided by TypeInfoResolver of type '[]'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.", - exception.Message); + Assert.Contains("Microsoft.AspNetCore.Routing.Internal.RequestDelegateFactoryTests+Todo", exception.Message); + Assert.Contains("JsonSerializableAttribute", exception.Message); }, options); } diff --git a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs index a7cf8e461642..d16ce19fb9da 100644 --- a/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs +++ b/src/Mvc/Mvc.Core/test/Formatters/SystemTextJsonOutputFormatterTest.cs @@ -263,15 +263,17 @@ public void WriteResponseBodyAsync_Works_WhenTypeResolverIsNull() jsonOptions.JsonSerializerOptions.TypeInfoResolver = null; var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); - Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + Assert.IsAssignableFrom(stjOutputFormatter.SerializerOptions.TypeInfoResolver); } - [ConditionalFact] + [ConditionalTheory] [RemoteExecutionSupported] - public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDefaultFalse() + [InlineData(false)] + [InlineData(true)] + public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDefaultFalse(bool isReflectionEnabledByDefault) { var options = new RemoteInvokeOptions(); - options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", false.ToString()); + options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", isReflectionEnabledByDefault.ToString()); using var remoteHandle = RemoteExecutor.Invoke(static () => { @@ -281,24 +283,11 @@ public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDe // Assert var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); Assert.IsAssignableFrom(stjOutputFormatter.SerializerOptions.TypeInfoResolver); - }, options); - } - - [ConditionalFact] - [RemoteExecutionSupported] - public void STJOutputFormatter_UsesEmptyResolver_WhenJsonIsReflectionEnabledByDefaultTrue() - { - var options = new RemoteInvokeOptions(); - options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", true.ToString()); - - using var remoteHandle = RemoteExecutor.Invoke(static () => - { - // Arrange - var jsonOptions = new JsonOptions(); - - // Assert - var stjOutputFormatter = SystemTextJsonOutputFormatter.CreateFormatter(jsonOptions); - Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + // Use default resolver if reflection is enabled instead of empty one + if (JsonSerializer.IsReflectionEnabledByDefault) + { + Assert.IsType(stjOutputFormatter.SerializerOptions.TypeInfoResolver); + } }, options); }