Skip to content

Commit 84cc228

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 796173c + 4b6cc17 commit 84cc228

392 files changed

Lines changed: 10433 additions & 1261 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/libs/V0/Generated/V0.AllOf.2.g.cs

Lines changed: 80 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace V0
66
/// <summary>
77
///
88
/// </summary>
9-
public readonly partial struct AllOf<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T1, [global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] T2> : global::System.IEquatable<AllOf<T1, T2>>
9+
public readonly partial struct AllOf<T1, T2> : global::System.IEquatable<AllOf<T1, T2>>
1010
{
1111
/// <summary>
1212
///
@@ -25,6 +25,26 @@ namespace V0
2525
#endif
2626
public bool IsValue1 => Value1 != null;
2727

28+
/// <summary>
29+
///
30+
/// </summary>
31+
public bool TryPickValue1(
32+
#if NET6_0_OR_GREATER
33+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
34+
#endif
35+
out T1? value)
36+
{
37+
value = Value1;
38+
return IsValue1;
39+
}
40+
41+
/// <summary>
42+
///
43+
/// </summary>
44+
public T1 PickValue1() => IsValue1
45+
? Value1!
46+
: throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}.");
47+
2848
/// <summary>
2949
///
3050
/// </summary>
@@ -41,6 +61,26 @@ namespace V0
4161
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))]
4262
#endif
4363
public bool IsValue2 => Value2 != null;
64+
65+
/// <summary>
66+
///
67+
/// </summary>
68+
public bool TryPickValue2(
69+
#if NET6_0_OR_GREATER
70+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
71+
#endif
72+
out T2? value)
73+
{
74+
value = Value2;
75+
return IsValue2;
76+
}
77+
78+
/// <summary>
79+
///
80+
/// </summary>
81+
public T2 PickValue2() => IsValue2
82+
? Value2!
83+
: throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}.");
4484
/// <summary>
4585
///
4686
/// </summary>
@@ -59,6 +99,11 @@ public AllOf(T1? value)
5999
Value1 = value;
60100
}
61101

102+
/// <summary>
103+
///
104+
/// </summary>
105+
public static AllOf<T1, T2> FromValue1(T1? value) => new AllOf<T1, T2>(value);
106+
62107
/// <summary>
63108
///
64109
/// </summary>
@@ -77,6 +122,11 @@ public AllOf(T2? value)
77122
Value2 = value;
78123
}
79124

125+
/// <summary>
126+
///
127+
/// </summary>
128+
public static AllOf<T1, T2> FromValue2(T2? value) => new AllOf<T1, T2>(value);
129+
80130
/// <summary>
81131
///
82132
/// </summary>
@@ -105,42 +155,17 @@ Value1 as object
105155
Value2?.ToString()
106156
;
107157

108-
private static bool RequiresValue<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] TValue>() => RequirementCache<TValue>.Value;
109-
110-
private static bool DetermineRequiresValue([global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] global::System.Type type)
158+
private static bool RequiresValue<TValue>()
111159
{
160+
var type = typeof(TValue);
112161
if (global::System.Nullable.GetUnderlyingType(type) != null)
113162
{
114163
return false;
115164
}
116165

117-
if (type.IsValueType ||
118-
type == typeof(string) ||
119-
type.IsArray)
120-
{
121-
return true;
122-
}
123-
124-
foreach (var property in type.GetProperties(global::System.Reflection.BindingFlags.Instance | global::System.Reflection.BindingFlags.Public))
125-
{
126-
foreach (var attributeData in property.CustomAttributes)
127-
{
128-
var attributeTypeName = attributeData.AttributeType.FullName;
129-
if (attributeTypeName == "System.Text.Json.Serialization.JsonRequiredAttribute" ||
130-
attributeTypeName == "Newtonsoft.Json.JsonRequiredAttribute" ||
131-
attributeTypeName == "System.Runtime.CompilerServices.RequiredMemberAttribute")
132-
{
133-
return true;
134-
}
135-
}
136-
}
137-
138-
return false;
139-
}
140-
141-
private static class RequirementCache<[global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(global::System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicProperties)] TValue>
142-
{
143-
public static readonly bool Value = DetermineRequiresValue(typeof(TValue));
166+
return type.IsValueType ||
167+
type == typeof(string) ||
168+
type.IsArray;
144169
}
145170

