Skip to content

Commit 151efb2

Browse files
committed
Change to use nullable reference types
1 parent 3fea483 commit 151efb2

File tree

6 files changed

+34
-33
lines changed

6 files changed

+34
-33
lines changed

Test.ServiceModel/CodeGenTestTypes.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ public class ArrayResult
5454

5555
public class HelloList : IReturn<List<ListResult>>
5656
{
57-
public List<string> Names { get; set; }
57+
public List<string> Names { get; set; } = [];
5858
}
5959

6060
public class HelloArray : IReturn<ArrayResult[]>
6161
{
62-
public List<string> Names { get; set; }
62+
public List<string> Names { get; set; } = [];
6363
}
6464

6565
public class HelloMap : IReturn<Dictionary<string,ArrayResult>>
6666
{
67-
public List<string> Names { get; set; }
67+
public List<string> Names { get; set; } = [];
6868
}
6969

7070
public class HelloQueryResponse : IReturn<QueryResponse<string>>
7171
{
72-
public List<string> Names { get; set; }
72+
public List<string> Names { get; set; } = [];
7373
}
7474

7575
public class HelloWithEnum

Test.ServiceModel/GetRandomIds.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public class GetRandomIds
1111

1212
public class GetRandomIdsResponse
1313
{
14-
public List<string> Results { get; set; }
14+
public List<string> Results { get; set; } = [];
1515
}

Test.ServiceModel/ReturnData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ public class ReturnString : IReturn<string>
1313
[Route("/return/bytes")]
1414
public class ReturnBytes : IReturn<byte[]>
1515
{
16-
public byte[] Data { get; set; }
16+
public byte[] Data { get; set; } = [];
1717
}
1818

1919
[Route("/return/stream")]
2020
public class ReturnStream : IReturn<Stream>
2121
{
22-
public byte[] Data { get; set; }
22+
public byte[] Data { get; set; } = [];
2323
}
2424

2525
[Route("/return/httpwebresponse")]
2626
public class ReturnHttpWebResponse : IReturn<HttpWebResponse>
2727
{
28-
public byte[] Data { get; set; }
28+
public byte[] Data { get; set; } = [];
2929
}
3030

3131
[Route("/return/json")]

Test.ServiceModel/StoreLogs.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ namespace Test.ServiceModel;
55

66
public class StoreLogs
77
{
8-
public List<Logger> Loggers { get; set; }
8+
public List<Logger> Loggers { get; set; } = [];
99
}
1010

1111
public class StoreLogsResponse
1212
{
13-
public List<Logger> ExistingLogs { get; set; }
13+
public List<Logger> ExistingLogs { get; set; } = [];
1414

1515
public ResponseStatus ResponseStatus { get; set; }
1616
}
1717

1818
public class Logger
1919
{
2020
public long Id { get; set; }
21-
public List<Device> Devices { get; set; }
21+
public List<Device> Devices { get; set; } = [];
2222
}
2323

2424
public class Device
2525
{
2626
public long Id { get; set; }
2727
public string Type { get; set; }
2828
public long TimeStamp { get; set; }
29-
public List<Channel> Channels { get; set; }
29+
public List<Channel> Channels { get; set; } = [];
3030
}
3131

3232
public class Channel

Test.ServiceModel/Test.ServiceModel.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
56
</PropertyGroup>
67

78
<ItemGroup>

Test.ServiceModel/Types/AllTypes.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public abstract class AllTypesBase
3636
public KeyValuePair<string, string> KeyValuePair { get; set; }
3737
public DateTime? NullableDateTime { get; set; }
3838
public TimeSpan? NullableTimeSpan { get; set; }
39-
public List<string> StringList { get; set; }
40-
public string[] StringArray { get; set; }
41-
public Dictionary<string, string> StringMap { get; set; }
42-
public Dictionary<int, string> IntStringMap { get; set; }
39+
public List<string> StringList { get; set; } = [];
40+
public string[] StringArray { get; set; } = [];
41+
public Dictionary<string, string> StringMap { get; set; } = new();
42+
public Dictionary<int, string> IntStringMap { get; set; } = new();
4343
public SubType SubType { get; set; }
4444
}
4545

@@ -66,33 +66,33 @@ public class AllTypes : IReturn<AllTypes>
6666
public KeyValuePair<string, string> KeyValuePair { get; set; }
6767
public DateTime? NullableDateTime { get; set; }
6868
public TimeSpan? NullableTimeSpan { get; set; }
69-
public List<string> StringList { get; set; }
70-
public string[] StringArray { get; set; }
71-
public Dictionary<string, string> StringMap { get; set; }
72-
public Dictionary<int, string> IntStringMap { get; set; }
69+
public List<string> StringList { get; set; } = [];
70+
public string[] StringArray { get; set; } = [];
71+
public Dictionary<string, string> StringMap { get; set; } = new();
72+
public Dictionary<int, string> IntStringMap { get; set; } = new();
7373
public SubType SubType { get; set; }
7474
}
7575

7676
public class AllCollectionTypes : IReturn<AllCollectionTypes>
7777
{
78-
public int[] IntArray { get; set; }
79-
public List<int> IntList { get; set; }
78+
public int[] IntArray { get; set; } = [];
79+
public List<int> IntList { get; set; } = [];
8080

81-
public string[] StringArray { get; set; }
82-
public List<string> StringList { get; set; }
81+
public string[] StringArray { get; set; } = [];
82+
public List<string> StringList { get; set; } = [];
8383

84-
public float[] FloatArray { get; set; }
85-
public List<double> DoubleList { get; set; }
84+
public float[] FloatArray { get; set; } = [];
85+
public List<double> DoubleList { get; set; } = [];
8686

87-
public byte[] ByteArray { get; set; }
88-
public char[] CharArray { get; set; }
89-
public List<decimal> DecimalList { get; set; }
87+
public byte[] ByteArray { get; set; } = [];
88+
public char[] CharArray { get; set; } = [];
89+
public List<decimal> DecimalList { get; set; } = [];
9090

91-
public Poco[] PocoArray { get; set; }
92-
public List<Poco> PocoList { get; set; }
91+
public Poco[] PocoArray { get; set; } = [];
92+
public List<Poco> PocoList { get; set; } = [];
9393

94-
public Dictionary<string, List<Poco>> PocoLookup { get; set; }
95-
public Dictionary<string, List<Dictionary<string, Poco>>> PocoLookupMap { get; set; }
94+
public Dictionary<string, List<Poco>> PocoLookup { get; set; } = new();
95+
public Dictionary<string, List<Dictionary<string, Poco>>> PocoLookupMap { get; set; } = new();
9696
}
9797

9898
public class Poco

0 commit comments

Comments
 (0)