diff --git a/core/data/tests/anonymous_struct_with_rename/output.cs b/core/data/tests/anonymous_struct_with_rename/output.cs index d4e2f2da..84db6773 100644 --- a/core/data/tests/anonymous_struct_with_rename/output.cs +++ b/core/data/tests/anonymous_struct_with_rename/output.cs @@ -7,20 +7,27 @@ /** Generated type representing the anonymous struct variant `List` of the `AnonymousStructWithRename` Rust enum */ public class AnonymousStructWithRenameListInner { + [JsonProperty(Required = Required.Always)] public IEnumerable list { get; set; } } /** Generated type representing the anonymous struct variant `LongFieldNames` of the `AnonymousStructWithRename` Rust enum */ public class AnonymousStructWithRenameLongFieldNamesInner { + [JsonProperty(Required = Required.Always)] public string some_long_field_name { get; set; } + [JsonProperty(Required = Required.Always)] public bool and { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable but_one_more { get; set; } } /** Generated type representing the anonymous struct variant `KebabCase` of the `AnonymousStructWithRename` Rust enum */ public class AnonymousStructWithRenameKebabCaseInner { + [JsonProperty(Required = Required.Always)] public IEnumerable another-list { get; set; } + [JsonProperty(Required = Required.Always)] public string camelCaseStringField { get; set; } + [JsonProperty(Required = Required.Always)] public bool something-else { get; set; } } diff --git a/core/data/tests/can_apply_prefix_correctly/output.cs b/core/data/tests/can_apply_prefix_correctly/output.cs index 4608b126..c8129964 100644 --- a/core/data/tests/can_apply_prefix_correctly/output.cs +++ b/core/data/tests/can_apply_prefix_correctly/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class ItemDetailsFieldValue { + [JsonProperty(Required = Required.Always)] public string Hello { get; set; } } diff --git a/core/data/tests/can_generate_generic_enum/output.cs b/core/data/tests/can_generate_generic_enum/output.cs index d7e26d9f..6d3adab1 100644 --- a/core/data/tests/can_generate_generic_enum/output.cs +++ b/core/data/tests/can_generate_generic_enum/output.cs @@ -16,6 +16,7 @@ public record VariantB(TB Content) : GenericEnum(); public class StructUsingGenericEnum { + [JsonProperty(Required = Required.Always)] public GenericEnum EnumField { get; set; } } @@ -33,23 +34,29 @@ public record VariantE(GenericEnum Content) : GenericEnumUsingGene /** Generated type representing the anonymous struct variant `VariantF` of the `GenericEnumsUsingStructVariants` Rust enum */ public class GenericEnumsUsingStructVariantsVariantFInner { + [JsonProperty(Required = Required.Always)] public T Action { get; set; } } /** Generated type representing the anonymous struct variant `VariantG` of the `GenericEnumsUsingStructVariants` Rust enum */ public class GenericEnumsUsingStructVariantsVariantGInner { + [JsonProperty(Required = Required.Always)] public T Action { get; set; } + [JsonProperty(Required = Required.Always)] public TU Response { get; set; } } /** Generated type representing the anonymous struct variant `VariantH` of the `GenericEnumsUsingStructVariants` Rust enum */ public class GenericEnumsUsingStructVariantsVariantHInner { + [JsonProperty(Required = Required.Always)] public int NonGeneric { get; set; } } /** Generated type representing the anonymous struct variant `VariantI` of the `GenericEnumsUsingStructVariants` Rust enum */ public class GenericEnumsUsingStructVariantsVariantIInner { + [JsonProperty(Required = Required.Always)] public IEnumerable Vec { get; set; } + [JsonProperty(Required = Required.Always)] public MyType Action { get; set; } } diff --git a/core/data/tests/can_generate_readonly_fields/output.cs b/core/data/tests/can_generate_readonly_fields/output.cs index 585b0e43..881d66ba 100644 --- a/core/data/tests/can_generate_readonly_fields/output.cs +++ b/core/data/tests/can_generate_readonly_fields/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class SomeStruct { + [JsonProperty(Required = Required.Always)] public uint FieldA { get; set; } } diff --git a/core/data/tests/can_generate_simple_struct_with_a_comment/output.cs b/core/data/tests/can_generate_simple_struct_with_a_comment/output.cs index 744de2df..76a6dbd9 100644 --- a/core/data/tests/can_generate_simple_struct_with_a_comment/output.cs +++ b/core/data/tests/can_generate_simple_struct_with_a_comment/output.cs @@ -11,10 +11,14 @@ public class Location { /** This is a comment. */ public class Person { /** This is another comment */ + [JsonProperty(Required = Required.Always)] public string Name { get; set; } + [JsonProperty(Required = Required.Always)] public ushort Age { get; set; } public string? Info { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Emails { get; set; } + [JsonProperty(Required = Required.Always)] public Location Location { get; set; } } diff --git a/core/data/tests/can_generate_slice_of_user_type/output.cs b/core/data/tests/can_generate_slice_of_user_type/output.cs index 8696141c..95de631c 100644 --- a/core/data/tests/can_generate_slice_of_user_type/output.cs +++ b/core/data/tests/can_generate_slice_of_user_type/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class Video { + [JsonProperty(Required = Required.Always)] public IEnumerable Tags { get; set; } } diff --git a/core/data/tests/can_generate_struct_with_skipped_fields/output.cs b/core/data/tests/can_generate_struct_with_skipped_fields/output.cs index a469a34b..da974387 100644 --- a/core/data/tests/can_generate_struct_with_skipped_fields/output.cs +++ b/core/data/tests/can_generate_struct_with_skipped_fields/output.cs @@ -6,7 +6,9 @@ using System.Runtime.Serialization; public class MyStruct { + [JsonProperty(Required = Required.Always)] public int A { get; set; } + [JsonProperty(Required = Required.Always)] public int C { get; set; } } diff --git a/core/data/tests/can_handle_anonymous_struct/output.cs b/core/data/tests/can_handle_anonymous_struct/output.cs index 3ed38536..c93bb1bf 100644 --- a/core/data/tests/can_handle_anonymous_struct/output.cs +++ b/core/data/tests/can_handle_anonymous_struct/output.cs @@ -8,14 +8,17 @@ /** Generated type representing the anonymous struct variant `Us` of the `AutofilledBy` Rust enum */ public class AutofilledByUsInner { /** The UUID for the fill */ + [JsonProperty(Required = Required.Always)] public string Uuid { get; set; } } /** Generated type representing the anonymous struct variant `SomethingElse` of the `AutofilledBy` Rust enum */ public class AutofilledBySomethingElseInner { /** The UUID for the fill */ + [JsonProperty(Required = Required.Always)] public string Uuid { get; set; } /** Some other thing */ + [JsonProperty(Required = Required.Always)] public int Thing { get; set; } } @@ -34,12 +37,15 @@ public record SomethingElse(AutofilledBySomethingElseInner Content): AutofilledB /** Generated type representing the anonymous struct variant `AnonVariant` of the `EnumWithManyVariants` Rust enum */ public class EnumWithManyVariantsAnonVariantInner { + [JsonProperty(Required = Required.Always)] public string Uuid { get; set; } } /** Generated type representing the anonymous struct variant `AnotherAnonVariant` of the `EnumWithManyVariants` Rust enum */ public class EnumWithManyVariantsAnotherAnonVariantInner { + [JsonProperty(Required = Required.Always)] public string Uuid { get; set; } + [JsonProperty(Required = Required.Always)] public int Thing { get; set; } } diff --git a/core/data/tests/can_handle_serde_rename/output.cs b/core/data/tests/can_handle_serde_rename/output.cs index 4d6440d6..4385e58d 100644 --- a/core/data/tests/can_handle_serde_rename/output.cs +++ b/core/data/tests/can_handle_serde_rename/output.cs @@ -10,10 +10,14 @@ public class OtherType { /** This is a comment. */ public class Person { + [JsonProperty(Required = Required.Always)] public string name { get; set; } + [JsonProperty(Required = Required.Always)] public ushort age { get; set; } + [JsonProperty(Required = Required.Always)] public int extraSpecialFieldOne { get; set; } public IEnumerable? extraSpecialFieldTwo { get; set; } + [JsonProperty(Required = Required.Always)] public OtherType nonStandardDataType { get; set; } public IEnumerable? nonStandardDataTypeInArray { get; set; } } diff --git a/core/data/tests/can_handle_serde_rename_all/output.cs b/core/data/tests/can_handle_serde_rename_all/output.cs index 584912f7..1d67137d 100644 --- a/core/data/tests/can_handle_serde_rename_all/output.cs +++ b/core/data/tests/can_handle_serde_rename_all/output.cs @@ -7,17 +7,24 @@ /** This is a Person struct with camelCase rename */ public class Person { + [JsonProperty(Required = Required.Always)] public string firstName { get; set; } + [JsonProperty(Required = Required.Always)] public string lastName { get; set; } + [JsonProperty(Required = Required.Always)] public ushort age { get; set; } + [JsonProperty(Required = Required.Always)] public int extraSpecialField1 { get; set; } public IEnumerable? extraSpecialField2 { get; set; } } /** This is a Person2 struct with UPPERCASE rename */ public class Person2 { + [JsonProperty(Required = Required.Always)] public string FIRST_NAME { get; set; } + [JsonProperty(Required = Required.Always)] public string LAST_NAME { get; set; } + [JsonProperty(Required = Required.Always)] public ushort AGE { get; set; } } diff --git a/core/data/tests/can_handle_serde_rename_on_top_level/output.cs b/core/data/tests/can_handle_serde_rename_on_top_level/output.cs index 1043375d..0fc6b3e8 100644 --- a/core/data/tests/can_handle_serde_rename_on_top_level/output.cs +++ b/core/data/tests/can_handle_serde_rename_on_top_level/output.cs @@ -10,10 +10,14 @@ public class OtherType { /** This is a comment. */ public class PersonTwo { + [JsonProperty(Required = Required.Always)] public string name { get; set; } + [JsonProperty(Required = Required.Always)] public ushort age { get; set; } + [JsonProperty(Required = Required.Always)] public int extraSpecialFieldOne { get; set; } public IEnumerable? extraSpecialFieldTwo { get; set; } + [JsonProperty(Required = Required.Always)] public OtherType nonStandardDataType { get; set; } public IEnumerable? nonStandardDataTypeInArray { get; set; } } diff --git a/core/data/tests/can_override_types/output.cs b/core/data/tests/can_override_types/output.cs index 836a61ca..21c53789 100644 --- a/core/data/tests/can_override_types/output.cs +++ b/core/data/tests/can_override_types/output.cs @@ -6,11 +6,13 @@ using System.Runtime.Serialization; public class OverrideStruct { + [JsonProperty(Required = Required.Always)] public char fieldToOverride { get; set; } } /** Generated type representing the anonymous struct variant `AnonymousStructVariant` of the `OverrideEnum` Rust enum */ public class OverrideEnumAnonymousStructVariantInner { + [JsonProperty(Required = Required.Always)] public char fieldToOverride { get; set; } } diff --git a/core/data/tests/can_recognize_types_inside_modules/output.cs b/core/data/tests/can_recognize_types_inside_modules/output.cs index feacde35..e631b983 100644 --- a/core/data/tests/can_recognize_types_inside_modules/output.cs +++ b/core/data/tests/can_recognize_types_inside_modules/output.cs @@ -6,18 +6,22 @@ using System.Runtime.Serialization; public class A { + [JsonProperty(Required = Required.Always)] public uint Field { get; set; } } public class ABC { + [JsonProperty(Required = Required.Always)] public uint Field { get; set; } } public class AB { + [JsonProperty(Required = Required.Always)] public uint Field { get; set; } } public class OutsideOfModules { + [JsonProperty(Required = Required.Always)] public uint Field { get; set; } } diff --git a/core/data/tests/generate_types/output.cs b/core/data/tests/generate_types/output.cs index 5c93be46..690fdefe 100644 --- a/core/data/tests/generate_types/output.cs +++ b/core/data/tests/generate_types/output.cs @@ -9,15 +9,24 @@ public class CustomType { } public class Types { + [JsonProperty(Required = Required.Always)] public string S { get; set; } + [JsonProperty(Required = Required.Always)] public string StaticS { get; set; } + [JsonProperty(Required = Required.Always)] public short Int8 { get; set; } + [JsonProperty(Required = Required.Always)] public float Float { get; set; } + [JsonProperty(Required = Required.Always)] public double Double { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Array { get; set; } + [JsonProperty(Required = Required.Always)] public string[] FixedLengthArray { get; set; } + [JsonProperty(Required = Required.Always)] public IDictionary Dictionary { get; set; } public IDictionary? OptionalDictionary { get; set; } + [JsonProperty(Required = Required.Always)] public CustomType CustomType { get; set; } } diff --git a/core/data/tests/kebab_case_rename/output.cs b/core/data/tests/kebab_case_rename/output.cs index b79628e0..2652b7c4 100644 --- a/core/data/tests/kebab_case_rename/output.cs +++ b/core/data/tests/kebab_case_rename/output.cs @@ -7,6 +7,7 @@ /** This is a comment. */ public class Things { + [JsonProperty(Required = Required.Always)] public string bla { get; set; } public string? label { get; set; } public string? label-left { get; set; } diff --git a/core/data/tests/recursive_enum_decorator/output.cs b/core/data/tests/recursive_enum_decorator/output.cs index f309cdaf..a3e581e0 100644 --- a/core/data/tests/recursive_enum_decorator/output.cs +++ b/core/data/tests/recursive_enum_decorator/output.cs @@ -19,11 +19,13 @@ public record Vermont(Options Content) : Options(); /** Generated type representing the anonymous struct variant `Exactly` of the `MoreOptions` Rust enum */ public class MoreOptionsExactlyInner { + [JsonProperty(Required = Required.Always)] public string Config { get; set; } } /** Generated type representing the anonymous struct variant `Built` of the `MoreOptions` Rust enum */ public class MoreOptionsBuiltInner { + [JsonProperty(Required = Required.Always)] public MoreOptions Top { get; set; } } diff --git a/core/data/tests/resolves_qualified_type/output.cs b/core/data/tests/resolves_qualified_type/output.cs index 1fb82657..ad1f9cd1 100644 --- a/core/data/tests/resolves_qualified_type/output.cs +++ b/core/data/tests/resolves_qualified_type/output.cs @@ -6,9 +6,13 @@ using System.Runtime.Serialization; public class QualifiedTypes { + [JsonProperty(Required = Required.Always)] public string Unqualified { get; set; } + [JsonProperty(Required = Required.Always)] public string Qualified { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable QualifiedVec { get; set; } + [JsonProperty(Required = Required.Always)] public IDictionary QualifiedHashmap { get; set; } public string? QualifiedOptional { get; set; } public IDictionary>? QualfiedOptionalHashmapVec { get; set; } diff --git a/core/data/tests/serialize_field_as/output.cs b/core/data/tests/serialize_field_as/output.cs index 038a5506..048d0178 100644 --- a/core/data/tests/serialize_field_as/output.cs +++ b/core/data/tests/serialize_field_as/output.cs @@ -6,7 +6,9 @@ using System.Runtime.Serialization; public class EditItemViewModelSaveRequest { + [JsonProperty(Required = Required.Always)] public string Context { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Values { get; set; } public AutoFillItemActionRequest? FillAction { get; set; } } diff --git a/core/data/tests/smart_pointers/output.cs b/core/data/tests/smart_pointers/output.cs index b3e8470f..23e0a027 100644 --- a/core/data/tests/smart_pointers/output.cs +++ b/core/data/tests/smart_pointers/output.cs @@ -7,37 +7,49 @@ /** This is a comment. */ public class ArcyColors { + [JsonProperty(Required = Required.Always)] public ushort Red { get; set; } + [JsonProperty(Required = Required.Always)] public string Blue { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Green { get; set; } } /** This is a comment. */ public class MutexyColors { + [JsonProperty(Required = Required.Always)] public IEnumerable Blue { get; set; } + [JsonProperty(Required = Required.Always)] public string Green { get; set; } } /** This is a comment. */ public class RcyColors { + [JsonProperty(Required = Required.Always)] public string Red { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Blue { get; set; } + [JsonProperty(Required = Required.Always)] public string Green { get; set; } } /** This is a comment. */ public class CellyColors { + [JsonProperty(Required = Required.Always)] public string Red { get; set; } + [JsonProperty(Required = Required.Always)] public IEnumerable Blue { get; set; } } /** This is a comment. */ public class LockyColors { + [JsonProperty(Required = Required.Always)] public string Red { get; set; } } /** This is a comment. */ public class CowyColors { + [JsonProperty(Required = Required.Always)] public string Lifetime { get; set; } } diff --git a/core/data/tests/test_generate_char/output.cs b/core/data/tests/test_generate_char/output.cs index cb2c1677..83c000b1 100644 --- a/core/data/tests/test_generate_char/output.cs +++ b/core/data/tests/test_generate_char/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class MyType { + [JsonProperty(Required = Required.Always)] public char Field { get; set; } } diff --git a/core/data/tests/test_i54_u53_type/output.cs b/core/data/tests/test_i54_u53_type/output.cs index de49db18..fd0defaa 100644 --- a/core/data/tests/test_i54_u53_type/output.cs +++ b/core/data/tests/test_i54_u53_type/output.cs @@ -6,7 +6,9 @@ using System.Runtime.Serialization; public class Foo { + [JsonProperty(Required = Required.Always)] public long A { get; set; } + [JsonProperty(Required = Required.Always)] public ulong B { get; set; } } diff --git a/core/data/tests/test_serde_iso8601/output.cs b/core/data/tests/test_serde_iso8601/output.cs index 0a8c5123..5bbe3772 100644 --- a/core/data/tests/test_serde_iso8601/output.cs +++ b/core/data/tests/test_serde_iso8601/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class Foo { + [JsonProperty(Required = Required.Always)] public string Time { get; set; } } diff --git a/core/data/tests/test_serde_url/output.cs b/core/data/tests/test_serde_url/output.cs index dde28904..4b1f3f64 100644 --- a/core/data/tests/test_serde_url/output.cs +++ b/core/data/tests/test_serde_url/output.cs @@ -6,6 +6,7 @@ using System.Runtime.Serialization; public class Foo { + [JsonProperty(Required = Required.Always)] public string Url { get; set; } } diff --git a/core/data/tests/use_correct_integer_types/output.cs b/core/data/tests/use_correct_integer_types/output.cs index 3ba7c226..eb0690b6 100644 --- a/core/data/tests/use_correct_integer_types/output.cs +++ b/core/data/tests/use_correct_integer_types/output.cs @@ -7,11 +7,17 @@ /** This is a comment. */ public class Foo { + [JsonProperty(Required = Required.Always)] public short A { get; set; } + [JsonProperty(Required = Required.Always)] public short B { get; set; } + [JsonProperty(Required = Required.Always)] public int C { get; set; } + [JsonProperty(Required = Required.Always)] public ushort E { get; set; } + [JsonProperty(Required = Required.Always)] public ushort F { get; set; } + [JsonProperty(Required = Required.Always)] public uint G { get; set; } } diff --git a/core/tests/snapshot_tests.rs b/core/tests/snapshot_tests.rs index b08fbc0a..360fd3a1 100644 --- a/core/tests/snapshot_tests.rs +++ b/core/tests/snapshot_tests.rs @@ -642,7 +642,7 @@ tests! { const_enum_decorator: [ swift{ prefix: "OP".to_string(), } ]; algebraic_enum_decorator: [ swift{ prefix: "OP".to_string(), } ]; struct_decorator: [ kotlin, swift{ prefix: "OP".to_string(), } ]; - serialize_field_as: [kotlin, swift, typescript, scala, go]; + serialize_field_as: [kotlin, swift, typescript, scala, go, csharp]; serialize_type_alias: [kotlin, swift, typescript, scala, go]; serialize_anonymous_field_as: [kotlin, swift, typescript, scala, go, csharp]; smart_pointers: [kotlin, swift, typescript, scala, go, csharp];