From 8dfc8fe9b8e2efe1c67b5a2f9461e2295ae409df Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Sat, 13 Aug 2022 15:05:08 -0700 Subject: [PATCH] ... --- .../Test_10_SETTINGS_IMMUTABLE_CLASSES.cs | 1 + ...t_10_SETTINGS_IMMUTABLE_CLASSES_OUTPUT.txt | 36 +++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES.cs b/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES.cs index 00831c8..58106ee 100644 --- a/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES.cs +++ b/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES.cs @@ -17,6 +17,7 @@ public class Test_10_SETTINGS_IMMUTABLE_CLASSES JsonClassGenerator jsonClassGenerator = new() { CodeWriter = new CSharpCodeWriter(), + CollectionType = OutputCollectionType.IReadOnlyList, OutputType = OutputTypes.ImmutableClass, UseThisKeyWord = true, AttributeLibrary = JsonLibrary.NewtonsoftJson, diff --git a/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES_OUTPUT.txt b/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES_OUTPUT.txt index 7645fe1..8a0e8be 100644 --- a/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES_OUTPUT.txt +++ b/Json2CSharpCodeGenerator.Tests/Test_10_SETTINGS_IMMUTABLE_CLASSES_OUTPUT.txt @@ -13,10 +13,10 @@ } [JsonProperty("SomeProps1")] - public int SomeProps1 { get; } + public int SomeProps1 { init; get; } [JsonProperty("SomeProps2")] - public string SomeProps2 { get; } + public string SomeProps2 { init; get; } } public class Class1 @@ -28,7 +28,7 @@ [JsonProperty("awesomeobject")] Awesomeobject awesomeobject, [JsonProperty("created_at")] string createdAt, [JsonProperty("updated_at")] string updatedAt, - [JsonProperty("users")] List users + [JsonProperty("users")] IReadOnlyList users ) { this.Id = id; @@ -40,22 +40,22 @@ } [JsonProperty("id")] - public int Id { get; } + public int Id { init; get; } [JsonProperty("user_id")] - public string UserId { get; } + public string UserId { init; get; } [JsonProperty("awesomeobject")] - public Awesomeobject Awesomeobject { get; } + public Awesomeobject Awesomeobject { init; get; } [JsonProperty("created_at")] - public string CreatedAt { get; } + public string CreatedAt { init; get; } [JsonProperty("updated_at")] - public string UpdatedAt { get; } + public string UpdatedAt { init; get; } [JsonProperty("users")] - public IReadOnlyList Users { get; } + public IReadOnlyList Users { init; get; } } public class Class2 @@ -69,7 +69,7 @@ } [JsonProperty("SomePropertyOfClass2")] - public string SomePropertyOfClass2 { get; } + public string SomePropertyOfClass2 { init; get; } } public class Root @@ -85,10 +85,10 @@ } [JsonProperty("Class1")] - public Class1 Class1 { get; } + public Class1 Class1 { init; get; } [JsonProperty("Class2")] - public Class2 Class2 { get; } + public Class2 Class2 { init; get; } } @@ -114,21 +114,21 @@ } [JsonProperty("id")] - public string Id { get; } + public string Id { init; get; } [JsonProperty("name")] - public string Name { get; } + public string Name { init; get; } [JsonProperty("created_at")] - public string CreatedAt { get; } + public string CreatedAt { init; get; } [JsonProperty("updated_at")] - public string UpdatedAt { get; } + public string UpdatedAt { init; get; } [JsonProperty("email")] - public string Email { get; } + public string Email { init; get; } [JsonProperty("testanadditionalfield")] - public string Testanadditionalfield { get; } + public string Testanadditionalfield { init; get; } }