From aa37ebe77dd47b417932857640ff6b8e5c09c5f8 Mon Sep 17 00:00:00 2001 From: Manfred Brands Date: Fri, 6 Aug 2021 17:52:42 +0800 Subject: [PATCH 1/5] Allow disabling sorting of constructor parameters. Add options to create C#9 records with optional (init) --- .../CodeCompiler.cs | 4 +- .../GeneralGeneratorTests.cs | 44 +++++++++++++++++++ .../CSharpClassStyle.cs | 5 ++- .../CSharpGeneratorSettings.cs | 3 ++ .../Models/ClassTemplateModel.cs | 14 +++++- .../Templates/Class.Constructor.Record.liquid | 5 +++ 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/CodeCompiler.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/CodeCompiler.cs index 1db1d3901..2b8a1f3b1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/CodeCompiler.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/CodeCompiler.cs @@ -5,9 +5,9 @@ namespace NJsonSchema.CodeGeneration.CSharp.Tests; public class CodeCompiler { - public static void AssertCompile(string source) + public static void AssertCompile(string source, CSharpParseOptions options = null) { - var syntaxTree = CSharpSyntaxTree.ParseText(source); + var syntaxTree = CSharpSyntaxTree.ParseText(source, options); var metadataReferences = AppDomain.CurrentDomain.GetAssemblies() .Where(x => !x.IsDynamic && !string.IsNullOrWhiteSpace(x.Location)) diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs index 9367df001..23a161723 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using Microsoft.CodeAnalysis.CSharp; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NJsonSchema.Annotations; @@ -1695,6 +1696,49 @@ public async Task When_native_record_no_setter_in_class_and_constructor_provided CodeCompiler.AssertCompile(output); } +#if NETCOREAPP3_1_OR_GREATER || NET5_0_OR_GREATER + [Fact] + public async Task When_csharp_record_no_setter_in_record_and_constructor_provided() + { + // Arrange + var schema = JsonSchema.FromType
(); + var data = schema.ToJson(); + var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings + { + ClassStyle = CSharpClassStyle.CSharpRecord, + SortConstructorParameters = false + }); + + // Act + var output = generator.GenerateFile("Address"); + + // Assert + await VerifyHelper.Verify(output); + CodeCompiler.AssertCompile(output, new CSharpParseOptions(LanguageVersion.CSharp9)); + } + + [Fact] + public async Task When_csharp_record_init_in_record_and_constructor_provided() + { + // Arrange + var schema = JsonSchema.FromType
(); + var data = schema.ToJson(); + var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings + { + ClassStyle = CSharpClassStyle.CSharpRecord, + SortConstructorParameters = false, + GenerateInitProperties = true, + }); + + // Act + var output = generator.GenerateFile("Address"); + + // Assert + await VerifyHelper.Verify(output); + CodeCompiler.AssertCompile(output, new CSharpParseOptions(LanguageVersion.CSharp9)); + } +#endif + public abstract class AbstractAddress { [JsonProperty("city")] diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs index eb948eda5..e9fe173a8 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs @@ -23,6 +23,9 @@ public enum CSharpClassStyle Prism, /// Generates Records - read only POCOs (Plain Old C# Objects). - Record + Record, + + /// Generates C# Records. + CSharpRecord } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs index 40cfd9389..0a03e71e6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs @@ -56,6 +56,7 @@ public CSharpGeneratorSettings() InlineNamedArrays = false; InlineNamedDictionaries = false; InlineNamedTuples = true; + SortConstructorParameters = true; } /// Gets or sets the .NET namespace of the generated types (default: MyNamespace). @@ -175,5 +176,7 @@ public CSharpGeneratorSettings() /// public string FieldNamePrefix { get; set; } = "_"; + /// Gets a value indicating whether the constructor parameters should be sorted alphabetically (default: true). + public bool SortConstructorParameters { get; set; } } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs index f1d8ae822..7116abb64 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs @@ -119,7 +119,12 @@ public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, public bool RenderPrism => _settings.ClassStyle == CSharpClassStyle.Prism; /// Gets a value indicating whether the class style is Record. - public bool RenderRecord => _settings.ClassStyle == CSharpClassStyle.Record; + public bool RenderRecord => _settings.ClassStyle == CSharpClassStyle.Record || + _settings.ClassStyle == CSharpClassStyle.CSharpRecord; + + /// Gets the class type. + public string ClassType => _settings.ClassStyle == CSharpClassStyle.CSharpRecord ? + "record" : "class"; /// Gets a value indicating whether to generate records as C# 9.0 records. public bool GenerateNativeRecords => _settings.GenerateNativeRecords; @@ -144,6 +149,13 @@ public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, /// Gets a value indicating whether the class has a parent class. public bool HasInheritance => _schema.InheritedTypeSchema != null; + /// Gets a value indicating whether the constructor parameters should be sorted. + public bool SortConstructorParameters => _settings.SortConstructorParameters; + + /// Gets a value indicating whether the properties should have an 'init' part. (default: false). + public bool GenerateInitProperties => _settings.ClassStyle == CSharpClassStyle.CSharpRecord && + _settings.GenerateInitProperties; + /// Gets the base class name. public string? BaseClassName => HasInheritance ? _resolver.Resolve(_schema.InheritedTypeSchema!, false, string.Empty, false) .Replace(_settings.ArrayType + "<", _settings.ArrayBaseType + "<") diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid index f88b7e1b9..eb9b39ada 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid +++ b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid @@ -5,8 +5,13 @@ {%- assign parentProperties = "" | empty %} {% endif %} +{% if SortConstructorParameters %} {%- assign sortedProperties = AllProperties | sort: "Name" %} {%- assign sortedParentProperties = parentProperties | sort: "Name" %} +{% else %} +{%- assign sortedProperties = AllProperties -%} +{%- assign sortedParentProperties = parentProperties -%} +{% endif %} {%- if UseSystemTextJson %} [System.Text.Json.Serialization.JsonConstructor] From 56798e2226d99e0bca2e284d2ce581fab30ca253 Mon Sep 17 00:00:00 2001 From: Manfred Brands Date: Sun, 8 Aug 2021 08:50:45 +0800 Subject: [PATCH 2/5] Base class parameters should come before derived class parameters --- .../GeneralGeneratorTests.cs | 7 +++--- .../InheritanceTests.cs | 24 +++++++++++++++++++ .../References/Car.json | 16 +++++++++++++ .../References/Vehicle.json | 12 ++++++++++ .../Models/ClassTemplateModel.cs | 6 +---- 5 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Car.json create mode 100644 src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Vehicle.json diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs index 23a161723..d81cb01ee 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs @@ -2,7 +2,6 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using Microsoft.CodeAnalysis.CSharp; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using NJsonSchema.Annotations; @@ -1714,7 +1713,7 @@ public async Task When_csharp_record_no_setter_in_record_and_constructor_provide // Assert await VerifyHelper.Verify(output); - CodeCompiler.AssertCompile(output, new CSharpParseOptions(LanguageVersion.CSharp9)); + CodeCompiler.AssertCompile(output, new Microsoft.CodeAnalysis.CSharp.CSharpParseOptions(Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp9)); } [Fact] @@ -1727,7 +1726,7 @@ public async Task When_csharp_record_init_in_record_and_constructor_provided() { ClassStyle = CSharpClassStyle.CSharpRecord, SortConstructorParameters = false, - GenerateInitProperties = true, + GenerateNativeRecords = true, }); // Act @@ -1735,7 +1734,7 @@ public async Task When_csharp_record_init_in_record_and_constructor_provided() // Assert await VerifyHelper.Verify(output); - CodeCompiler.AssertCompile(output, new CSharpParseOptions(LanguageVersion.CSharp9)); + CodeCompiler.AssertCompile(output, new Microsoft.CodeAnalysis.CSharp.CSharpParseOptions(Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp9)); } #endif diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs index 659f57eec..84d033df7 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs @@ -173,6 +173,30 @@ public async Task When_definitions_inherit_from_root_schema_and_STJ_polymorphism CodeCompiler.AssertCompile(code); } + [Fact] + public async Task When_definition_inherits_parameters_from_base_come_first() + { + //// Arrange + var path = GetTestDirectory() + "/References/Car.json"; + + //// Act + var schema = await JsonSchema.FromFileAsync(path); + var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings + { + ClassStyle = CSharpClassStyle.Record, + SortConstructorParameters = false, + }); + + //// Act + var code = generator.GenerateFile(); + + //// Assert + Assert.Contains("public partial class Car : Vehicle", code); + Assert.Contains("Vehicle(string @id)", code); + Assert.Contains("Car(string @id, int @wheels)", code); + Assert.Contains("base(id)", code); + } + private string GetTestDirectory() { #pragma warning disable SYSLIB0012 diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Car.json b/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Car.json new file mode 100644 index 000000000..a06b9e8a4 --- /dev/null +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Car.json @@ -0,0 +1,16 @@ +{ + "title": "Car", + "type": "object", + "description": "This is a car", + "allOf": [ + { + "$ref": "Vehicle.json" + } + ], + "properties": { + "wheels": { + "type": "integer", + "description": "The number of wheels on the car" + } + } +} diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Vehicle.json b/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Vehicle.json new file mode 100644 index 000000000..2ad6ef0f8 --- /dev/null +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/References/Vehicle.json @@ -0,0 +1,12 @@ +{ + "title": "Vehicle", + "type": "object", + "x-abstract": true, + "description": "This is a vehicle", + "properties": { + "id": { + "type": "string", + "description": "This is the ID of Vehicle" + } + } +} diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs index 7116abb64..f291a16ae 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs @@ -50,8 +50,8 @@ public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, { BaseClass = new ClassTemplateModel(BaseClassName!, settings, resolver, schema.InheritedSchema, rootObject); _allProperties = new List(_properties.Count + BaseClass._allProperties.Count); - _allProperties.AddRange(_properties); _allProperties.AddRange(BaseClass._allProperties); + _allProperties.AddRange(_properties); } else { @@ -152,10 +152,6 @@ public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, /// Gets a value indicating whether the constructor parameters should be sorted. public bool SortConstructorParameters => _settings.SortConstructorParameters; - /// Gets a value indicating whether the properties should have an 'init' part. (default: false). - public bool GenerateInitProperties => _settings.ClassStyle == CSharpClassStyle.CSharpRecord && - _settings.GenerateInitProperties; - /// Gets the base class name. public string? BaseClassName => HasInheritance ? _resolver.Resolve(_schema.InheritedTypeSchema!, false, string.Empty, false) .Replace(_settings.ArrayType + "<", _settings.ArrayBaseType + "<") From 0b434df15ce9ef67d5edcb94aedcbff8d2772b27 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 27 Jul 2025 11:11:47 +0300 Subject: [PATCH 3/5] Remove unnecessary CSharpClassStyle.CSharpRecord --- .../GeneralGeneratorTests.cs | 5 +++-- src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs | 3 --- .../Models/ClassTemplateModel.cs | 6 ++---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs index d81cb01ee..df3b862ad 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/GeneralGeneratorTests.cs @@ -1704,7 +1704,8 @@ public async Task When_csharp_record_no_setter_in_record_and_constructor_provide var data = schema.ToJson(); var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings { - ClassStyle = CSharpClassStyle.CSharpRecord, + ClassStyle = CSharpClassStyle.Record, + GenerateNativeRecords = true, SortConstructorParameters = false }); @@ -1724,7 +1725,7 @@ public async Task When_csharp_record_init_in_record_and_constructor_provided() var data = schema.ToJson(); var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings { - ClassStyle = CSharpClassStyle.CSharpRecord, + ClassStyle = CSharpClassStyle.Record, SortConstructorParameters = false, GenerateNativeRecords = true, }); diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs index e9fe173a8..d17972f25 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpClassStyle.cs @@ -24,8 +24,5 @@ public enum CSharpClassStyle /// Generates Records - read only POCOs (Plain Old C# Objects). Record, - - /// Generates C# Records. - CSharpRecord } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs index f291a16ae..26248061e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp/Models/ClassTemplateModel.cs @@ -119,12 +119,10 @@ public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings, public bool RenderPrism => _settings.ClassStyle == CSharpClassStyle.Prism; /// Gets a value indicating whether the class style is Record. - public bool RenderRecord => _settings.ClassStyle == CSharpClassStyle.Record || - _settings.ClassStyle == CSharpClassStyle.CSharpRecord; + public bool RenderRecord => _settings.ClassStyle == CSharpClassStyle.Record; /// Gets the class type. - public string ClassType => _settings.ClassStyle == CSharpClassStyle.CSharpRecord ? - "record" : "class"; + public string ClassType => _settings.GenerateNativeRecords ? "record" : "class"; /// Gets a value indicating whether to generate records as C# 9.0 records. public bool GenerateNativeRecords => _settings.GenerateNativeRecords; From d4811e1c9ae4f85ce39103c490de980614543da3 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 27 Jul 2025 12:03:31 +0300 Subject: [PATCH 4/5] tweak templates and update snapshots --- ...t_CSharp_keyword_is_generated.verified.txt | 2 +- ...age_has_additional_properties.verified.txt | 4 +-- ...ry_and_no_object_are_not_same.verified.txt | 3 +- ..._special_property_is_rendered.verified.txt | 6 ++-- ..._special_property_is_rendered.verified.txt | 5 --- ..._rendered_only_for_base_class.verified.txt | 6 ---- ...ed_only_for_lowest_base_class.verified.txt | 6 ---- ...e_schema_then_it_is_inherited.verified.txt | 5 ++- ...eferenced_schema_is_inherited.verified.txt | 5 ++- ..._anonymous_class_is_generated.verified.txt | 5 ++- ...rited_class_in_generated_code.verified.txt | 5 ++- ...should_expand_to_single_class.verified.txt | 13 +++---- ..._properties_in_generated_code.verified.txt | 5 ++- ...hen_it_does_not_have_a_setter.verified.txt | 2 +- ...n_generated_CSharp_is_correct.verified.txt | 2 +- ...array_instance_can_be_changed.verified.txt | 2 +- ...generates_expected_expression.verified.txt | 3 +- ...generates_expected_expression.verified.txt | 3 +- ...generates_expected_expression.verified.txt | 3 +- ...generates_expected_expression.verified.txt | 3 +- ...efault_value_is_not_generated.verified.txt | 3 +- ...t_it_is_reflected_in_the_poco.verified.txt | 3 +- ...t_it_is_reflected_in_the_poco.verified.txt | 3 +- ...enum_then_csharp_has_enum_key.verified.txt | 2 +- ...onary_instance_can_be_changed.verified.txt | 2 +- ...pe_name_hint_is_property_name.verified.txt | 6 ++-- ...y_then_enum_name_is_preserved.verified.txt | 2 +- ..._convert_to_string_equivalent.verified.txt | 3 +- ...nerated_with_correct_basetype.verified.txt | 3 +- ...o_type_then_enum_is_generated.verified.txt | 3 +- ..._enum_is_generated_with_flags.verified.txt | 3 +- ...it_should_use_declared_values.verified.txt | 3 +- ...then_question_mark_is_omitted.verified.txt | 3 +- ...ld_be_nullable_with_converter.verified.txt | 3 +- ...ld_be_nullable_with_converter.verified.txt | 3 +- ...en_StringEnumConverter_is_set.verified.txt | 2 +- ...then_ItemConverterType_is_set.verified.txt | 2 +- ..._word_converted_to_upper_case.verified.txt | 3 +- ..._Swagger2_then_it_is_nullable.verified.txt | 3 +- ..._convert_to_string_equivalent.verified.txt | 3 +- ...erics_then_they_are_converted.verified.txt | 6 ++-- ...g_property_with_base64_format.verified.txt | 2 +- ...ing_property_with_byte_format.verified.txt | 2 +- ...auto_properties_are_generated.verified.txt | 6 ++-- ...harp_inheritance_is_generated.verified.txt | 6 ++-- ..._code_has_correct_initializer.verified.txt | 3 +- ...n_then_csharp_has_xml_comment.verified.txt | 6 ++-- ...uctor_is_protected_for_record.verified.txt | 9 ++--- ..._toolchain_version_is_printed.verified.txt | 3 +- ...cord_and_constructor_provided.verified.txt | 27 ++++++++++++++ ...cord_and_constructor_provided.verified.txt | 27 ++++++++++++++ ...ing_length_attribute_is_added.verified.txt | 3 +- ...are_added_only_for_type_array.verified.txt | 3 +- ...is_added_only_for_type_string.verified.txt | 3 +- ...um_a_range_attribute_is_added.verified.txt | 3 +- ..._should_be_added_for_datetime.verified.txt | 2 -- ...d_be_added_for_datetimeoffset.verified.txt | 2 -- ..._should_be_added_for_datetime.verified.txt | 3 +- ...d_be_added_for_datetimeoffset.verified.txt | 3 +- ...converter_should_not_be_added.verified.txt | 2 -- ...converter_should_not_be_added.verified.txt | 3 +- ...ing_length_attribute_is_added.verified.txt | 3 +- ...in_double_minimum_and_maximum.verified.txt | 3 +- ...ng_but_type_number_or_integer.verified.txt | 3 +- ...ing_length_attribute_is_added.verified.txt | 3 +- ...inimum_and_max_double_maximum.verified.txt | 3 +- ...expression_attribute_is_added.verified.txt | 3 +- ...xpression_should_not_be_added.verified.txt | 3 +- ...e_they_should_not_be_included.verified.txt | 3 +- ...ect_then_JObject_is_generated.verified.txt | 3 +- ..._code_has_correct_initializer.verified.txt | 3 +- ...alid_xml_documentation_syntax.verified.txt | 2 +- ...n_then_csharp_has_xml_comment.verified.txt | 6 ++-- ...correct_csharp_code_generated.verified.txt | 2 +- ...correct_csharp_code_generated.verified.txt | 2 +- ..._value_is_still_correctly_set.verified.txt | 2 +- ...it_is_converted_to_upper_case.verified.txt | 3 +- ...harp_jsonPropertyName=FooBar3.verified.txt | 3 +- ...harp_jsonPropertyName=FooBar4.verified.txt | 3 +- ...p_jsonPropertyName=FooStarbar.verified.txt | 3 +- ...harp_jsonPropertyName=Foo_bar.verified.txt | 3 +- ...harp_jsonPropertyName=Foobar1.verified.txt | 3 +- ...harp_jsonPropertyName=Foobar2.verified.txt | 3 +- ...harp_jsonPropertyName=Foobars.verified.txt | 3 +- ...p_jsonPropertyName=Fooplusbar.verified.txt | 3 +- ...en_it_should_appear_in_output.verified.txt | 6 ++-- ...lass_and_constructor_provided.verified.txt | 9 ++--- ...n_title_is_used_as_class_name.verified.txt | 6 ++-- ...able_in_generated_csharp_code.verified.txt | 2 +- ...c_name_then_it_is_transformed.verified.txt | 3 +- ..._code_has_correct_initializer.verified.txt | 9 ++--- ...rrect_dictionary_is_generated.verified.txt | 3 +- ...n_then_csharp_has_xml_comment.verified.txt | 6 ++-- ...racters_then_they_are_removed.verified.txt | 3 +- ...e_as_class_then_it_is_renamed.verified.txt | 3 +- ...ated_code_uses_the_same_class.verified.txt | 2 +- ...te_then_its_type_is_preserved.verified.txt | 2 +- ..._object_property_is_generated.verified.txt | 2 +- ...d_then_CSharp_code_is_correct.verified.txt | 2 +- ..._than_csharp_timespan_is_used.verified.txt | 4 +-- ...ame_then_attribute_is_correct.verified.txt | 6 ++-- ...fun_then_attribute_is_correct.verified.txt | 6 ++-- ...er_name_is_correct_for_record.verified.txt | 9 ++--- ...s.When_record_has_inheritance.verified.txt | 28 ++++----------- ...lass_and_constructor_provided.verified.txt | 9 ++--- ...ntain_correct_target_ref_type.verified.txt | 6 ++-- ...ionDataAttribute_is_generated.verified.txt | 3 +- ...ectly_inlineNamedTuples=False.verified.txt | 3 +- ...rectly_inlineNamedTuples=True.verified.txt | 2 +- ...d_then_any_array_is_generated.verified.txt | 3 +- ...FromJson_and_ToJson_correctly.verified.txt | 9 ++--- ...FromJson_and_ToJson_correctly.verified.txt | 9 ++--- ...FromJson_and_ToJson_correctly.verified.txt | 17 --------- ...FromJson_and_ToJson_correctly.verified.txt | 17 --------- ...is_referenced_with_Newtonsoft.verified.txt | 6 ++-- ...hen_it_is_referenced_with_STJ.verified.txt | 3 -- ..._attributes_are_not_generated.verified.txt | 3 -- ...csharp_is_generated_correctly.verified.txt | 8 ++--- ...ions_inherit_from_root_schema.verified.txt | 16 ++------- ...t_schema_and_STJ_polymorphism.verified.txt | 16 ++------- ...allOf_inheritance_still_works.verified.txt | 2 +- ...then_property_type_is_correct.verified.txt | 6 ++-- ...erties_are_included_in_schema.verified.txt | 2 +- ...erties_are_included_in_schema.verified.txt | 2 +- ..._required_then_it_is_nullable.verified.txt | 3 +- ..._not_set_then_CSharp_property.verified.txt | 3 +- ...s_is_set_then_CSharp_property.verified.txt | 3 +- ...arp_property_format=date-time.verified.txt | 3 +- ...n_CSharp_property_format=date.verified.txt | 3 +- ...arp_property_format=time-span.verified.txt | 3 +- ...n_CSharp_property_format=time.verified.txt | 3 +- ...arp_property_format=date-time.verified.txt | 3 +- ...n_CSharp_property_format=date.verified.txt | 3 +- ...arp_property_format=time-span.verified.txt | 3 +- ...n_CSharp_property_format=time.verified.txt | 3 +- ...s_is_set_then_CSharp_property.verified.txt | 3 +- ...n_CSharp_property_is_nullable.verified.txt | 2 +- ...harp_property_is_not_nullable.verified.txt | 2 +- ...harp_property_is_not_nullable.verified.txt | 2 +- ...n_CSharp_property_is_nullable.verified.txt | 2 +- ...hen_setting_type_is_generated.verified.txt | 3 +- ...hen_setting_type_is_generated.verified.txt | 3 +- ...hen_setting_type_is_generated.verified.txt | 3 +- ...mat_then_decimal_is_generated.verified.txt | 3 +- ...rmat_then_double_is_generated.verified.txt | 3 +- ...ormat_then_float_is_generated.verified.txt | 3 +- ...mat_then_default_is_generated.verified.txt | 3 +- ...hen_setting_type_is_generated.verified.txt | 3 +- ...null_then_double_is_generated.verified.txt | 3 +- ...pace_then_double_is_generated.verified.txt | 3 +- ...red_attribute_is_not_rendered.verified.txt | 2 +- ..._not_rendered_in_Swagger_mode.verified.txt | 2 +- ...equired_attribute_is_rendered.verified.txt | 2 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 2 +- ...bsolete_attribute_is_rendered.verified.txt | 2 +- ...te_with_a_message_is_rendered.verified.txt | 2 +- ...bsolete_attribute_is_rendered.verified.txt | 2 +- ...te_with_a_message_is_rendered.verified.txt | 2 +- ...ed_with_date_format_attribute.verified.txt | 4 +-- ...ies_property_is_not_generated.verified.txt | 4 +-- ...tions_no_types_are_duplicated.verified.txt | 7 ++-- ...ted_property_is_also_nullable.verified.txt | 3 +- ..._file_no_types_are_duplicated.verified.txt | 7 ++-- ...red_attribute_is_not_rendered.verified.txt | 2 +- ..._not_rendered_in_Swagger_mode.verified.txt | 2 +- ...equired_attribute_is_rendered.verified.txt | 2 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 2 +- ...hen_csharp_output_is_also_uri.verified.txt | 2 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ..._too_large_or_small_for_int64.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...n_range_attribute_is_rendered.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_is_rendered_in_Swagger_mode.verified.txt | 3 +- ...e_then_default_value_is_int32.verified.txt | 3 +- ...ime_then_assign_default_value.verified.txt | 3 +- ...=integer_propertyFormat=int32.verified.txt | 3 +- ...=integer_propertyFormat=int64.verified.txt | 3 +- ...integer_propertyFormat=uint64.verified.txt | 3 +- ...number_propertyFormat=decimal.verified.txt | 3 +- ...=number_propertyFormat=double.verified.txt | 3 +- ...e=number_propertyFormat=float.verified.txt | 3 +- ...n_code_is_correctly_generated.verified.txt | 2 +- .../Templates/Class.Constructor.Record.liquid | 36 +++++++++---------- .../Templates/Class.liquid | 21 +++++------ 193 files changed, 318 insertions(+), 526 deletions(-) create mode 100644 src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_init_in_record_and_constructor_provided.verified.txt create mode 100644 src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_no_setter_in_record_and_constructor_provided.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AbstractSchemaTests.When_class_is_abstract_then_is_abstract_CSharp_keyword_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AbstractSchemaTests.When_class_is_abstract_then_is_abstract_CSharp_keyword_is_generated.verified.txt index 95f66bdfa..00b624944 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AbstractSchemaTests.When_class_is_abstract_then_is_abstract_CSharp_keyword_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AbstractSchemaTests.When_class_is_abstract_then_is_abstract_CSharp_keyword_is_generated.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public abstract partial class AbstractClass { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_any_page_has_additional_properties.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_any_page_has_additional_properties.verified.txt index 9188525c5..825702455 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_any_page_has_additional_properties.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_any_page_has_additional_properties.verified.txt @@ -11,7 +11,6 @@ namespace ns public partial class Page { - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -25,14 +24,13 @@ namespace ns public partial class Library { + [Newtonsoft.Json.JsonProperty("Index", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Index { get; set; } [Newtonsoft.Json.JsonProperty("Page", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Page Page { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_dictionary_and_no_object_are_not_same.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_dictionary_and_no_object_are_not_same.verified.txt index 666d19428..2137608ab 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_dictionary_and_no_object_are_not_same.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_AlwaysAllowAdditionalObjectProperties_is_set_then_dictionary_and_no_object_are_not_same.verified.txt @@ -10,14 +10,13 @@ namespace ns public partial class Library { + [Newtonsoft.Json.JsonProperty("Index", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Index { get; set; } [Newtonsoft.Json.JsonProperty("Page", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Page { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt index 5e0b89970..26a954e7d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("Pet", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Pet Pet { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,14 +27,13 @@ namespace MyNamespace public partial class Pet { + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public long Id { get; set; } [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt index 44e01da15..000e19ed5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered.verified.txt @@ -14,8 +14,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Pet")] public Pet Pet { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] @@ -33,12 +31,9 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("id")] public long Id { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("category")] public string Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] 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_base_class.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_base_class.verified.txt index 7c83f3c6d..20e6660d4 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_base_class.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AdditionalPropertiesTests.When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_base_class.verified.txt @@ -14,12 +14,9 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("dog")] public Dog Dog { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("cat")] public Cat Cat { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] @@ -50,12 +47,9 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("id")] public long Id { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("category")] public string Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] 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_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class.verified.txt index 58d983672..5e5753a58 100644 --- 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_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class.verified.txt @@ -14,7 +14,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("whiskers")] public string Whiskers { get; set; } - } public partial class Pet : Animal @@ -23,7 +22,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("id")] public long Id { get; set; } - } public partial class Animal @@ -32,8 +30,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("category")] public string Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] @@ -51,8 +47,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Name")] public string Name { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_one_schema_then_it_is_inherited.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_one_schema_then_it_is_inherited.verified.txt index 15d4e0479..9c9121c89 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_one_schema_then_it_is_inherited.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_one_schema_then_it_is_inherited.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class B { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -29,6 +28,7 @@ namespace MyNamespace [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "type")] public partial class A : B { + [Newtonsoft.Json.JsonProperty("prop", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.StringLength(30, MinimumLength = 1)] @@ -37,7 +37,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("prop2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop2 { get; set; } - } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple = true)] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_two_schemas_then_referenced_schema_is_inherited.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_two_schemas_then_referenced_schema_is_inherited.verified.txt index 2c7b93557..e8b1851f5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_two_schemas_then_referenced_schema_is_inherited.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_has_two_schemas_then_referenced_schema_is_inherited.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class B { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,6 +27,7 @@ namespace MyNamespace public partial class A : B { + [Newtonsoft.Json.JsonProperty("prop", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.StringLength(30, MinimumLength = 1)] @@ -36,6 +36,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("prop2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_contains_two_anonymous_nodes_without_type_specifier_an_anonymous_class_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_contains_two_anonymous_nodes_without_type_specifier_an_anonymous_class_is_generated.verified.txt index a29044d30..33a95e51a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_contains_two_anonymous_nodes_without_type_specifier_an_anonymous_class_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_contains_two_anonymous_nodes_without_type_specifier_an_anonymous_class_is_generated.verified.txt @@ -10,19 +10,18 @@ namespace MyNamespace public partial class Foo : Anonymous { + [Newtonsoft.Json.JsonProperty("prop2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Prop2 { get; set; } - } public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("prop1", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_is_object_type_then_it_is_an_inherited_class_in_generated_code.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_is_object_type_then_it_is_an_inherited_class_in_generated_code.verified.txt index 7bb6bf33c..2fc52bb26 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_is_object_type_then_it_is_an_inherited_class_in_generated_code.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_allOf_schema_is_object_type_then_it_is_an_inherited_class_in_generated_code.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Bar { + [Newtonsoft.Json.JsonProperty("prop2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop2 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,9 +27,9 @@ namespace MyNamespace public partial class Foo : Bar { + [Newtonsoft.Json.JsonProperty("prop1", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop1 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_all_of_has_multiple_refs_then_the_properties_should_expand_to_single_class.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_all_of_has_multiple_refs_then_the_properties_should_expand_to_single_class.verified.txt index 004a03c0d..e26fe1bb6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_all_of_has_multiple_refs_then_the_properties_should_expand_to_single_class.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_all_of_has_multiple_refs_then_the_properties_should_expand_to_single_class.verified.txt @@ -10,11 +10,10 @@ namespace ns public partial class TRef1 { + [Newtonsoft.Json.JsonProperty("val1", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Val1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,11 +27,10 @@ namespace ns public partial class TRef2 { + [Newtonsoft.Json.JsonProperty("val2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Val2 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -46,11 +44,10 @@ namespace ns public partial class TRef3 { + [Newtonsoft.Json.JsonProperty("val3", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Val3 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -64,20 +61,20 @@ namespace ns public partial class Foo { + [Newtonsoft.Json.JsonProperty("tAgg", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public TAgg TAgg { get; set; } - } public partial class TAgg : TRef1 { + [Newtonsoft.Json.JsonProperty("val2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Val2 { get; set; } [Newtonsoft.Json.JsonProperty("val3", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Val3 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_more_properties_are_defined_in_allOf_and_type_none_then_all_of_contains_all_properties_in_generated_code.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_more_properties_are_defined_in_allOf_and_type_none_then_all_of_contains_all_properties_in_generated_code.verified.txt index 0dd9b57d6..889e21056 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_more_properties_are_defined_in_allOf_and_type_none_then_all_of_contains_all_properties_in_generated_code.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AllOfTests.When_more_properties_are_defined_in_allOf_and_type_none_then_all_of_contains_all_properties_in_generated_code.verified.txt @@ -10,22 +10,21 @@ namespace MyNamespace public partial class Foo : Anonymous { + [Newtonsoft.Json.JsonProperty("prop1", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop1 { get; set; } [Newtonsoft.Json.JsonProperty("prop2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Prop2 { get; set; } - } public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("baseProperty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string BaseProperty { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AnnotationsTests.When_array_property_is_not_nullable_then_it_does_not_have_a_setter.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AnnotationsTests.When_array_property_is_not_nullable_then_it_does_not_have_a_setter.verified.txt index 6c7e1376c..2e446d7e2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AnnotationsTests.When_array_property_is_not_nullable_then_it_does_not_have_a_setter.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/AnnotationsTests.When_array_property_is_not_nullable_then_it_does_not_have_a_setter.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyRequiredTest { + [Newtonsoft.Json.JsonProperty("Name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Name { get; set; } @@ -21,6 +22,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.IDictionary Dictionary { get; } = new System.Collections.Generic.Dictionary(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_item_is_nullable_then_generated_CSharp_is_correct.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_item_is_nullable_then_generated_CSharp_is_correct.verified.txt index 53ae93fb1..11f4fccf2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_item_is_nullable_then_generated_CSharp_is_correct.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_item_is_nullable_then_generated_CSharp_is_correct.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Items", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection Items { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_property_is_required_then_array_instance_can_be_changed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_property_is_required_then_array_instance_can_be_changed.verified.txt index 2f36d974e..bc9ed0f99 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_property_is_required_then_array_instance_can_be_changed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ArrayTests.When_array_property_is_required_then_array_instance_can_be_changed.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("ArrayProperty", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public Foo ArrayProperty { get; set; } = new Bar(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_generates_expected_expression.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_generates_expected_expression.verified.txt index e7f580ada..3f7269159 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_generates_expected_expression.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_generates_expected_expression.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("someOptionalProperty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double SomeOptionalProperty { get; set; } = 123D; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_array_of_arrays_generates_expected_expression.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_array_of_arrays_generates_expected_expression.verified.txt index 77886d84b..6d0d0eef0 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_array_of_arrays_generates_expected_expression.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_array_of_arrays_generates_expected_expression.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("requiredList", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.ICollection> RequiredList { get; set; } = new System.Collections.ObjectModel.Collection>(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_dictionary_with_array_values_generates_expected_expression.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_dictionary_with_array_values_generates_expected_expression.verified.txt index 0aeb3763c..d4b0e5cfd 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_dictionary_with_array_values_generates_expected_expression.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_of_dictionary_with_array_values_generates_expected_expression.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("requiredDictionary", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.IDictionary> RequiredDictionary { get; set; } = new System.Collections.Generic.Dictionary>(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_with_decimal_generates_expected_expression.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_with_decimal_generates_expected_expression.verified.txt index a3a20e1c8..43f4a16ec 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_with_decimal_generates_expected_expression.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_generating_CSharp_code_then_default_value_with_decimal_generates_expected_expression.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("someOptionalProperty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double SomeOptionalProperty { get; set; } = 123.456D; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_and_default_value_generation_is_disabled_then_default_value_is_not_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_and_default_value_generation_is_disabled_then_default_value_is_not_generated.verified.txt index d10ddbdab..7f7fb274f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_and_default_value_generation_is_disabled_then_default_value_is_not_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_and_default_value_generation_is_disabled_then_default_value_is_not_generated.verified.txt @@ -10,11 +10,10 @@ namespace ns public partial class MyClass { + [Newtonsoft.Json.JsonProperty("boolWithDefault", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public bool BoolWithDefault { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_it_is_reflected_in_the_poco.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_it_is_reflected_in_the_poco.verified.txt index 1b090a90b..106b9cf0a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_it_is_reflected_in_the_poco.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_boolean_default_it_is_reflected_in_the_poco.verified.txt @@ -10,11 +10,10 @@ namespace ns public partial class MyClass { + [Newtonsoft.Json.JsonProperty("boolWithDefault", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public bool BoolWithDefault { get; set; } = false; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_interger_default_it_is_reflected_in_the_poco.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_interger_default_it_is_reflected_in_the_poco.verified.txt index 2a8243c88..44f19396a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_interger_default_it_is_reflected_in_the_poco.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DefaultPropertyTests.When_property_has_interger_default_it_is_reflected_in_the_poco.verified.txt @@ -10,11 +10,10 @@ namespace ns public partial class MyClass { + [Newtonsoft.Json.JsonProperty("intergerWithDefault", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int IntergerWithDefault { get; set; } = 5; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_key_is_enum_then_csharp_has_enum_key.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_key_is_enum_then_csharp_has_enum_key.verified.txt index bb660fc8a..98c5f1a43 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_key_is_enum_then_csharp_has_enum_key.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_key_is_enum_then_csharp_has_enum_key.verified.txt @@ -21,6 +21,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("EnumDictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary EnumDictionary { get; set; } @@ -28,6 +29,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.IDictionary EnumInterfaceDictionary { get; set; } = new System.Collections.Generic.Dictionary(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_property_is_required_then_dictionary_instance_can_be_changed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_property_is_required_then_dictionary_instance_can_be_changed.verified.txt index d4e01bacd..d437d46d1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_property_is_required_then_dictionary_instance_can_be_changed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/DictionaryTests.When_dictionary_property_is_required_then_dictionary_instance_can_be_changed.verified.txt @@ -21,6 +21,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("EnumDictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Foo EnumDictionary { get; set; } @@ -28,6 +29,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public Foo EnumInterfaceDictionary { get; set; } = new Bar(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_array_item_enum_is_not_referenced_then_type_name_hint_is_property_name.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_array_item_enum_is_not_referenced_then_type_name_hint_is_property_name.verified.txt index 10a17051b..422bab3ac 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_array_item_enum_is_not_referenced_then_type_name_hint_is_property_name.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_array_item_enum_is_not_referenced_then_type_name_hint_is_property_name.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class NewOrderModel { + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int Id { get; set; } @@ -19,8 +20,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.ICollection Status { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -34,11 +33,10 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public NewOrderModel Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_class_has_enum_array_property_then_enum_name_is_preserved.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_class_has_enum_array_property_then_enum_name_is_preserved.verified.txt index d85caaaaf..f4ba486b1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_class_has_enum_array_property_then_enum_name_is_preserved.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_class_has_enum_array_property_then_enum_name_is_preserved.verified.txt @@ -21,12 +21,12 @@ namespace MyNamespace public partial class SomeClass { + [Newtonsoft.Json.JsonProperty("SomeProperty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int SomeProperty { get; set; } [Newtonsoft.Json.JsonProperty("SomeEnums", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection SomeEnums { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_contains_operator_convert_to_string_equivalent.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_contains_operator_convert_to_string_equivalent.verified.txt index 3c598780f..bdef5efb4 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_contains_operator_convert_to_string_equivalent.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_contains_operator_convert_to_string_equivalent.verified.txt @@ -62,12 +62,11 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public OperatorTestEnum? Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_a_format_then_enum_is_generated_with_correct_basetype.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_a_format_then_enum_is_generated_with_correct_basetype.verified.txt index 7ed919fca..8ff4ef62c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_a_format_then_enum_is_generated_with_correct_basetype.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_a_format_then_enum_is_generated_with_correct_basetype.verified.txt @@ -21,11 +21,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public ManyValuesTestEnum Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated.verified.txt index 0afadaacc..a17bd6b19 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public MyClassCategory Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated_with_flags.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated_with_flags.verified.txt index 98868ea95..e59ae5060 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated_with_flags.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_has_no_type_then_enum_is_generated_with_flags.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public MyClassCategory Category { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_integer_flags_it_should_use_declared_values.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_integer_flags_it_should_use_declared_values.verified.txt index baef5d3e7..dd437aebf 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_integer_flags_it_should_use_declared_values.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_integer_flags_it_should_use_declared_values.verified.txt @@ -34,11 +34,10 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public FlagsTestEnum Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_and_has_default_then_question_mark_is_omitted.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_and_has_default_then_question_mark_is_omitted.verified.txt index c2c806218..44a59074c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_and_has_default_then_question_mark_is_omitted.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_and_has_default_then_question_mark_is_omitted.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public MyClassCategory? Category { get; set; } = MyNamespace.MyClassCategory.Commercial; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_not_required_it_should_be_nullable_with_converter.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_not_required_it_should_be_nullable_with_converter.verified.txt index 67af2f94b..b7d3bf8b2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_not_required_it_should_be_nullable_with_converter.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_not_required_it_should_be_nullable_with_converter.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("myProperty", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public FooMyProperty? MyProperty { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_required_it_should_be_nullable_with_converter.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_required_it_should_be_nullable_with_converter.verified.txt index caecf8702..0b38fb856 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_required_it_should_be_nullable_with_converter.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_required_it_should_be_nullable_with_converter.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("myProperty", Required = Newtonsoft.Json.Required.AllowNull)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public FooMyProperty? MyProperty { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_then_StringEnumConverter_is_set.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_then_StringEnumConverter_is_set.verified.txt index d42e9dbe1..595644730 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_then_StringEnumConverter_is_set.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_is_nullable_then_StringEnumConverter_is_set.verified.txt @@ -23,6 +23,7 @@ namespace MyNamespace public partial class MyStringEnumListTest { + [Newtonsoft.Json.JsonProperty("Enums", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.ICollection Enums { get; set; } @@ -30,6 +31,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public MyStringEnum? NullableEnum { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_list_uses_string_enums_then_ItemConverterType_is_set.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_list_uses_string_enums_then_ItemConverterType_is_set.verified.txt index d42e9dbe1..595644730 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_list_uses_string_enums_then_ItemConverterType_is_set.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_list_uses_string_enums_then_ItemConverterType_is_set.verified.txt @@ -23,6 +23,7 @@ namespace MyNamespace public partial class MyStringEnumListTest { + [Newtonsoft.Json.JsonProperty("Enums", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ItemConverterType = typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public System.Collections.Generic.ICollection Enums { get; set; } @@ -30,6 +31,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public MyStringEnum? NullableEnum { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_name_contains_colon_then_it_is_removed_and_next_word_converted_to_upper_case.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_name_contains_colon_then_it_is_removed_and_next_word_converted_to_upper_case.verified.txt index 5ddda26f9..d9467036e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_name_contains_colon_then_it_is_removed_and_next_word_converted_to_upper_case.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_name_contains_colon_then_it_is_removed_and_next_word_converted_to_upper_case.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + /// /// The event identifier. /// @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public MyClassEvent Event { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_property_is_not_required_in_Swagger2_then_it_is_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_property_is_not_required_in_Swagger2_then_it_is_nullable.verified.txt index 7d707cfc1..a28e85094 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_property_is_not_required_in_Swagger2_then_it_is_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_property_is_not_required_in_Swagger2_then_it_is_nullable.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + /// /// pet status in the store /// @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public MyClassStatus? Status { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_starts_with_plus_or_minus_convert_to_string_equivalent.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_starts_with_plus_or_minus_convert_to_string_equivalent.verified.txt index e597db407..146b9f932 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_starts_with_plus_or_minus_convert_to_string_equivalent.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_enum_starts_with_plus_or_minus_convert_to_string_equivalent.verified.txt @@ -26,12 +26,11 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public PlusMinusTestEnum Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_type_name_hint_has_generics_then_they_are_converted.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_type_name_hint_has_generics_then_they_are_converted.verified.txt index 405f9cc74..82d9c6359 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_type_name_hint_has_generics_then_they_are_converted.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/EnumTests.When_type_name_hint_has_generics_then_they_are_converted.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class FirstMetdodOfMetValue { + [Newtonsoft.Json.JsonProperty("GroupChar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public FirstMetdodOfMetValueGroupChar GroupChar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -29,11 +28,10 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public FirstMetdodOfMetValue Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_base64_format.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_base64_format.verified.txt index 5b887669f..57e9a35a1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_base64_format.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_base64_format.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Content", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public byte[] Content { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_byte_format.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_byte_format.verified.txt index 5b887669f..57e9a35a1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_byte_format.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.Can_generate_type_from_string_property_with_byte_format.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Content", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public byte[] Content { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_POCO_is_set_then_auto_properties_are_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_POCO_is_set_then_auto_properties_are_generated.verified.txt index 80811bd0d..a81a77532 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_POCO_is_set_then_auto_properties_are_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_POCO_is_set_then_auto_properties_are_generated.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,20 +60,20 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_allOf_contains_one_schema_then_csharp_inheritance_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_allOf_contains_one_schema_then_csharp_inheritance_is_generated.verified.txt index cb3f1f3d8..00ec0025a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_allOf_contains_one_schema_then_csharp_inheritance_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_allOf_contains_one_schema_then_csharp_inheritance_is_generated.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,20 +60,20 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class Teacher : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_array_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_array_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt index 135745502..830ba9f66 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_array_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_array_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("A", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.ICollection A { get; set; } = new System.Collections.ObjectModel.Collection(); @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("B", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection B { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_has_description_then_csharp_has_xml_comment.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_has_description_then_csharp_has_xml_comment.verified.txt index 92ecedf27..b1e568fb5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_has_description_then_csharp_has_xml_comment.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_has_description_then_csharp_has_xml_comment.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,13 +60,13 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } /// @@ -74,9 +74,9 @@ namespace MyNamespace /// public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_is_abstract_constructor_is_protected_for_record.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_is_abstract_constructor_is_protected_for_record.verified.txt index 4a490aa6b..51f83ac2d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_is_abstract_constructor_is_protected_for_record.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_class_is_abstract_constructor_is_protected_for_record.verified.txt @@ -11,22 +11,17 @@ namespace MyNamespace public abstract partial class AbstractAddress { [Newtonsoft.Json.JsonConstructor] - protected AbstractAddress(string @city, string @streetName) - - { - this.City = @city; - this.StreetName = @streetName; + } - } [Newtonsoft.Json.JsonProperty("city", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("city", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; } [Newtonsoft.Json.JsonProperty("streetName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string StreetName { get; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_code_is_generated_then_toolchain_version_is_printed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_code_is_generated_then_toolchain_version_is_printed.verified.txt index 608839832..ac5447e29 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_code_is_generated_then_toolchain_version_is_printed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_code_is_generated_then_toolchain_version_is_printed.verified.txt @@ -10,12 +10,11 @@ namespace ns public partial class MyClass { + [Newtonsoft.Json.JsonProperty("emptySchema", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.ICollection EmptySchema { get; set; } = new System.Collections.ObjectModel.Collection(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_init_in_record_and_constructor_provided.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_init_in_record_and_constructor_provided.verified.txt new file mode 100644 index 000000000..45e0e2969 --- /dev/null +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_init_in_record_and_constructor_provided.verified.txt @@ -0,0 +1,27 @@ +//---------------------- +// +// +//---------------------- + + +namespace MyNamespace +{ + #pragma warning disable // Disable all warnings + + public partial record Address + { + [Newtonsoft.Json.JsonConstructor] + public Address(string @street, string @city) + { + this.Street = @street; + this.City = @city; + } + + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Street { get; init; } + + [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string City { get; init; } + + } +} \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_no_setter_in_record_and_constructor_provided.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_no_setter_in_record_and_constructor_provided.verified.txt new file mode 100644 index 000000000..45e0e2969 --- /dev/null +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_csharp_record_no_setter_in_record_and_constructor_provided.verified.txt @@ -0,0 +1,27 @@ +//---------------------- +// +// +//---------------------- + + +namespace MyNamespace +{ + #pragma warning disable // Disable all warnings + + public partial record Address + { + [Newtonsoft.Json.JsonConstructor] + public Address(string @street, string @city) + { + this.Street = @street; + this.City = @city; + } + + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Street { get; init; } + + [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string City { get; init; } + + } +} \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_and_max_length_a_string_length_attribute_is_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_and_max_length_a_string_length_attribute_is_added.verified.txt index 39c3c32ca..002ce8525 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_and_max_length_a_string_length_attribute_is_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_and_max_length_a_string_length_attribute_is_added.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.StringLength(20, MinimumLength = 10)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_items_and_max_items_a_min_length_and_max_length_attributes_are_added_only_for_type_array.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_items_and_max_items_a_min_length_and_max_length_attributes_are_added_only_for_type_array.verified.txt index 60c7fdd04..9876eee71 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_items_and_max_items_a_min_length_and_max_length_attributes_are_added_only_for_type_array.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_items_and_max_items_a_min_length_and_max_length_attributes_are_added_only_for_type_array.verified.txt @@ -10,13 +10,12 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.MinLength(10)] [System.ComponentModel.DataAnnotations.MaxLength(20)] public System.Collections.Generic.ICollection Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_length_a_string_length_attribute_is_added_only_for_type_string.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_length_a_string_length_attribute_is_added_only_for_type_string.verified.txt index f29e948cc..0c897563d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_length_a_string_length_attribute_is_added_only_for_type_string.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_min_length_a_string_length_attribute_is_added_only_for_type_string.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double? Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_minimum_and_maximum_a_range_attribute_is_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_minimum_and_maximum_a_range_attribute_is_added.verified.txt index ccbfa60e2..b2a3b3849 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_minimum_and_maximum_a_range_attribute_is_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_both_minimum_and_maximum_a_range_attribute_is_added.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1, 10)] public int? Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetime.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetime.verified.txt index f75ae0a79..b14d88d95 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetime.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetime.verified.txt @@ -15,8 +15,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonConverter(typeof(DateFormatConverter))] public System.DateTime? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetimeoffset.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetimeoffset.verified.txt index a8fa6503a..280ec136f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetimeoffset.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_and_use_system_text_json_then_converter_should_be_added_for_datetimeoffset.verified.txt @@ -15,8 +15,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonConverter(typeof(DateFormatConverter))] public System.DateTimeOffset? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetime.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetime.verified.txt index da5dd5551..f378af16c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetime.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetime.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("a", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))] public System.DateTime? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetimeoffset.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetimeoffset.verified.txt index dad84ebfb..140f90c75 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetimeoffset.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_date_converter_should_be_added_for_datetimeoffset.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("a", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))] public System.DateTimeOffset? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_and_use_system_text_json_then_converter_should_not_be_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_and_use_system_text_json_then_converter_should_not_be_added.verified.txt index 2d26b76b6..24ae16278 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_and_use_system_text_json_then_converter_should_not_be_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_and_use_system_text_json_then_converter_should_not_be_added.verified.txt @@ -14,8 +14,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("a")] public System.DateTimeOffset? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [System.Text.Json.Serialization.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_converter_should_not_be_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_converter_should_not_be_added.verified.txt index cb3b85d87..01f10ea83 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_converter_should_not_be_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_datetime_converter_should_not_be_added.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("a", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.DateTimeOffset? A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_max_length_a_string_length_attribute_is_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_max_length_a_string_length_attribute_is_added.verified.txt index 428e4af94..74bfd4cc2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_max_length_a_string_length_attribute_is_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_max_length_a_string_length_attribute_is_added.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.StringLength(20)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_added_with_min_double_minimum_and_maximum.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_added_with_min_double_minimum_and_maximum.verified.txt index cd22ed745..db3fed2de 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_added_with_min_double_minimum_and_maximum.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_added_with_min_double_minimum_and_maximum.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(int.MinValue, 10)] public int? Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_not_added_for_anything_but_type_number_or_integer.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_not_added_for_anything_but_type_number_or_integer.verified.txt index a700462f7..794a85b74 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_not_added_for_anything_but_type_number_or_integer.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_maximum_a_range_attribute_is_not_added_for_anything_but_type_number_or_integer.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_min_length_a_string_length_attribute_is_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_min_length_a_string_length_attribute_is_added.verified.txt index de040f216..43157f012 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_min_length_a_string_length_attribute_is_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_min_length_a_string_length_attribute_is_added.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 10)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_minimum_a_range_attribute_is_added_with_minimum_and_max_double_maximum.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_minimum_a_range_attribute_is_added_with_minimum_and_max_double_maximum.verified.txt index e843fb2fb..f63dac38b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_minimum_a_range_attribute_is_added_with_minimum_and_max_double_maximum.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_minimum_a_range_attribute_is_added_with_minimum_and_max_double_maximum.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)] public int? Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_a_regular_expression_attribute_is_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_a_regular_expression_attribute_is_added.verified.txt index bd43bba31..3465bfa8d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_a_regular_expression_attribute_is_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_a_regular_expression_attribute_is_added.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_but_type_is_not_string_a_regular_expression_should_not_be_added.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_but_type_is_not_string_a_regular_expression_should_not_be_added.verified.txt index f29e948cc..0c897563d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_but_type_is_not_string_a_regular_expression_should_not_be_added.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_pattern_but_type_is_not_string_a_regular_expression_should_not_be_added.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double? Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_restrictions_but_render_data_annotations_is_set_to_false_they_should_not_be_included.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_restrictions_but_render_data_annotations_is_set_to_false_they_should_not_be_included.verified.txt index 6b03fac16..e72807892 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_restrictions_but_render_data_annotations_is_set_to_false_they_should_not_be_included.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_contains_restrictions_but_render_data_annotations_is_set_to_false_they_should_not_be_included.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("a", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int? A { get; set; } @@ -19,8 +20,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("c", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string C { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_is_named_Object_then_JObject_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_is_named_Object_then_JObject_is_generated.verified.txt index ea750587a..267dff719 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_is_named_Object_then_JObject_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_definition_is_named_Object_then_JObject_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_dictionary_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_dictionary_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt index 04cd1612a..38ce4854c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_dictionary_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_dictionary_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("A", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.IDictionary A { get; set; } = new System.Collections.Generic.Dictionary(); @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("B", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary B { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_documentation_present_produces_valid_xml_documentation_syntax.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_documentation_present_produces_valid_xml_documentation_syntax.verified.txt index c38609bf6..1b26960fd 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_documentation_present_produces_valid_xml_documentation_syntax.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_documentation_present_produces_valid_xml_documentation_syntax.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + /// /// Summary is here ///
@@ -21,6 +22,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("HelloMessage", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string HelloMessage { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_has_description_then_csharp_has_xml_comment.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_has_description_then_csharp_has_xml_comment.verified.txt index 66b53008a..143900292 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_has_description_then_csharp_has_xml_comment.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_has_description_then_csharp_has_xml_comment.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -47,7 +48,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -63,20 +63,20 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_int_serialization_then_correct_csharp_code_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_int_serialization_then_correct_csharp_code_generated.verified.txt index 3d93e9ede..132ef60e9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_int_serialization_then_correct_csharp_code_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_int_serialization_then_correct_csharp_code_generated.verified.txt @@ -31,10 +31,10 @@ namespace Foo public partial class MyClass { + [Newtonsoft.Json.JsonProperty("ConstructionCode", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public ConstructionCode ConstructionCode { get; set; } = Foo.ConstructionCode.NON_CBST; - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_string_serialization_then_correct_csharp_code_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_string_serialization_then_correct_csharp_code_generated.verified.txt index 3d93e9ede..132ef60e9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_string_serialization_then_correct_csharp_code_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_property_has_default_and_string_serialization_then_correct_csharp_code_generated.verified.txt @@ -31,10 +31,10 @@ namespace Foo public partial class MyClass { + [Newtonsoft.Json.JsonProperty("ConstructionCode", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public ConstructionCode ConstructionCode { get; set; } = Foo.ConstructionCode.NON_CBST; - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_type_name_is_missing_then_default_value_is_still_correctly_set.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_type_name_is_missing_then_default_value_is_still_correctly_set.verified.txt index 73cac6fff..fe052a670 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_type_name_is_missing_then_default_value_is_still_correctly_set.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_enum_type_name_is_missing_then_default_value_is_still_correctly_set.verified.txt @@ -10,10 +10,10 @@ namespace Foo public partial class MyClass { + [Newtonsoft.Json.JsonProperty("ConstructionCode", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public MyClassConstructionCode ConstructionCode { get; set; } = Foo.MyClassConstructionCode.JOIST_MAS; - } public enum MyClassConstructionCode diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_dash_then_it_is_converted_to_upper_case.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_dash_then_it_is_converted_to_upper_case.verified.txt index 4e3c5e004..8733c39cc 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_dash_then_it_is_converted_to_upper_case.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_dash_then_it_is_converted_to_upper_case.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo-bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FooBar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar3.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar3.verified.txt index 20518024c..bea9de289 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar3.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar3.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo.bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FooBar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar4.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar4.verified.txt index f9da20889..8183193f6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar4.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooBar4.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo=bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FooBar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooStarbar.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooStarbar.verified.txt index 9f54e3120..4c737afd9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooStarbar.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=FooStarbar.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo*bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FooStarbar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foo_bar.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foo_bar.verified.txt index 9a9670b6b..a0f9686c2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foo_bar.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foo_bar.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo:bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo_bar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar1.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar1.verified.txt index 4320d4429..47bb0c023 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar1.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar1.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo@bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foobar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar2.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar2.verified.txt index 33174bab3..0955ef430 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar2.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobar2.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo$bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foobar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobars.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobars.verified.txt index 0128a8779..e7fef7d20 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobars.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Foobars.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foobars[]", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foobars { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Fooplusbar.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Fooplusbar.verified.txt index cc9600161..ebf58000e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Fooplusbar.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_name_contains_unallowed_characters_then_they_are_converted_to_valid_csharp_jsonPropertyName=Fooplusbar.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("foo+bar", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Fooplusbar { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_namespace_is_set_then_it_should_appear_in_output.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_namespace_is_set_then_it_should_appear_in_output.verified.txt index 80811bd0d..a81a77532 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_namespace_is_set_then_it_should_appear_in_output.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_namespace_is_set_then_it_should_appear_in_output.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,20 +60,20 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_native_record_no_setter_in_class_and_constructor_provided.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_native_record_no_setter_in_class_and_constructor_provided.verified.txt index 3d7df8e0a..0c0a1d0f5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_native_record_no_setter_in_class_and_constructor_provided.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_native_record_no_setter_in_class_and_constructor_provided.verified.txt @@ -11,22 +11,17 @@ namespace MyNamespace public partial record Address { [Newtonsoft.Json.JsonConstructor] - public Address(string @city, string @street) - - { - this.Street = @street; - this.City = @city; + } - } [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; init; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; init; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_no_typeNameHint_is_available_then_title_is_used_as_class_name.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_no_typeNameHint_is_available_then_title_is_used_as_class_name.verified.txt index 9584e2348..1fba831b9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_no_typeNameHint_is_available_then_title_is_used_as_class_name.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_no_typeNameHint_is_available_then_title_is_used_as_class_name.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Endpoints", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection Endpoints { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,11 +27,10 @@ namespace MyNamespace public partial class Endpoints { + [Newtonsoft.Json.JsonProperty("url", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Url { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_nullable_property_is_required_then_it_is_not_nullable_in_generated_csharp_code.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_nullable_property_is_required_then_it_is_not_nullable_in_generated_csharp_code.verified.txt index 43fe8fcf6..8a89e3977 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_nullable_property_is_required_then_it_is_not_nullable_in_generated_csharp_code.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_nullable_property_is_required_then_it_is_not_nullable_in_generated_csharp_code.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyRequiredNullableTest { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Always)] public int Foo { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_has_generic_name_then_it_is_transformed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_has_generic_name_then_it_is_transformed.verified.txt index 8513512b9..e7001c2df 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_has_generic_name_then_it_is_transformed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_has_generic_name_then_it_is_transformed.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class FooOfBarOfInner { + [Newtonsoft.Json.JsonProperty("foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt index a038af286..427fb07ea 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_object_property_is_required_or_not_then_the_code_has_correct_initializer.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("A", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public A A { get; set; } = new A(); @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("B", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public B B { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -32,11 +31,10 @@ namespace MyNamespace public partial class A { + [Newtonsoft.Json.JsonProperty("A", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string A1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -50,11 +48,10 @@ namespace MyNamespace public partial class B { + [Newtonsoft.Json.JsonProperty("A", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string A { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_patternProperties_is_set_with_string_value_type_then_correct_dictionary_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_patternProperties_is_set_with_string_value_type_then_correct_dictionary_is_generated.verified.txt index 06da7497f..8cdbf72f4 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_patternProperties_is_set_with_string_value_type_then_correct_dictionary_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_patternProperties_is_set_with_string_value_type_then_correct_dictionary_is_generated.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("dict", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.IDictionary Dict { get; set; } = new System.Collections.Generic.Dictionary(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_description_then_csharp_has_xml_comment.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_description_then_csharp_has_xml_comment.verified.txt index 3ecf74489..48272d70f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_description_then_csharp_has_xml_comment.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_description_then_csharp_has_xml_comment.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,23 +60,23 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass : Person { + /// /// PropertyDesc. /// [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_not_supported_characters_then_they_are_removed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_not_supported_characters_then_they_are_removed.verified.txt index 55a41f5fc..bf197c261 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_not_supported_characters_then_they_are_removed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_not_supported_characters_then_they_are_removed.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("@odata.context", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string OdataContext { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_same_name_as_class_then_it_is_renamed.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_same_name_as_class_then_it_is_renamed.verified.txt index a80360e86..931c11148 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_same_name_as_class_then_it_is_renamed.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_has_same_name_as_class_then_it_is_renamed.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Foo { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo1 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_ObservableCollection_then_generated_code_uses_the_same_class.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_ObservableCollection_then_generated_code_uses_the_same_class.verified.txt index 13974747b..442e3573e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_ObservableCollection_then_generated_code_uses_the_same_class.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_ObservableCollection_then_generated_code_uses_the_same_class.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Test", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public ObservableCollection Test { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_byte_then_its_type_is_preserved.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_byte_then_its_type_is_preserved.verified.txt index b115d500a..d261a08fb 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_byte_then_its_type_is_preserved.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_byte_then_its_type_is_preserved.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyByteTest { + [Newtonsoft.Json.JsonProperty("Cell", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public byte? Cell { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_object_then_object_property_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_object_then_object_property_is_generated.verified.txt index 1665411fd..63969fb69 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_object_then_object_property_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_object_then_object_property_is_generated.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Foo { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_required_then_CSharp_code_is_correct.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_required_then_CSharp_code_is_correct.verified.txt index 0efa10110..a0f1e4511 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_required_then_CSharp_code_is_correct.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_required_then_CSharp_code_is_correct.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -20,6 +21,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Age", Required = Newtonsoft.Json.Required.AllowNull)] public int? Age { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_timespan_than_csharp_timespan_is_used.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_timespan_than_csharp_timespan_is_used.verified.txt index 81ffd8aca..71b1101f4 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_timespan_than_csharp_timespan_is_used.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_is_timespan_than_csharp_timespan_is_used.verified.txt @@ -21,17 +21,18 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -66,6 +67,5 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_does_not_match_property_name_then_attribute_is_correct.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_does_not_match_property_name_then_attribute_is_correct.verified.txt index 80811bd0d..a81a77532 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_does_not_match_property_name_then_attribute_is_correct.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_does_not_match_property_name_then_attribute_is_correct.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - } public enum Gender @@ -60,20 +60,20 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_attribute_is_correct.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_attribute_is_correct.verified.txt index 999f0efe7..110eb93f8 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_attribute_is_correct.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_attribute_is_correct.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyCustomTypePerson { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string MyCustomFirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary MyCustomDictionary { get; set; } - } public enum MyCustomTypeGender @@ -60,20 +60,20 @@ namespace MyNamespace public partial class MyCustomTypeAddress { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string MyCustomStreet { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string MyCustomCity { get; set; } - } public partial class MyCustomTypeTeacher : MyCustomTypePerson { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string MyCustomClass { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_parameter_name_is_correct_for_record.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_parameter_name_is_correct_for_record.verified.txt index 76c2088f1..57fb4cca9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_parameter_name_is_correct_for_record.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_property_name_is_created_by_custom_fun_then_parameter_name_is_correct_for_record.verified.txt @@ -11,22 +11,17 @@ namespace MyNamespace public partial class Address { [Newtonsoft.Json.JsonConstructor] - public Address(string @myCustomCity, string @myCustomStreet) - - { - this.MyCustomStreet = @myCustomStreet; - this.MyCustomCity = @myCustomCity; + } - } [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string MyCustomStreet { get; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string MyCustomCity { get; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_has_inheritance.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_has_inheritance.verified.txt index b1cb35221..27800f91b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_has_inheritance.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_has_inheritance.verified.txt @@ -11,65 +11,49 @@ namespace MyNamespace public partial class PostAddress : AbstractAddress { [Newtonsoft.Json.JsonConstructor] - public PostAddress(string @city, int @houseNumber, string @streetName, string @zip) - - : base(city, streetName) - { - this.Zip = @zip; - this.HouseNumber = @houseNumber; + } - } [Newtonsoft.Json.JsonProperty("Zip", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Zip", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Zip { get; } [Newtonsoft.Json.JsonProperty("HouseNumber", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int HouseNumber { get; } - } public abstract partial class AbstractAddress { [Newtonsoft.Json.JsonConstructor] - protected AbstractAddress(string @city, string @streetName) - - { - this.City = @city; - this.StreetName = @streetName; + } - } [Newtonsoft.Json.JsonProperty("city", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("city", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; } [Newtonsoft.Json.JsonProperty("streetName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string StreetName { get; } - } public partial class PersonAddress : PostAddress { [Newtonsoft.Json.JsonConstructor] - public PersonAddress(string @addressee, string @city, int @houseNumber, string @streetName, string @zip) - - : base(city, houseNumber, streetName, zip) - { - this.Addressee = @addressee; + } - } [Newtonsoft.Json.JsonProperty("Addressee", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Addressee", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Addressee { get; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_no_setter_in_class_and_constructor_provided.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_no_setter_in_class_and_constructor_provided.verified.txt index 7c990f55d..08d16a61e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_no_setter_in_class_and_constructor_provided.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_record_no_setter_in_class_and_constructor_provided.verified.txt @@ -11,22 +11,17 @@ namespace MyNamespace public partial class Address { [Newtonsoft.Json.JsonConstructor] - public Address(string @city, string @street) - - { - this.Street = @street; - this.City = @city; + } - } [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_contains_ref_to_definition_that_refs_another_definition_then_result_should_contain_correct_target_ref_type.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_contains_ref_to_definition_that_refs_another_definition_then_result_should_contain_correct_target_ref_type.verified.txt index ccc8bdeba..59c0db2b5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_contains_ref_to_definition_that_refs_another_definition_then_result_should_contain_correct_target_ref_type.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_contains_ref_to_definition_that_refs_another_definition_then_result_should_contain_correct_target_ref_type.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class PRef { + [Newtonsoft.Json.JsonProperty("pRef2", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string PRef2 { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -28,11 +27,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pRefs", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection PRefs { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_has_AdditionProperties_schema_then_JsonExtensionDataAttribute_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_has_AdditionProperties_schema_then_JsonExtensionDataAttribute_is_generated.verified.txt index 9c6abb4aa..9ceb04662 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_has_AdditionProperties_schema_then_JsonExtensionDataAttribute_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_schema_has_AdditionProperties_schema_then_JsonExtensionDataAttribute_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class PersonAddress { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=False.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=False.verified.txt index c6c8c833e..b1501f996 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=False.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=False.verified.txt @@ -18,7 +18,6 @@ namespace MyNamespace } - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -37,10 +36,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("OuterList", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public OuterList OuterList { get; set; } = new OuterList(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=True.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=True.verified.txt index 989a3422c..cd431e111 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=True.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_tuple_types_has_ints_then_it_is_generated_correctly_inlineNamedTuples=True.verified.txt @@ -15,10 +15,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("OuterList", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public OuterList OuterList { get; set; } = new OuterList(); - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_type_is_array_and_items_and_item_is_not_defined_then_any_array_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_type_is_array_and_items_and_item_is_not_defined_then_any_array_is_generated.verified.txt index 608839832..ac5447e29 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_type_is_array_and_items_and_item_is_not_defined_then_any_array_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_type_is_array_and_items_and_item_is_not_defined_then_any_array_is_generated.verified.txt @@ -10,12 +10,11 @@ namespace ns public partial class MyClass { + [Newtonsoft.Json.JsonProperty("emptySchema", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public System.Collections.Generic.ICollection EmptySchema { get; set; } = new System.Collections.ObjectModel.Collection(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt index 44428e650..865e6b926 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - public string ToJson() { @@ -57,7 +57,6 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject(data, new Newtonsoft.Json.JsonConverter[] { new CustomConverter1(), new CustomConverter2() }); } - } public enum Gender @@ -73,13 +72,13 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - public string ToJson() { @@ -92,15 +91,14 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject
(data, new Newtonsoft.Json.JsonConverter[] { new CustomConverter1(), new CustomConverter2() }); } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - public string ToJson() { @@ -113,6 +111,5 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject(data, new Newtonsoft.Json.JsonConverter[] { new CustomConverter1(), new CustomConverter2() }); } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt index 47d3412ad..4c64a2677 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_NewtonsoftJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } @@ -44,7 +45,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("Dictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.IDictionary Dictionary { get; set; } - public string ToJson() { @@ -57,7 +57,6 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject(data, new Newtonsoft.Json.JsonSerializerSettings()); } - } public enum Gender @@ -73,13 +72,13 @@ namespace MyNamespace public partial class Address { + [Newtonsoft.Json.JsonProperty("Street", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Street { get; set; } [Newtonsoft.Json.JsonProperty("City", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string City { get; set; } - public string ToJson() { @@ -92,15 +91,14 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject
(data, new Newtonsoft.Json.JsonSerializerSettings()); } - } public partial class MyClass : Person { + [Newtonsoft.Json.JsonProperty("Class", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Class { get; set; } - public string ToJson() { @@ -113,6 +111,5 @@ namespace MyNamespace return Newtonsoft.Json.JsonConvert.DeserializeObject(data, new Newtonsoft.Json.JsonSerializerSettings()); } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt index e82c0e7db..908cedd7f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_with_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt @@ -15,47 +15,36 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("lastName")] public string LastName { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Birthday")] public System.DateTimeOffset Birthday { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("TimeSpan")] public System.TimeSpan TimeSpan { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("TimeSpanOrNull")] public System.TimeSpan? TimeSpanOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Gender")] public Gender Gender { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("GenderOrNull")] public Gender? GenderOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Address")] public Address Address { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("AddressOrNull")] public Address AddressOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Array")] public System.Collections.Generic.ICollection Array { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Dictionary")] public System.Collections.Generic.IDictionary Dictionary { get; set; } - public string ToJson() { @@ -80,7 +69,6 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize(data, options); } - } public enum Gender @@ -100,11 +88,9 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Street")] public string Street { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("City")] public string City { get; set; } - public string ToJson() { @@ -129,7 +115,6 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize
(data, options); } - } public partial class MyClass : Person @@ -138,7 +123,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Class")] public string Class { get; set; } - public string ToJson() { @@ -163,6 +147,5 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize(data, options); } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt index 2c9c94348..ca241d917 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/GeneralGeneratorTests.When_using_SystemTextJson_without_JsonConverters_generates_FromJson_and_ToJson_correctly.verified.txt @@ -15,47 +15,36 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("lastName")] public string LastName { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Birthday")] public System.DateTimeOffset Birthday { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("TimeSpan")] public System.TimeSpan TimeSpan { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("TimeSpanOrNull")] public System.TimeSpan? TimeSpanOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Gender")] public Gender Gender { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("GenderOrNull")] public Gender? GenderOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Address")] public Address Address { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("AddressOrNull")] public Address AddressOrNull { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Array")] public System.Collections.Generic.ICollection Array { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("Dictionary")] public System.Collections.Generic.IDictionary Dictionary { get; set; } - public string ToJson() { @@ -72,7 +61,6 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize(data, options); } - } public enum Gender @@ -92,11 +80,9 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Street")] public string Street { get; set; } - [System.Text.Json.Serialization.JsonPropertyName("City")] public string City { get; set; } - public string ToJson() { @@ -113,7 +99,6 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize
(data, options); } - } public partial class MyClass : Person @@ -122,7 +107,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Class")] public string Class { get; set; } - public string ToJson() { @@ -139,6 +123,5 @@ namespace MyNamespace return System.Text.Json.JsonSerializer.Deserialize(data, options); } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_Newtonsoft.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_Newtonsoft.verified.txt index 66b29c356..0f98bc7f6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_Newtonsoft.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_Newtonsoft.verified.txt @@ -10,28 +10,28 @@ namespace MyNamespace public partial class Banana : Fruit { + [Newtonsoft.Json.JsonProperty("Amember", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Amember { get; set; } - } [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] [JsonInheritanceAttribute("Banana", typeof(Banana))] public partial class Fruit { + [Newtonsoft.Json.JsonProperty("ID", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public long ID { get; set; } - } public partial class MyContainer { + [Newtonsoft.Json.JsonProperty("Item", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Banana Item { get; set; } - } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple = true)] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_STJ.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_STJ.verified.txt index 0aa1f1dfb..494511a41 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_STJ.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_schema_has_base_schema_then_it_is_referenced_with_STJ.verified.txt @@ -14,7 +14,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Amember")] public string Amember { get; set; } - } [JsonInheritanceConverter(typeof(Fruit), "discriminator")] @@ -25,7 +24,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("ID")] public long ID { get; set; } - } public partial class MyContainer @@ -34,7 +32,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Item")] public Banana Item { get; set; } - } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple = true)] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_using_STJ_polymorphic_serialization_then_NSwag_inheritance_converter_and_attributes_are_not_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_using_STJ_polymorphic_serialization_then_NSwag_inheritance_converter_and_attributes_are_not_generated.verified.txt index 46603e0c4..65c497a4c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_using_STJ_polymorphic_serialization_then_NSwag_inheritance_converter_and_attributes_are_not_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceInterfaceTests.When_using_STJ_polymorphic_serialization_then_NSwag_inheritance_converter_and_attributes_are_not_generated.verified.txt @@ -14,7 +14,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Amember")] public string Amember { get; set; } - } [System.Text.Json.Serialization.JsonPolymorphic(TypeDiscriminatorPropertyName = "discriminator")] @@ -25,7 +24,6 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("ID")] public long ID { get; set; } - } public partial class MyContainer @@ -34,6 +32,5 @@ namespace MyNamespace [System.Text.Json.Serialization.JsonPropertyName("Item")] public Banana Item { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_class_with_discriminator_has_base_class_then_csharp_is_generated_correctly.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_class_with_discriminator_has_base_class_then_csharp_is_generated_correctly.verified.txt index cfb05234f..d1859263b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_class_with_discriminator_has_base_class_then_csharp_is_generated_correctly.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_class_with_discriminator_has_base_class_then_csharp_is_generated_correctly.verified.txt @@ -12,14 +12,15 @@ namespace MyNamespace [JsonInheritanceAttribute("MyException", typeof(MyException))] public partial class ExceptionBase : Exception { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Foo { get; set; } - } public partial class Exception { + [Newtonsoft.Json.JsonProperty("Message", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Message { get; set; } @@ -32,7 +33,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("StackTrace", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string StackTrace { get; set; } - } /// @@ -40,18 +40,18 @@ namespace MyNamespace /// public partial class MyException : ExceptionBase { + [Newtonsoft.Json.JsonProperty("Bar", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Bar { get; set; } - } public partial class ExceptionContainer { + [Newtonsoft.Json.JsonProperty("Exception", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public ExceptionBase Exception { get; set; } - } [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple = true)] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema.verified.txt index 857f2f4d4..174eb7709 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema.verified.txt @@ -11,29 +11,21 @@ namespace MyNamespace public partial class Cat : Animal { [Newtonsoft.Json.JsonConstructor] - public Cat() - - : base() - { - } + } public partial class PersianCat : Cat { [Newtonsoft.Json.JsonConstructor] - public PersianCat() - - : base() - { - } + } [Newtonsoft.Json.JsonConverter(typeof(JsonInheritanceConverter), "discriminator")] @@ -42,12 +34,8 @@ namespace MyNamespace public abstract partial class Animal { [Newtonsoft.Json.JsonConstructor] - protected Animal() - - { - } private System.Collections.Generic.IDictionary _additionalProperties; diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema_and_STJ_polymorphism.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema_and_STJ_polymorphism.verified.txt index 1a1ba18d1..c2bb28819 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema_and_STJ_polymorphism.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definitions_inherit_from_root_schema_and_STJ_polymorphism.verified.txt @@ -11,29 +11,21 @@ namespace MyNamespace public partial class Cat : Animal { [System.Text.Json.Serialization.JsonConstructor] - public Cat() - - : base() - { - } + } public partial class PersianCat : Cat { [System.Text.Json.Serialization.JsonConstructor] - public PersianCat() - - : base() - { - } + } [System.Text.Json.Serialization.JsonPolymorphic(TypeDiscriminatorPropertyName = "discriminator")] @@ -42,12 +34,8 @@ namespace MyNamespace public abstract partial class Animal { [System.Text.Json.Serialization.JsonConstructor] - protected Animal() - - { - } private System.Collections.Generic.IDictionary _additionalProperties; diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works.verified.txt index c4eba9b6d..3b411891a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works.verified.txt @@ -18,9 +18,9 @@ namespace MyNamespace public partial class MyContainer { + [Newtonsoft.Json.JsonProperty("CustomDictionary", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public EmptyClassInheritingDictionary CustomDictionary { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_property_references_any_schema_with_inheritance_then_property_type_is_correct.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_property_references_any_schema_with_inheritance_then_property_type_is_correct.verified.txt index e72352353..6ee8cb05d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_property_references_any_schema_with_inheritance_then_property_type_is_correct.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_property_references_any_schema_with_inheritance_then_property_type_is_correct.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class Pet { + [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Name { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -33,11 +32,10 @@ namespace MyNamespace public partial class Anonymous { + [Newtonsoft.Json.JsonProperty("dog", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Dog Dog { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_class_implements_interface_then_properties_are_included_in_schema.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_class_implements_interface_then_properties_are_included_in_schema.verified.txt index 7750a2083..045f888df 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_class_implements_interface_then_properties_are_included_in_schema.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_class_implements_interface_then_properties_are_included_in_schema.verified.txt @@ -10,12 +10,12 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("LastName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string LastName { get; set; } [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FirstName { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_interface_has_properties_then_properties_are_included_in_schema.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_interface_has_properties_then_properties_are_included_in_schema.verified.txt index 7750a2083..045f888df 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_interface_has_properties_then_properties_are_included_in_schema.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InterfaceTests.When_interface_has_properties_then_properties_are_included_in_schema.verified.txt @@ -10,12 +10,12 @@ namespace MyNamespace public partial class Person { + [Newtonsoft.Json.JsonProperty("LastName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string LastName { get; set; } [Newtonsoft.Json.JsonProperty("FirstName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string FirstName { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableEnumTests.When_Swagger2_enum_property_is_not_required_then_it_is_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableEnumTests.When_Swagger2_enum_property_is_not_required_then_it_is_nullable.verified.txt index 33996241c..d540f18d9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableEnumTests.When_Swagger2_enum_property_is_not_required_then_it_is_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableEnumTests.When_Swagger2_enum_property_is_not_required_then_it_is_nullable.verified.txt @@ -23,12 +23,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("sex", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public Sex? Sex { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property.verified.txt index 6ae740dba..25acf310b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Property { get; set; } @@ -17,8 +18,6 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object Property2 { get; set; } = new object(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt index 80fcab438..dad54cb2a 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_generating_from_json_schema_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object? Property { get; set; } = default!; @@ -20,8 +21,6 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object Property2 { get; set; } = new object(); - - private System.Collections.Generic.IDictionary? _additionalProperties; [Newtonsoft.Json.JsonExtensionData] 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date-time.verified.txt index 49db37d59..aa69c138b 100644 --- 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date-time.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("required", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Required { get; set; } @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("optional", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Optional { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date.verified.txt index 49db37d59..aa69c138b 100644 --- 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=date.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("required", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Required { get; set; } @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("optional", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Optional { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time-span.verified.txt index 49db37d59..aa69c138b 100644 --- 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time-span.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("required", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Required { get; set; } @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("optional", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Optional { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time.verified.txt index 49db37d59..aa69c138b 100644 --- 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_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_format=time.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("required", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Required { get; set; } @@ -17,8 +18,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("optional", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Optional { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date-time.verified.txt index f4bf7778b..a25a64ead 100644 --- 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date-time.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace 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!; @@ -20,8 +21,6 @@ namespace MyNamespace [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] 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date.verified.txt index f4bf7778b..a25a64ead 100644 --- 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=date.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace 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!; @@ -20,8 +21,6 @@ namespace MyNamespace [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] 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time-span.verified.txt index f4bf7778b..a25a64ead 100644 --- 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time-span.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace 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!; @@ -20,8 +21,6 @@ namespace MyNamespace [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] 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time.verified.txt index f4bf7778b..a25a64ead 100644 --- 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_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_format=time.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace 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!; @@ -20,8 +21,6 @@ namespace MyNamespace [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] 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_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt index f4bf7778b..a25a64ead 100644 --- 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_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace 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!; @@ -20,8 +21,6 @@ namespace MyNamespace [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] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt index 0083e1ed8..010328cf8 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object? Property { get; set; } = default!; @@ -20,6 +21,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object Property2 { get; set; } = default!; - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableReferenceTypes_is_not_set_then_CSharp_property_is_not_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableReferenceTypes_is_not_set_then_CSharp_property_is_not_nullable.verified.txt index d4823e4ed..23c57d490 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableReferenceTypes_is_not_set_then_CSharp_property_is_not_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableReferenceTypesTests.When_property_is_optional_and_GenerateNullableReferenceTypes_is_not_set_then_CSharp_property_is_not_nullable.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Property { get; set; } @@ -17,6 +18,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object Property2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_is_not_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_is_not_nullable.verified.txt index e15c32462..e4c556149 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_is_not_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property_is_not_nullable.verified.txt @@ -10,12 +10,12 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int Property { get; set; } [Newtonsoft.Json.JsonProperty("Property2", Required = Newtonsoft.Json.Required.Always)] public int Property2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt index 72822c546..fbbf6352b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NullableTests.When_property_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property_is_nullable.verified.txt @@ -10,12 +10,12 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int? Property { get; set; } [Newtonsoft.Json.JsonProperty("Property2", Required = Newtonsoft.Json.Required.Always)] public int Property2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_decimal_type_setting_is_defined_then_setting_type_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_decimal_type_setting_is_defined_then_setting_type_is_generated.verified.txt index 10f371aaa..55b103d5c 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_decimal_type_setting_is_defined_then_setting_type_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_decimal_type_setting_is_defined_then_setting_type_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public customDecimalType Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_double_type_setting_is_defined_then_setting_type_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_double_type_setting_is_defined_then_setting_type_is_generated.verified.txt index 17e7ac8c2..2f9b3810e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_double_type_setting_is_defined_then_setting_type_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_double_type_setting_is_defined_then_setting_type_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public customDoubleType Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_float_type_setting_is_defined_then_setting_type_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_float_type_setting_is_defined_then_setting_type_is_generated.verified.txt index 09f454e50..c9a40ab93 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_float_type_setting_is_defined_then_setting_type_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_float_type_setting_is_defined_then_setting_type_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public customFloatType Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_decimal_format_then_decimal_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_decimal_format_then_decimal_is_generated.verified.txt index 13a9cf7ca..f286e15d8 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_decimal_format_then_decimal_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_decimal_format_then_decimal_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public decimal Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_double_format_then_double_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_double_format_then_double_is_generated.verified.txt index 07a51cd5d..f707556e6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_double_format_then_double_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_double_format_then_double_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_float_format_then_float_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_float_format_then_float_is_generated.verified.txt index f6c320a28..809fd7c56 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_float_format_then_float_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_float_format_then_float_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public float Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_no_format_then_default_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_no_format_then_default_is_generated.verified.txt index 07a51cd5d..f707556e6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_no_format_then_default_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_has_no_format_then_default_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_defined_then_setting_type_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_defined_then_setting_type_is_generated.verified.txt index f9461a290..1ddb9c611 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_defined_then_setting_type_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_defined_then_setting_type_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public customNumberType Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_null_then_double_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_null_then_double_is_generated.verified.txt index a0934584a..74792a1c9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_null_then_double_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_null_then_double_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double? Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_whitespace_then_double_is_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_whitespace_then_double_is_generated.verified.txt index 07a51cd5d..f707556e6 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_whitespace_then_double_is_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/NumberTests.When_number_type_setting_is_whitespace_then_double_is_generated.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("amount", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Amount { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt index 4e1654733..516fd1969 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt index 4e1654733..516fd1969 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public object Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt index 2b1084c8e..26ba51c98 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public object Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt index 2b1084c8e..26ba51c98 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObjectPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public object Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt index 86176c192..ccd864a11 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt @@ -11,9 +11,9 @@ namespace MyNamespace [System.Obsolete] public partial class ObsoleteTestClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt index 329fbb3e3..5918aba1f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_class_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt @@ -11,9 +11,9 @@ namespace MyNamespace [System.Obsolete("Reason class is \"obsolete\"")] public partial class ObsoleteWithMessageTestClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt index 79b2a747d..fed9735e2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_then_obsolete_attribute_is_rendered.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class ObsoletePropertyTestClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.Obsolete] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt index 843dd21e3..ceaaaa281 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ObsoleteTests.When_property_is_obsolete_with_a_message_then_obsolete_attribute_with_a_message_is_rendered.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class ObsoletePropertyWithMessageTestClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.Obsolete("Reason property is \"obsolete\"")] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_date_reference_is_generated_from_swagger2_schema_then_generated_member_is_decorated_with_date_format_attribute.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_date_reference_is_generated_from_swagger2_schema_then_generated_member_is_decorated_with_date_format_attribute.verified.txt index dd9e74f8e..96e636356 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_date_reference_is_generated_from_swagger2_schema_then_generated_member_is_decorated_with_date_format_attribute.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_date_reference_is_generated_from_swagger2_schema_then_generated_member_is_decorated_with_date_format_attribute.verified.txt @@ -10,20 +10,20 @@ namespace MyNamespace public partial class MyType { + [Newtonsoft.Json.JsonProperty("EntryDate", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))] public System.DateTimeOffset EntryDate { get; set; } - } public partial class MyClass { + [Newtonsoft.Json.JsonProperty("MyType", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public MyType MyType { get; set; } - } internal class DateFormatConverter : Newtonsoft.Json.Converters.IsoDateTimeConverter diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_inheritance_with_object_without_props_is_generated_then_all_classes_exist_and_additional_properties_property_is_not_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_inheritance_with_object_without_props_is_generated_then_all_classes_exist_and_additional_properties_property_is_not_generated.verified.txt index 01ffab757..cc218aceb 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_inheritance_with_object_without_props_is_generated_then_all_classes_exist_and_additional_properties_property_is_not_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_inheritance_with_object_without_props_is_generated_then_all_classes_exist_and_additional_properties_property_is_not_generated.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class BusinessException { + [Newtonsoft.Json.JsonProperty("customerId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string CustomerId { get; set; } @@ -19,7 +20,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("userId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string UserId { get; set; } - } public partial class ValidationException : BusinessException @@ -29,9 +29,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Exception", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public BusinessException Exception { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_definitions_no_types_are_duplicated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_definitions_no_types_are_duplicated.verified.txt index 031d1d7dc..ffde63de9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_definitions_no_types_are_duplicated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_definitions_no_types_are_duplicated.verified.txt @@ -13,6 +13,7 @@ namespace MyNamespace /// public partial class B { + /// /// This is the ID of B /// @@ -32,8 +33,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("empty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public D Empty { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -67,7 +66,6 @@ namespace MyNamespace public partial class D { - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -84,6 +82,7 @@ namespace MyNamespace /// public partial class MyClass { + /// /// This is the type of E /// @@ -95,8 +94,6 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object SignalPaths { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_and_it_contains_nullable_property_then_generated_property_is_also_nullable.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_and_it_contains_nullable_property_then_generated_property_is_also_nullable.verified.txt index 15d0a12b9..1610ae1a3 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_and_it_contains_nullable_property_then_generated_property_is_also_nullable.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_and_it_contains_nullable_property_then_generated_property_is_also_nullable.verified.txt @@ -13,14 +13,13 @@ namespace MyNamespace public partial class MyClass { + /// /// This is the type of G /// [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string? Name { get; set; } = default!; - - private System.Collections.Generic.IDictionary? _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_no_types_are_duplicated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_no_types_are_duplicated.verified.txt index c7ea7df55..06d38905d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_no_types_are_duplicated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ReferencesTest.When_ref_is_file_no_types_are_duplicated.verified.txt @@ -30,7 +30,6 @@ namespace MyNamespace public partial class D { - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -47,6 +46,7 @@ namespace MyNamespace /// public partial class B { + /// /// This is the ID of B /// @@ -66,8 +66,6 @@ namespace MyNamespace [Newtonsoft.Json.JsonProperty("empty", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public D Empty { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] @@ -84,6 +82,7 @@ namespace MyNamespace /// public partial class MyClass { + /// /// This is the type of A /// @@ -95,8 +94,6 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required] public object SignalPaths { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt index 9cc592d76..e795cc5ef 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt index 9cc592d76..e795cc5ef 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_not_required_then_required_attribute_is_not_rendered_in_Swagger_mode.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Property { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt index 9593c79d1..4ca9618d3 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string Property { get; set; } @@ -18,6 +19,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Property2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt index 9593c79d1..4ca9618d3 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/StringPropertyRequiredTests.When_property_is_required_then_required_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Property", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string Property { get; set; } @@ -18,6 +19,5 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Property2 { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/UriTests.When_property_is_uri_then_csharp_output_is_also_uri.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/UriTests.When_property_is_uri_then_csharp_output_is_also_uri.verified.txt index 752546cbc..ad04cb3cc 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/UriTests.When_property_is_uri_then_csharp_output_is_also_uri.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/UriTests.When_property_is_uri_then_csharp_output_is_also_uri.verified.txt @@ -10,9 +10,9 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("MyUri", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Uri MyUri { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_maxitems_then_maxlength_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_maxitems_then_maxlength_attribute_is_rendered_in_Swagger_mode.verified.txt index 1d866410b..1715bb0cc 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_maxitems_then_maxlength_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_maxitems_then_maxlength_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -15,13 +15,12 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.MaxLength(10)] public Array10 Value { get; set; } = new Array10(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_minitems_then_minlength_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_minitems_then_minlength_attribute_is_rendered_in_Swagger_mode.verified.txt index 5d16e23d5..661978a15 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_minitems_then_minlength_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_array_property_has_minitems_then_minlength_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,13 +10,12 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.MinLength(10)] public System.Collections.Generic.ICollection Value { get; set; } = new System.Collections.ObjectModel.Collection(); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int32_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int32_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index 41de4fa2b..a5ac4f572 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int32_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int32_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(10, int.MaxValue)] public int Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int64_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int64_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index d2b677921..cbe79acbc 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int64_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int64_property_has_minimum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(10L, long.MaxValue)] public long Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int_property_has_maximum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int_property_has_maximum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index 50f7b850a..32a74156f 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int_property_has_maximum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_int_property_has_maximum_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(int.MinValue, 20)] public int Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_int64_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_int64_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index e6c30013d..f800b13e5 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_int64_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_int64_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(-10000000000L, 10000000000L)] public long Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_too_large_or_small_for_int64.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_too_large_or_small_for_int64.verified.txt index 55bb23e0f..1f2e7316d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_too_large_or_small_for_int64.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_that_are_too_large_or_small_for_int64.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(-9223372036854775808L, 9223372036854775807L)] public long Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_with_exclusive_true_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_with_exclusive_true_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index 38b845e35..e42450ebc 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_with_exclusive_true_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_integer_property_has_minimum_and_maximum_with_exclusive_true_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(-99999999, 99999999)] public int Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_decimal_then_range_attribute_is_rendered.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_decimal_then_range_attribute_is_rendered.verified.txt index 6390f3dc3..294ac822e 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_decimal_then_range_attribute_is_rendered.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_decimal_then_range_attribute_is_rendered.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(typeof(decimal), "-100.50", "100.50")] public decimal Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_double_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_double_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index 61508246a..5d75cc988 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_double_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_that_are_double_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(-10000000000D, 10000000000D)] public double Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_with_exclusive_true_and_multipleof_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_with_exclusive_true_and_multipleof_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt index 460cdd930..74a825ba1 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_with_exclusive_true_and_multipleof_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_number_property_has_minimum_and_maximum_with_exclusive_true_and_multipleof_then_range_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Range(-100000000.4999D, 100000000.4999D)] public double Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_maxlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_maxlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt index 926203130..21b435f65 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_maxlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_maxlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,13 +10,12 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.StringLength(50)] public string Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_minlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_minlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt index 5bdd1b5ee..2e4b1c2d9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_minlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_minlength_then_stringlength_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,13 +10,12 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 40)] public string Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_pattern_then_regularexpression_attribute_is_rendered_in_Swagger_mode.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_pattern_then_regularexpression_attribute_is_rendered_in_Swagger_mode.verified.txt index 31de48ea5..2077ca9c3 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_pattern_then_regularexpression_attribute_is_rendered_in_Swagger_mode.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValidationAttributesTests.When_string_property_has_pattern_then_regularexpression_attribute_is_rendered_in_Swagger_mode.verified.txt @@ -10,13 +10,12 @@ namespace MyNamespace public partial class Message { + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] [System.ComponentModel.DataAnnotations.RegularExpression(@"[a-zA-Z0-9]{5,56}")] public string Value { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_integer_and_no_format_is_available_then_default_value_is_int32.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_integer_and_no_format_is_available_then_default_value_is_int32.verified.txt index 47d41cc33..de8f1d7e2 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_integer_and_no_format_is_available_then_default_value_is_int32.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_integer_and_no_format_is_available_then_default_value_is_int32.verified.txt @@ -10,6 +10,7 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)] public int? PageSize { get; set; } = 10; @@ -18,8 +19,6 @@ namespace MyNamespace [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)] public int? PagingSize { get; set; } = 5; - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_string_and_format_is_date_time_then_assign_default_value.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_string_and_format_is_date_time_then_assign_default_value.verified.txt index 3f03cb810..98182925d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_string_and_format_is_date_time_then_assign_default_value.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_property_is_string_and_format_is_date_time_then_assign_default_value.verified.txt @@ -10,11 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("dateTime", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.DateTime? DateTime { get; set; } = System.DateTime.Parse("31.12.9999 23:59:59"); - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int32.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int32.verified.txt index 7fd320aa0..7c7a17692 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int32.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int32.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1, int.MaxValue)] public int? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int64.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int64.verified.txt index 2991fb9d3..e243af129 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int64.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=int64.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1L, long.MaxValue)] public long? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=uint64.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=uint64.verified.txt index f76c9e39c..8606e2976 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=uint64.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=integer_propertyFormat=uint64.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1UL, ulong.MaxValue)] public ulong? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=decimal.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=decimal.verified.txt index 86b2cfe86..9307d4a4b 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=decimal.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=decimal.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(typeof(decimal), "1", "79228162514264337593543950335")] public decimal? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=double.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=double.verified.txt index 165b01eb1..3db36eabe 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=double.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=double.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1D, double.MaxValue)] public double? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=float.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=float.verified.txt index 413a64722..6fb320270 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=float.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_and_format_then_code_is_correctly_generated_propertyType=number_propertyFormat=float.verified.txt @@ -10,12 +10,11 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("pageSize", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(1F, float.MaxValue)] public float? PageSize { get; set; } - - private System.Collections.Generic.IDictionary _additionalProperties; [Newtonsoft.Json.JsonExtensionData] diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_then_code_is_correctly_generated.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_then_code_is_correctly_generated.verified.txt index 80ac36eee..d1c6f5614 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_then_code_is_correctly_generated.verified.txt +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/ValueGeneratorTests.When_schema_contains_range_then_code_is_correctly_generated.verified.txt @@ -10,10 +10,10 @@ namespace MyNamespace public partial class MyClass { + [Newtonsoft.Json.JsonProperty("Foo", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.Range(2, int.MaxValue)] public int? Foo { get; set; } - } } \ No newline at end of file diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid index eb9b39ada..3dfa4330d 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid +++ b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.Constructor.Record.liquid @@ -1,30 +1,30 @@ -{%- assign skipComma = true %} -{% if HasInheritance %} -{%- assign parentProperties = BaseClass.AllProperties %} +{%- assign skipComma = true -%} +{% if HasInheritance -%} +{%- assign parentProperties = BaseClass.AllProperties -%} {% else %} -{%- assign parentProperties = "" | empty %} -{% endif %} +{%- assign parentProperties = "" | empty -%} +{% endif -%} -{% if SortConstructorParameters %} -{%- assign sortedProperties = AllProperties | sort: "Name" %} -{%- assign sortedParentProperties = parentProperties | sort: "Name" %} -{% else %} +{%- if SortConstructorParameters -%} +{%- assign sortedProperties = AllProperties | sort: "Name" -%} +{%- assign sortedParentProperties = parentProperties | sort: "Name" -%} +{%- else -%} {%- assign sortedProperties = AllProperties -%} {%- assign sortedParentProperties = parentProperties -%} -{% endif %} +{%- endif -%} -{%- if UseSystemTextJson %} +{%- if UseSystemTextJson -%} [System.Text.Json.Serialization.JsonConstructor] -{%- else %} +{%- else -%} [Newtonsoft.Json.JsonConstructor] -{%- endif %} +{%- endif -%} {% if IsAbstract %}protected{% else %}public{% endif %} {{ClassName}}({% for property in sortedProperties %}{%- if skipComma %}{%- assign skipComma = false %}{% else %}, {% endif %}{{ property.Type }} @{{ property.PropertyName | lowercamelcase }}{% endfor %}) -{%- assign skipComma = true %} -{%- if HasInheritance %} +{%- assign skipComma = true -%} +{%- if HasInheritance -%} : base({%- for property in sortedParentProperties %}{%- if skipComma %}{%- assign skipComma = false %}{% else %}, {% endif %}{{ property.PropertyName | lowercamelcase }}{%- endfor %}) -{%- endif %} +{%- endif -%} { -{%- for property in Properties %} +{%- for property in Properties -%} this.{{property.PropertyName}} = @{{property.PropertyName | lowercamelcase}}; -{%- endfor %} +{%- endfor -%} } diff --git a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid index 60f6f1edf..f2229e6b9 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid +++ b/src/NJsonSchema.CodeGeneration.CSharp/Templates/Class.liquid @@ -35,7 +35,7 @@ [System.Obsolete{% if HasDeprecatedMessage %}({{ DeprecatedMessage | literal }}){% endif %}] {% endif -%} {%- template Class.Annotations -%} -{{ TypeAccessModifier }} {% if IsAbstract %}abstract {% endif %}partial {% if GenerateNativeRecords %}record{% else %}class{% endif %} {{ClassName}} {%- template Class.Inheritance %} +{{ TypeAccessModifier }} {% if IsAbstract %}abstract {% endif %}partial {{ ClassType }} {{ClassName}} {%- template Class.Inheritance %} { {%- if IsTuple -%} public {{ ClassName }}({%- for tupleType in TupleTypes %}{{ tupleType }} item{{ forloop.index }}{%- if forloop.last == false %}, {% endif %}{% endfor %}) : base({%- for tupleType in TupleTypes %}item{{ forloop.index }}{%- if forloop.last == false %}, {% endif %}{% endfor %}) @@ -49,19 +49,19 @@ {%- endfor -%} {%- endif -%} - {%- template Class.Constructor -%} + {% template Class.Constructor %} {%- if RenderRecord -%} - {% template Class.Constructor.Record -%} -{%- endif -%} + {% template Class.Constructor.Record %} +{%- endif %} {%- for property in Properties -%} {%- if property.HasDescription -%} /// /// {{ property.Description | csharpdocs }} /// {%- endif -%} -{%- if UseSystemTextJson %} +{%- if UseSystemTextJson -%} [System.Text.Json.Serialization.JsonPropertyName("{{ property.Name }}")] -{%- if property.IsStringEnumArray %} +{%- if property.IsStringEnumArray -%} // TODO(system.text.json): Add string enum item converter {%- endif -%} {%- else -%} @@ -108,10 +108,9 @@ {%- endif -%} {%- template Class.Property.Annotations -%} public {% if UseRequiredKeyword and property.IsRequired %}required {% endif %}{{ property.Type }} {{ property.PropertyName }}{% if RenderInpc == false and RenderPrism == false %} { get; {% if property.HasSetter and RenderRecord == false %}set; {% elsif RenderRecord and GenerateNativeRecords %}init; {% endif %}}{% if property.HasDefaultValue and RenderRecord == false %} = {{ property.DefaultValue }};{% elsif GenerateNullableReferenceTypes and RenderRecord == false %} = default!;{% endif %} -{% else %} +{%- else -%} { get { return {{ property.FieldName }}; } - {%- if property.HasSetter -%} {%- if RenderInpc -%} {{PropertySetterAccessModifier}}set @@ -127,11 +126,10 @@ {%- endif -%} {%- endif -%} } -{%- endif %} -{%- endfor -%} +{%- endif -%} +{%- endfor -%} {%- if GenerateAdditionalPropertiesProperty -%} - private System.Collections.Generic.IDictionary{% if GenerateNullableReferenceTypes %}?{% endif %} _additionalProperties; {%- if UseSystemTextJson -%} @@ -149,7 +147,6 @@ {%- if GenerateJsonMethods -%} {% template Class.ToJson %} {% template Class.FromJson %} - {%- endif -%} {%- if RenderInpc -%} {% template Class.Inpc %} From e0feecea636ad9ec69b876f64c0c640aff448511 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 27 Jul 2025 12:16:32 +0300 Subject: [PATCH 5/5] use verify --- .../InheritanceTests.cs | 14 ++--- ...rameters_from_base_come_first.verified.txt | 58 +++++++++++++++++++ 2 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definition_inherits_parameters_from_base_come_first.verified.txt diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs b/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs index 84d033df7..a4f2afada 100644 --- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/InheritanceTests.cs @@ -176,10 +176,10 @@ public async Task When_definitions_inherit_from_root_schema_and_STJ_polymorphism [Fact] public async Task When_definition_inherits_parameters_from_base_come_first() { - //// Arrange + // Arrange var path = GetTestDirectory() + "/References/Car.json"; - //// Act + // Act var schema = await JsonSchema.FromFileAsync(path); var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings { @@ -187,14 +187,12 @@ public async Task When_definition_inherits_parameters_from_base_come_first() SortConstructorParameters = false, }); - //// Act + // Act var code = generator.GenerateFile(); - //// Assert - Assert.Contains("public partial class Car : Vehicle", code); - Assert.Contains("Vehicle(string @id)", code); - Assert.Contains("Car(string @id, int @wheels)", code); - Assert.Contains("base(id)", code); + // Assert + await VerifyHelper.Verify(code); + CodeCompiler.AssertCompile(code); } private string GetTestDirectory() diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definition_inherits_parameters_from_base_come_first.verified.txt b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definition_inherits_parameters_from_base_come_first.verified.txt new file mode 100644 index 000000000..fa4c2cb13 --- /dev/null +++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/Snapshots/InheritanceTests.When_definition_inherits_parameters_from_base_come_first.verified.txt @@ -0,0 +1,58 @@ +//---------------------- +// +// +//---------------------- + + +namespace MyNamespace +{ + #pragma warning disable // Disable all warnings + + /// + /// This is a vehicle + /// + public abstract partial class Vehicle + { + [Newtonsoft.Json.JsonConstructor] + protected Vehicle(string @id) + { + this.Id = @id; + } + + /// + /// This is the ID of Vehicle + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Id { get; } + + 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; } + } + + } + + /// + /// This is a car + /// + public partial class Car : Vehicle + { + [Newtonsoft.Json.JsonConstructor] + public Car(string @id, int @wheels) + : base(id) + { + this.Wheels = @wheels; + } + + /// + /// The number of wheels on the car + /// + [Newtonsoft.Json.JsonProperty("wheels", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int Wheels { get; } + + } +} \ No newline at end of file