146171

@@ -182,6 +207,30 @@ public bool Validate()
182207
/// </summary>
183208
public void Match(
184209
global::System.Action<T1>? value1 = null,
210+
211+
global::System.Action<T2>? value2 = null,
212+
bool validate = true)
213+
{
214+
if (validate)
215+
{
216+
Validate();
217+
}
218+
219+
if (IsValue1)
220+
{
221+
value1?.Invoke(Value1!);
222+
}
223+
else if (IsValue2)
224+
{
225+
value2?.Invoke(Value2!);
226+
}
227+
}
228+
229+
/// <summary>
230+
///
231+
/// </summary>
232+
public void Switch(
233+
global::System.Action<T1>? value1 = null,
185234
global::System.Action<T2>? value2 = null,
186235
bool validate = true)
187236
{

src/libs/V0/Generated/V0.AnyOf.2.g.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ namespace V0
2525
#endif
2626
public bool IsValue1 => Value1 != null;
2727

28+
/// <summary>
29+
///
30+
/// </summary>
31+
public bool TryPickValue1(
32+
#if NET6_0_OR_GREATER
33+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
34+
#endif
35+
out T1? value)
36+
{
37+
value = Value1;
38+
return IsValue1;
39+
}
40+
41+
/// <summary>
42+
///
43+
/// </summary>
44+
public T1 PickValue1() => IsValue1
45+
? Value1!
46+
: throw new global::System.InvalidOperationException($"Expected union variant 'Value1' but the value was {ToString()}.");
47+
2848
/// <summary>
2949
///
3050
/// </summary>
@@ -41,6 +61,26 @@ namespace V0
4161
[global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Value2))]
4262
#endif
4363
public bool IsValue2 => Value2 != null;
64+
65+
/// <summary>
66+
///
67+
/// </summary>
68+
public bool TryPickValue2(
69+
#if NET6_0_OR_GREATER
70+
[global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)]
71+
#endif
72+
out T2? value)
73+
{
74+
value = Value2;
75+
return IsValue2;
76+
}
77+
78+
/// <summary>
79+
///
80+
/// </summary>
81+
public T2 PickValue2() => IsValue2
82+
? Value2!
83+
: throw new global::System.InvalidOperationException($"Expected union variant 'Value2' but the value was {ToString()}.");
4484
/// <summary>
4585
///
4686
/// </summary>
@@ -59,6 +99,11 @@ public AnyOf(T1? value)
5999
Value1 = value;
60100
}
61101

102+
/// <summary>
103+
///
104+
/// </summary>
105+
public static AnyOf<T1, T2> FromValue1(T1? value) => new AnyOf<T1, T2>(value);
106+
62107
/// <summary>
63108
///
64109
/// </summary>
@@ -77,6 +122,11 @@ public AnyOf(T2? value)
77122
Value2 = value;
78123
}
79124

125+
/// <summary>
126+
///
127+
/// </summary>
128+
public static AnyOf<T1, T2> FromValue2(T2? value) => new AnyOf<T1, T2>(value);
129+
80130
/// <summary>
81131
///
82132
/// </summary>
@@ -143,6 +193,30 @@ public bool Validate()
143193
/// </summary>
144194
public void Match(
145195
global::System.Action<T1>? value1 = null,
196+
197+
global::System.Action<T2>? value2 = null,
198+
bool validate = true)
199+
{
200+
if (validate)
201+
{
202+
Validate();
203+
}
204+
205+
if (IsValue1)
206+
{
207+
value1?.Invoke(Value1!);
208+
}
209+
else if (IsValue2)
210+
{
211+
value2?.Invoke(Value2!);
212+
}
213+
}
214+
215+
/// <summary>
216+
///
217+
/// </summary>
218+
public void Switch(
219+
global::System.Action<T1>? value1 = null,
146220
global::System.Action<T2>? value2 = null,
147221
bool validate = true)
148222
{

0 commit comments

Comments
 (0)