|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | - |
4 | 1 | namespace MemoryPack.Tests.Models; |
5 | 2 |
|
6 | | -enum TestEnum |
7 | | -{ |
8 | | - A, B, C |
9 | | -} |
10 | | - |
11 | 3 | [MemoryPackable] |
12 | 4 | partial class DefaultValuePlaceholder |
13 | 5 | { |
14 | 6 | public int X { get; set; } |
15 | 7 | } |
16 | 8 |
|
17 | | -[MemoryPackable] |
18 | | -partial class FieldDefaultValue |
| 9 | +[MemoryPackable(GenerateType.VersionTolerant, SerializeLayout.Sequential)] |
| 10 | +partial class DefaultValuePlaceholderWithVersionTolerant |
19 | 11 | { |
20 | | - public int X; |
21 | | - public int Y = 12345; |
22 | | - public float Z = 678.9f; |
23 | | - public string S = "aaaaaaaaa"; |
24 | | - public bool B = true; |
| 12 | + public int X { get; set; } |
25 | 13 | } |
26 | 14 |
|
27 | | -[MemoryPackable] |
28 | | -partial class PropertyDefaultValue |
| 15 | +[MemoryPackable(GenerateType.VersionTolerant, SerializeLayout.Sequential)] |
| 16 | +partial class HasDefaultValueWithVersionTolerant |
29 | 17 | { |
30 | | - internal enum NestedEnum |
31 | | - { |
32 | | - A, B |
33 | | - } |
| 18 | + public int X; |
34 | 19 |
|
35 | | - public int X { get; set; } |
36 | | - public int Y { get; set; } = 12345; |
| 20 | + public int Y = 12345; |
37 | 21 | public float Z { get; set; } = 678.9f; |
38 | | - public string S { get; set; } = "aaaaaaaaa"; |
39 | | - public bool B { get; set; } = true; |
40 | | - public List<string> Alpha { get; set; } = new List<string>(new HashSet<string>()); |
41 | | - public TestEnum E { get; set; } = TestEnum.A; |
42 | | - public NestedEnum E2 { get; set; } = NestedEnum.A; |
43 | | - public (TestEnum, List<string>) Tuple { get; set; } = (TestEnum.A, new List<string>(new HashSet<string>())); |
44 | | - public DateTime Struct { get; set; } = default!; |
| 22 | + |
| 23 | + [SuppressDefaultInitialization] |
| 24 | + public int Y2 = 12345; |
| 25 | + |
| 26 | + [SuppressDefaultInitialization] |
| 27 | + public float Z2 { get; set; } = 678.9f; |
45 | 28 | } |
46 | 29 |
|
47 | 30 | [MemoryPackable] |
48 | | -partial class CtorParamDefaultValue |
| 31 | +partial class HasDefaultValue |
49 | 32 | { |
50 | 33 | public int X; |
51 | | - public int Y; |
52 | | - public float Z; |
53 | | - public string S; |
54 | | - public bool B; |
55 | | - public decimal D; |
56 | | - public DateTime StructValue; |
57 | 34 |
|
58 | | - [MemoryPackConstructor] |
59 | | - public CtorParamDefaultValue(int x, int y = 12345, float z = 678.9f, string s = "aaaaaa", bool b = true, decimal d = 99M, DateTime structValue = default) |
60 | | - { |
61 | | - X = x; |
62 | | - Y = y; |
63 | | - Z = z; |
64 | | - S = s; |
65 | | - B = b; |
66 | | - D = d; |
67 | | - StructValue = structValue; |
68 | | - } |
| 35 | + public int Y = 12345; |
| 36 | + public float Z { get; set; } = 678.9f; |
| 37 | + |
| 38 | + [SuppressDefaultInitialization] |
| 39 | + public int Y2 = 12345; |
| 40 | + |
| 41 | + [SuppressDefaultInitialization] |
| 42 | + public float Z2 { get; set; } = 678.9f; |
69 | 43 | } |
0 commit comments