diff --git a/.gitattributes b/.gitattributes index 151823642..d06b0e8b1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -152,7 +152,5 @@ makefile text *.exe binary *.pyc binary -# Verify support +# Verify *.verified.txt text eol=lf working-tree-encoding=UTF-8 -*.verified.xml text eol=lf working-tree-encoding=UTF-8 -*.verified.json text eol=lf working-tree-encoding=UTF-8 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 40777ee10..c8404d3a6 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ _ReSharper.Caches /artifacts node_modules + +# Verify +*.received.* +*.received/ \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index e16a7054d..a94d16e17 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -41,6 +41,9 @@ [CA1720] Identifier 'xxx' contains type name --> $(NoWarn);CA1200;CA1510;CA1716;CA1720 + + + $(NoWarn);xUnit1051 diff --git a/Directory.Packages.props b/Directory.Packages.props index 35cdfdf91..4640de49e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,14 +10,12 @@ - - - - + + diff --git a/src/.editorconfig b/src/.editorconfig index aaad355eb..97aeb6a6e 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -8,3 +8,13 @@ indent_style = space indent_size = 4 end_of_line = crlf insert_final_newline = false + +# Verify +[*.{received,verified}.{txt}] +charset = utf-8-bom +end_of_line = lf +indent_size = unset +indent_style = unset +insert_final_newline = false +tab_width = unset +trim_trailing_whitespace = false diff --git a/src/NJsonSchema.Benchmark/JsonInheritanceConverterBenchmarks.cs b/src/NJsonSchema.Benchmark/JsonInheritanceConverterBenchmarks.cs deleted file mode 100644 index 3a19e4156..000000000 --- a/src/NJsonSchema.Benchmark/JsonInheritanceConverterBenchmarks.cs +++ /dev/null @@ -1,48 +0,0 @@ -using NBench; -using NJsonSchema.Tests.Generation; -using Pro.NBench.xUnit.XunitExtensions; -using Counter = NBench.Counter; - -namespace NJsonSchema.Benchmark -{ - public class JsonInheritanceConverterBenchmarks - { - private Counter _counter; - private JsonInheritanceConverterTests _tests; - - [PerfSetup] - public void Setup(BenchmarkContext context) - { - _counter = context.GetCounter("Iterations"); - _tests = new JsonInheritanceConverterTests(); - } - - [NBenchFact] - [PerfBenchmark( - NumberOfIterations = 3, - RunTimeMilliseconds = 1000, - RunMode = RunMode.Throughput, - TestMode = TestMode.Test)] - [CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 100)] - public void Serialize() - { - _tests.When_serializing_discriminator_property_is_set(); - _tests.When_serializing_discriminator_property_is_overwritten_if_already_present(); - _counter.Increment(); - } - - [NBenchFact] - [PerfBenchmark( - NumberOfIterations = 3, - RunTimeMilliseconds = 1000, - RunMode = RunMode.Throughput, - TestMode = TestMode.Test)] - [CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 100)] - public void Deserialize() - { - _tests.When_deserializing_type_is_resolved_using_discriminator_value(); - _tests.When_deserializing_existing_property_is_populated_with_discriminator_value(); - _counter.Increment(); - } - } -} diff --git a/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj b/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj index c5992515f..59a84f011 100644 --- a/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj +++ b/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj @@ -16,18 +16,12 @@ - - - - - - diff --git a/src/NJsonSchema.Benchmark/SchemaGenerationBenchmarks.cs b/src/NJsonSchema.Benchmark/SchemaGenerationBenchmarks.cs index 35f36ba85..7dfaa9829 100644 --- a/src/NJsonSchema.Benchmark/SchemaGenerationBenchmarks.cs +++ b/src/NJsonSchema.Benchmark/SchemaGenerationBenchmarks.cs @@ -1,32 +1,13 @@ using System.Runtime.Serialization; -using NBench; using NJsonSchema.NewtonsoftJson.Generation; -using Pro.NBench.xUnit.XunitExtensions; -using Counter = NBench.Counter; namespace NJsonSchema.Benchmark { public class SchemaGenerationBenchmarks { - private Counter _counter; - - [PerfSetup] - public void Setup(BenchmarkContext context) - { - _counter = context.GetCounter("Iterations"); - } - - [NBenchFact(Skip = "Can vary a lot when running on GitHub Actions")] - [PerfBenchmark( - NumberOfIterations = 3, - RunTimeMilliseconds = 1000, - RunMode = RunMode.Throughput, - TestMode = TestMode.Test)] - [CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 100)] public void GenerateSchema() { var schema = NewtonsoftJsonSchemaGenerator.FromType(); - _counter.Increment(); } public class SpecialTeacher : Teacher diff --git a/src/NJsonSchema.Benchmark/SerializationBenchmarks.cs b/src/NJsonSchema.Benchmark/SerializationBenchmarks.cs index 345e46bd3..0ba755fc0 100644 --- a/src/NJsonSchema.Benchmark/SerializationBenchmarks.cs +++ b/src/NJsonSchema.Benchmark/SerializationBenchmarks.cs @@ -1,20 +1,13 @@ using System.Reflection; -using NBench; -using Pro.NBench.xUnit.XunitExtensions; -using Counter = NBench.Counter; - -[assembly: CollectionBehavior(DisableTestParallelization = true)] namespace NJsonSchema.Benchmark { public class SerializationBenchmarks { private JsonSchema _schema; - private Counter _counter; private string _json; - [PerfSetup] - public void Setup(BenchmarkContext context) + public void Setup() { var executingAssembly = Assembly.GetExecutingAssembly(); @@ -26,41 +19,22 @@ public void Setup(BenchmarkContext context) } _schema = JsonSchema.FromJsonAsync(_json).Result; - _counter = context.GetCounter("Iterations"); } /// /// Ensure that we can serialise at least 200 times per second (5ms). /// - [NBenchFact] - [PerfBenchmark( - Description = "Ensure serialization doesn't take too long", - NumberOfIterations = 3, - RunTimeMilliseconds = 1000, - RunMode = RunMode.Throughput, - TestMode = TestMode.Test)] - [CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 200)] public void ToJson() { _schema.ToJson(); - _counter.Increment(); } /// /// Ensure that we can deserialise at least 200 times per second (5ms). /// - [NBenchFact] - [PerfBenchmark( - Description = "Ensure deserialization doesn't take too long", - NumberOfIterations = 3, - RunTimeMilliseconds = 1000, - RunMode = RunMode.Throughput, - TestMode = TestMode.Test)] - [CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 200)] public void FromJson() { JsonSchema.FromJsonAsync(_json).GetAwaiter().GetResult(); - _counter.Increment(); } } } diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/AdditionalPropertiesTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/AdditionalPropertiesTests.cs index 13d2f2067..9afb4ecf9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/AdditionalPropertiesTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/AdditionalPropertiesTests.cs @@ -138,7 +138,7 @@ public async Task When_using_SystemTextJson_additionalProperties_schema_is_set_f } [Fact] - public async Task When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class() + public async Task When_using_STJ_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base() { var json = @"{ diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj index 619f2e697..adb9e982a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj @@ -7,6 +7,7 @@ disable latest-Minimal $(NoWarn);1591 + Exe @@ -16,8 +17,8 @@ - - + + diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NullableReferenceTypesTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NullableReferenceTypesTests.cs index 1ed3e9631..27533bbc5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NullableReferenceTypesTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NullableReferenceTypesTests.cs @@ -153,7 +153,7 @@ public async Task When_generating_from_json_schema_property_is_optional_and_Gene [InlineData("date-time")] [InlineData("time")] [InlineData("time-span")] - public async Task When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property(string format) + public async Task When_generating_from_json_schema_string_property_with_date_or_time_format(string format) { // Arrange var schemaJson = @" @@ -201,7 +201,7 @@ public async Task When_generating_from_json_schema_string_property_with_date_or_ [InlineData("date-time")] [InlineData("time")] [InlineData("time-span")] - public async Task When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property(string format) + public async Task When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties(string format) { // Arrange var schemaJson = @" @@ -245,8 +245,7 @@ public async Task When_generating_from_json_schema_string_property_with_date_or_ } [Fact] - public async Task - When_generating_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property() + public async Task When_generating_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set() { // Arrange var schemaJson = @" diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_STJ_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_STJ_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date-time.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=date-time.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date-time.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=date-time.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=date.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=date.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time-span.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=time-span.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time-span.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=time-span.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=time.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_format=time.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt deleted file mode 100644 index f4bf7778b..000000000 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt +++ /dev/null @@ -1,35 +0,0 @@ -//---------------------- -// -// -//---------------------- - - -#nullable enable - - -namespace MyNamespace -{ - #pragma warning disable // Disable all warnings - - public partial class MyClass - { - [Newtonsoft.Json.JsonProperty("required", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] - public string Required { get; set; } = default!; - - [Newtonsoft.Json.JsonProperty("optional", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string? Optional { get; set; } = default!; - - - - private System.Collections.Generic.IDictionary? _additionalProperties; - - [Newtonsoft.Json.JsonExtensionData] - public System.Collections.Generic.IDictionary AdditionalProperties - { - get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary()); } - set { _additionalProperties = value; } - } - - } -} \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date-time.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=date-time.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date-time.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=date-time.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=date.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=date.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time-span.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=time-span.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time-span.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=time-span.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=time.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties_format=time.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt rename to src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj b/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj index ef84624d0..ac59389bc 100644 --- a/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj +++ b/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj @@ -7,13 +7,14 @@ $(NoWarn),1998,1591,618,IDE1006 disable false + Exe - - + + diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/InheritanceTests.cs b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/InheritanceTests.cs index f47bf7230..502f2e7a2 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/InheritanceTests.cs +++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/InheritanceTests.cs @@ -27,7 +27,7 @@ public sealed class EmptyClassInheritingDictionary : Dictionary [InlineData(true, true)] [InlineData(false, false)] [InlineData(true, false)] - public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works(bool inlineNamedDictionaries, bool convertConstructorInterfaceData) + public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works(bool inline, bool convert) { // Arrange var schema = NewtonsoftJsonSchemaGenerator.FromType(); @@ -36,8 +36,8 @@ public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritan var generator = new TypeScriptGenerator(schema, new TypeScriptGeneratorSettings { TypeScriptVersion = 2.0m, - InlineNamedDictionaries = inlineNamedDictionaries, - ConvertConstructorInterfaceData = convertConstructorInterfaceData + InlineNamedDictionaries = inline, + ConvertConstructorInterfaceData = convert }); // Act @@ -49,7 +49,7 @@ public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritan Assert.Empty(dschema.AllOf); Assert.True(dschema.IsDictionary); - await VerifyHelper.Verify(code).UseParameters(inlineNamedDictionaries, convertConstructorInterfaceData); + await VerifyHelper.Verify(code).UseParameters(inline, convert); TypeScriptCompiler.AssertCompile(code); } diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj index cae19c6e7..2e97a5b12 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj +++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj @@ -7,14 +7,15 @@ disable latest-Minimal $(NoWarn);1591 + Exe - - + + diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=False_convertConstructorInterfaceData=False.verified.txt b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=False_convert=False.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=False_convertConstructorInterfaceData=False.verified.txt rename to src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=False_convert=False.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=False_convertConstructorInterfaceData=True.verified.txt b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=False_convert=True.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=False_convertConstructorInterfaceData=True.verified.txt rename to src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=False_convert=True.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=True_convertConstructorInterfaceData=False.verified.txt b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=True_convert=False.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=True_convertConstructorInterfaceData=False.verified.txt rename to src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=True_convert=False.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=True_convertConstructorInterfaceData=True.verified.txt b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=True_convert=True.verified.txt similarity index 100% rename from src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inlineNamedDictionaries=True_convertConstructorInterfaceData=True.verified.txt rename to src/NJsonSchema.CodeGeneration.TypeScript.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works_inline=True_convert=True.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package-lock.json b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package-lock.json index f494a1703..2649dca09 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package-lock.json +++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package-lock.json @@ -5,21 +5,11 @@ "packages": { "": { "devDependencies": { - "@types/moment": "^2.13.0", "dayjs": "^1.11.13", + "moment": "^2.30.1", "typescript": "^5.8.3" } }, - "node_modules/@types/moment": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/@types/moment/-/moment-2.13.0.tgz", - "integrity": "sha512-DyuyYGpV6r+4Z1bUznLi/Y7HpGn4iQ4IVcGn8zrr1P4KotKLdH0sbK1TFR6RGyX6B+G8u83wCzL+bpawKU/hdQ==", - "deprecated": "This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need @types/moment installed!", - "dev": true, - "dependencies": { - "moment": "*" - } - }, "node_modules/dayjs": { "version": "1.11.13", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package.json b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package.json index 94133d5ed..ad6aaebe2 100644 --- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package.json +++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "@types/moment": "^2.13.0", + "moment": "^2.30.1", "dayjs": "^1.11.13", "typescript": "^5.8.3" } diff --git a/src/NJsonSchema.NewtonsoftJson.Tests/NJsonSchema.NewtonsoftJson.Tests.csproj b/src/NJsonSchema.NewtonsoftJson.Tests/NJsonSchema.NewtonsoftJson.Tests.csproj index 869294dc2..4d4609d6e 100644 --- a/src/NJsonSchema.NewtonsoftJson.Tests/NJsonSchema.NewtonsoftJson.Tests.csproj +++ b/src/NJsonSchema.NewtonsoftJson.Tests/NJsonSchema.NewtonsoftJson.Tests.csproj @@ -6,6 +6,7 @@ false disable latest-Minimal + Exe @@ -21,7 +22,7 @@ - + diff --git a/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj b/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj index 4235269d8..3d6adcd7d 100644 --- a/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj +++ b/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj @@ -6,13 +6,11 @@ false disable latest-Minimal - - - bin\Debug\$(TargetFramework)\NJsonSchema.Tests.xml $(NoWarn),618,1587,1998,1591 $(NoWarn),CA1707 + Exe @@ -21,8 +19,8 @@ - - + + diff --git a/src/NJsonSchema.Tests/VerifyChecksTests.cs b/src/NJsonSchema.Tests/VerifyChecksTests.cs new file mode 100644 index 000000000..494b051ab --- /dev/null +++ b/src/NJsonSchema.Tests/VerifyChecksTests.cs @@ -0,0 +1,8 @@ +namespace NJsonSchema.Tests; + +public class VerifyChecksTests +{ + [Fact] + public Task Run() => + VerifyChecks.Run(); +} \ No newline at end of file diff --git a/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj b/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj index 6d77e7cc3..b8c5a2096 100644 --- a/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj +++ b/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj @@ -7,17 +7,15 @@ disable latest-Minimal $(NoWarn);1591 - - - $(NoWarn),CA1707 + Exe - +