From 58ee895dd7ec33790d722e7a420727d7693aab18 Mon Sep 17 00:00:00 2001 From: Chebotov Nikolay Date: Tue, 2 Mar 2021 21:10:59 +0300 Subject: [PATCH] Add small fix to CSharpJsonSerializerGenerator --- .../CSharpJsonSerializerGeneratorTests.cs | 4 ++-- .../CSharpJsonSerializerGenerator.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/CSharpJsonSerializerGeneratorTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/CSharpJsonSerializerGeneratorTests.cs index 75c24f36b..cacd08917 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/CSharpJsonSerializerGeneratorTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/CSharpJsonSerializerGeneratorTests.cs @@ -21,7 +21,7 @@ public void When_using_SytemTextJson_with_JsonConverters_GenerateJsonSerializerP Console.WriteLine(output); //// Assert - Assert.Equal(", System.Text.Json.JsonSerializerOptions(); var converters = new System.Text.Json.Serialization.JsonConverter[] { new CustomConverter1(), new CustomConverter2(), new AdditionalConverter1(), new AdditionalConverter2() }", output); + Assert.Equal(", new System.Text.Json.JsonSerializerOptions(); var converters = new System.Text.Json.Serialization.JsonConverter[] { new CustomConverter1(), new CustomConverter2(), new AdditionalConverter1(), new AdditionalConverter2() }", output); } [Fact] @@ -58,7 +58,7 @@ public void When_using_SytemTextJson_with_JsonSerializerSettingsOrOptionsTransfo Console.WriteLine(output); //// Assert - Assert.Equal(", TestJsonSerializerSettingsTransformationMethod(System.Text.Json.JsonSerializerOptions())", output); + Assert.Equal(", TestJsonSerializerSettingsTransformationMethod(new System.Text.Json.JsonSerializerOptions())", output); } [Fact] diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpJsonSerializerGenerator.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpJsonSerializerGenerator.cs index b4baebd65..981df4f4d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpJsonSerializerGenerator.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpJsonSerializerGenerator.cs @@ -64,7 +64,7 @@ private static string GenerateForJsonLibrary(CSharpGeneratorSettings settings, L { return ", " + (useSettingsTransformationMethod ? settings.JsonSerializerSettingsTransformationMethod + "(" : string.Empty) + - "System.Text.Json.JsonSerializerOptions()" + + "new System.Text.Json.JsonSerializerOptions()" + (useSettingsTransformationMethod ? ")" : string.Empty) + (hasJsonConverters ? "; var converters = " + GenerateConverters(jsonConverters, settings.JsonLibrary)