diff --git a/Generator/Program.cs b/Generator/Program.cs index 4f04e2b..6353e14 100644 --- a/Generator/Program.cs +++ b/Generator/Program.cs @@ -39,6 +39,9 @@ string GetContent(bool isStruct, int i) { sb.Append(@$"using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf {{ @@ -100,6 +103,19 @@ public void Switch({RangeJoined(", ", e => $"Action f{e}")}) throw new InvalidOperationException(); }} +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync({RangeJoined(", ", e => $"Func f{e}")}) + {{ + {RangeJoined(@" + ", j => @$"if (_index == {j} && f{j} != null) + {{ + await f{j}(_value{j}); + return; + }}")} + throw new InvalidOperationException(); + }} +#endif + public TResult Match({RangeJoined(", ", e => $"Func f{e}")}) {{ {RangeJoined(@" @@ -110,6 +126,18 @@ public TResult Match({RangeJoined(", ", e => $"Func f{e} throw new InvalidOperationException(); }} +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task MatchAsync({RangeJoined(", ", e => $"Func> f{e}")}) + {{ + {RangeJoined(@" + ", j => $@"if (_index == {j} && f{j} != null) + {{ + return await f{j}(_value{j}); + }}")} + throw new InvalidOperationException(); + }} +#endif + {IfStruct(genericArgs.Joined(@" ", bindToType => $@"public static OneOf<{genericArgs.Joined(", ")}> From{bindToType}({bindToType} input) => input;"))} @@ -134,7 +162,26 @@ public TResult Match({RangeJoined(", ", e => $"Func f{e} $"{k} => As{x},")} _ => throw new InvalidOperationException() }}; - }}"; + }} + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> Map{bindToType}Async(Func<{bindToType}, Task> mapFunc) + {{ + if (mapFunc == null) + {{ + throw new ArgumentNullException(nameof(mapFunc)); + }} + return _index switch + {{ + {genericArgs.Joined(@" + ", (x, k) => + x == bindToType ? + $"{k} => await mapFunc(As{x})," : + $"{k} => As{x},")} + _ => throw new InvalidOperationException() + }}; + }} +#endif"; }))} "); diff --git a/OneOf.Extended/OneOfBaseT10.generated.cs b/OneOf.Extended/OneOfBaseT10.generated.cs index 3c61780..bc7c867 100644 --- a/OneOf.Extended/OneOfBaseT10.generated.cs +++ b/OneOf.Extended/OneOfBaseT10.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -176,6 +179,68 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10) { if (_index == 0 && f0 != null) @@ -225,6 +290,57 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT11.generated.cs b/OneOf.Extended/OneOfBaseT11.generated.cs index cc72a59..ea6ccdb 100644 --- a/OneOf.Extended/OneOfBaseT11.generated.cs +++ b/OneOf.Extended/OneOfBaseT11.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -189,6 +192,73 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11) { if (_index == 0 && f0 != null) @@ -242,6 +312,61 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT12.generated.cs b/OneOf.Extended/OneOfBaseT12.generated.cs index 7b9c66d..b3e4a5c 100644 --- a/OneOf.Extended/OneOfBaseT12.generated.cs +++ b/OneOf.Extended/OneOfBaseT12.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -202,6 +205,78 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12) { if (_index == 0 && f0 != null) @@ -259,6 +334,65 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT13.generated.cs b/OneOf.Extended/OneOfBaseT13.generated.cs index ccf0cd7..e8f4b7a 100644 --- a/OneOf.Extended/OneOfBaseT13.generated.cs +++ b/OneOf.Extended/OneOfBaseT13.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -215,6 +218,83 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13) { if (_index == 0 && f0 != null) @@ -276,6 +356,69 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT14.generated.cs b/OneOf.Extended/OneOfBaseT14.generated.cs index cade467..3b38b92 100644 --- a/OneOf.Extended/OneOfBaseT14.generated.cs +++ b/OneOf.Extended/OneOfBaseT14.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -228,6 +231,88 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14) { if (_index == 0 && f0 != null) @@ -293,6 +378,73 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT15.generated.cs b/OneOf.Extended/OneOfBaseT15.generated.cs index 05132d2..9d737c5 100644 --- a/OneOf.Extended/OneOfBaseT15.generated.cs +++ b/OneOf.Extended/OneOfBaseT15.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -241,6 +244,93 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15) { if (_index == 0 && f0 != null) @@ -310,6 +400,77 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT16.generated.cs b/OneOf.Extended/OneOfBaseT16.generated.cs index d59e70a..d05dbcd 100644 --- a/OneOf.Extended/OneOfBaseT16.generated.cs +++ b/OneOf.Extended/OneOfBaseT16.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -254,6 +257,98 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16) { if (_index == 0 && f0 != null) @@ -327,6 +422,81 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT17.generated.cs b/OneOf.Extended/OneOfBaseT17.generated.cs index b50d501..9f69d54 100644 --- a/OneOf.Extended/OneOfBaseT17.generated.cs +++ b/OneOf.Extended/OneOfBaseT17.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -267,6 +270,103 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17) { if (_index == 0 && f0 != null) @@ -344,6 +444,85 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT18.generated.cs b/OneOf.Extended/OneOfBaseT18.generated.cs index 9749b93..e4139df 100644 --- a/OneOf.Extended/OneOfBaseT18.generated.cs +++ b/OneOf.Extended/OneOfBaseT18.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -280,6 +283,108 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18) { if (_index == 0 && f0 != null) @@ -361,6 +466,89 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT19.generated.cs b/OneOf.Extended/OneOfBaseT19.generated.cs index 76a2c60..2d3962a 100644 --- a/OneOf.Extended/OneOfBaseT19.generated.cs +++ b/OneOf.Extended/OneOfBaseT19.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -293,6 +296,113 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19) { if (_index == 0 && f0 != null) @@ -378,6 +488,93 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT20.generated.cs b/OneOf.Extended/OneOfBaseT20.generated.cs index 7f69d8f..7eac361 100644 --- a/OneOf.Extended/OneOfBaseT20.generated.cs +++ b/OneOf.Extended/OneOfBaseT20.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -306,6 +309,118 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20) { if (_index == 0 && f0 != null) @@ -395,6 +510,97 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT21.generated.cs b/OneOf.Extended/OneOfBaseT21.generated.cs index a6b02ee..02eb4b8 100644 --- a/OneOf.Extended/OneOfBaseT21.generated.cs +++ b/OneOf.Extended/OneOfBaseT21.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -319,6 +322,123 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21) { if (_index == 0 && f0 != null) @@ -412,6 +532,101 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT22.generated.cs b/OneOf.Extended/OneOfBaseT22.generated.cs index daca4ef..fb9d05c 100644 --- a/OneOf.Extended/OneOfBaseT22.generated.cs +++ b/OneOf.Extended/OneOfBaseT22.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -332,6 +335,128 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22) { if (_index == 0 && f0 != null) @@ -429,6 +554,105 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT23.generated.cs b/OneOf.Extended/OneOfBaseT23.generated.cs index 78a26b5..df3ee13 100644 --- a/OneOf.Extended/OneOfBaseT23.generated.cs +++ b/OneOf.Extended/OneOfBaseT23.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -345,6 +348,133 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23) { if (_index == 0 && f0 != null) @@ -446,6 +576,109 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT24.generated.cs b/OneOf.Extended/OneOfBaseT24.generated.cs index c291a10..d9af976 100644 --- a/OneOf.Extended/OneOfBaseT24.generated.cs +++ b/OneOf.Extended/OneOfBaseT24.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -358,6 +361,138 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24) { if (_index == 0 && f0 != null) @@ -463,6 +598,113 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT25.generated.cs b/OneOf.Extended/OneOfBaseT25.generated.cs index dc06dc9..3a47eb8 100644 --- a/OneOf.Extended/OneOfBaseT25.generated.cs +++ b/OneOf.Extended/OneOfBaseT25.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -371,6 +374,143 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25) { if (_index == 0 && f0 != null) @@ -480,6 +620,117 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT26.generated.cs b/OneOf.Extended/OneOfBaseT26.generated.cs index edd010b..6086a24 100644 --- a/OneOf.Extended/OneOfBaseT26.generated.cs +++ b/OneOf.Extended/OneOfBaseT26.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -384,6 +387,148 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26) { if (_index == 0 && f0 != null) @@ -497,6 +642,121 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT27.generated.cs b/OneOf.Extended/OneOfBaseT27.generated.cs index ae54cde..7171b71 100644 --- a/OneOf.Extended/OneOfBaseT27.generated.cs +++ b/OneOf.Extended/OneOfBaseT27.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -397,6 +400,153 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27) { if (_index == 0 && f0 != null) @@ -514,6 +664,125 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT28.generated.cs b/OneOf.Extended/OneOfBaseT28.generated.cs index 611c63e..a3557f2 100644 --- a/OneOf.Extended/OneOfBaseT28.generated.cs +++ b/OneOf.Extended/OneOfBaseT28.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -410,6 +413,158 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28) { if (_index == 0 && f0 != null) @@ -531,6 +686,129 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT29.generated.cs b/OneOf.Extended/OneOfBaseT29.generated.cs index 8348e0d..480ef2e 100644 --- a/OneOf.Extended/OneOfBaseT29.generated.cs +++ b/OneOf.Extended/OneOfBaseT29.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -423,6 +426,163 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29) { if (_index == 0 && f0 != null) @@ -548,6 +708,133 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT30.generated.cs b/OneOf.Extended/OneOfBaseT30.generated.cs index 25229bd..f12ff06 100644 --- a/OneOf.Extended/OneOfBaseT30.generated.cs +++ b/OneOf.Extended/OneOfBaseT30.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -436,6 +439,168 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + if (_index == 30 && f30 != null) + { + await f30(_value30); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30) { if (_index == 0 && f0 != null) @@ -565,6 +730,137 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29, Func> f30) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + if (_index == 30 && f30 != null) + { + return await f30(_value30); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT31.generated.cs b/OneOf.Extended/OneOfBaseT31.generated.cs index 9a1fa4d..1be0ed8 100644 --- a/OneOf.Extended/OneOfBaseT31.generated.cs +++ b/OneOf.Extended/OneOfBaseT31.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -449,6 +452,173 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30, Func f31) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + if (_index == 30 && f30 != null) + { + await f30(_value30); + return; + } + if (_index == 31 && f31 != null) + { + await f31(_value31); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30, Func f31) { if (_index == 0 && f0 != null) @@ -582,6 +752,141 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29, Func> f30, Func> f31) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + if (_index == 30 && f30 != null) + { + return await f30(_value30); + } + if (_index == 31 && f31 != null) + { + return await f31(_value31); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfBaseT9.generated.cs b/OneOf.Extended/OneOfBaseT9.generated.cs index 9510257..ff66bb2 100644 --- a/OneOf.Extended/OneOfBaseT9.generated.cs +++ b/OneOf.Extended/OneOfBaseT9.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -163,6 +166,63 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9) { if (_index == 0 && f0 != null) @@ -208,6 +268,53 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf.Extended/OneOfT10.generated.cs b/OneOf.Extended/OneOfT10.generated.cs index 1297e00..591f1ac 100644 --- a/OneOf.Extended/OneOfT10.generated.cs +++ b/OneOf.Extended/OneOfT10.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -182,6 +185,68 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10) { if (_index == 0 && f0 != null) @@ -231,6 +296,57 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -266,6 +382,31 @@ public OneOf MapT0(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -289,6 +430,31 @@ public OneOf MapT1(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -312,6 +478,31 @@ public OneOf MapT2(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -335,6 +526,31 @@ public OneOf MapT3(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -358,6 +574,31 @@ public OneOf MapT4(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -381,6 +622,31 @@ public OneOf MapT5(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -404,6 +670,31 @@ public OneOf MapT6(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -427,6 +718,31 @@ public OneOf MapT7(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -450,6 +766,31 @@ public OneOf MapT8(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -473,6 +814,31 @@ public OneOf MapT9(Fu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT10(Func mapFunc) { @@ -497,6 +863,31 @@ public OneOf MapT10(Fu }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT11.generated.cs b/OneOf.Extended/OneOfT11.generated.cs index 4b97d9f..6b08c95 100644 --- a/OneOf.Extended/OneOfT11.generated.cs +++ b/OneOf.Extended/OneOfT11.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -196,6 +199,73 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11) { if (_index == 0 && f0 != null) @@ -249,6 +319,61 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -286,6 +411,32 @@ public OneOf MapT0 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -310,6 +461,32 @@ public OneOf MapT1 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -334,6 +511,32 @@ public OneOf MapT2 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -358,6 +561,32 @@ public OneOf MapT3 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -382,6 +611,32 @@ public OneOf MapT4 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -406,6 +661,32 @@ public OneOf MapT5 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -430,6 +711,32 @@ public OneOf MapT6 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -454,6 +761,32 @@ public OneOf MapT7 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -478,6 +811,32 @@ public OneOf MapT8 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -502,6 +861,32 @@ public OneOf MapT9 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT10(Func mapFunc) { @@ -526,6 +911,32 @@ public OneOf MapT10 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT11(Func mapFunc) { @@ -551,6 +962,32 @@ public OneOf MapT11> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT12.generated.cs b/OneOf.Extended/OneOfT12.generated.cs index 0801a8b..0604307 100644 --- a/OneOf.Extended/OneOfT12.generated.cs +++ b/OneOf.Extended/OneOfT12.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -210,6 +213,78 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12) { if (_index == 0 && f0 != null) @@ -267,6 +342,65 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -306,6 +440,33 @@ public OneOf MapT0 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -331,6 +492,33 @@ public OneOf MapT1 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -356,6 +544,33 @@ public OneOf MapT2 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -381,6 +596,33 @@ public OneOf MapT3 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -406,6 +648,33 @@ public OneOf MapT4 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -431,6 +700,33 @@ public OneOf MapT5 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -456,6 +752,33 @@ public OneOf MapT6 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -481,6 +804,33 @@ public OneOf MapT7 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -506,6 +856,33 @@ public OneOf MapT8 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -531,6 +908,33 @@ public OneOf MapT9 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT10(Func mapFunc) { @@ -556,6 +960,33 @@ public OneOf MapT10 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT11(Func mapFunc) { @@ -581,6 +1012,33 @@ public OneOf MapT11 throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT12(Func mapFunc) { @@ -607,6 +1065,33 @@ public OneOf MapT12> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT13.generated.cs b/OneOf.Extended/OneOfT13.generated.cs index c5d1ac5..eaad861 100644 --- a/OneOf.Extended/OneOfT13.generated.cs +++ b/OneOf.Extended/OneOfT13.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -224,6 +227,83 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13) { if (_index == 0 && f0 != null) @@ -285,6 +365,69 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -326,6 +469,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -352,6 +523,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -378,6 +577,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -404,6 +631,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -430,6 +685,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -456,6 +739,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -482,6 +793,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -508,6 +847,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -534,6 +901,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -560,6 +955,34 @@ public OneOf Ma _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT10(Func mapFunc) { @@ -586,6 +1009,34 @@ public OneOf Map _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT11(Func mapFunc) { @@ -612,6 +1063,34 @@ public OneOf Map _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT12(Func mapFunc) { @@ -638,6 +1117,34 @@ public OneOf Map _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT13(Func mapFunc) { @@ -665,6 +1172,34 @@ public OneOf Map }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT14.generated.cs b/OneOf.Extended/OneOfT14.generated.cs index e7e9578..7c68c2e 100644 --- a/OneOf.Extended/OneOfT14.generated.cs +++ b/OneOf.Extended/OneOfT14.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -238,6 +241,88 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14) { if (_index == 0 && f0 != null) @@ -303,6 +388,73 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -346,6 +498,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -373,6 +554,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -400,6 +610,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -427,6 +666,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -454,6 +722,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -481,6 +778,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -508,6 +834,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -535,6 +890,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -562,6 +946,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -589,6 +1002,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT10(Func mapFunc) { @@ -616,6 +1058,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT11(Func mapFunc) { @@ -643,6 +1114,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT12(Func mapFunc) { @@ -670,6 +1170,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT13(Func mapFunc) { @@ -697,6 +1226,35 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT14(Func mapFunc) { @@ -725,6 +1283,35 @@ public OneOf> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT15.generated.cs b/OneOf.Extended/OneOfT15.generated.cs index 8c3b91d..919a478 100644 --- a/OneOf.Extended/OneOfT15.generated.cs +++ b/OneOf.Extended/OneOfT15.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -252,6 +255,93 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15) { if (_index == 0 && f0 != null) @@ -321,6 +411,77 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -366,6 +527,36 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -394,6 +585,36 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -422,8 +643,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -433,8 +655,8 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, - 3 => mapFunc(AsT3), + 2 => await mapFunc(AsT2), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -450,8 +672,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -462,8 +685,8 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, - 4 => mapFunc(AsT4), + 3 => mapFunc(AsT3), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -478,8 +701,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -490,9 +714,9 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -506,8 +730,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -519,9 +744,9 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -534,8 +759,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -547,10 +773,10 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -562,8 +788,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -576,10 +803,10 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -590,8 +817,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -604,11 +832,11 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -618,8 +846,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -633,11 +862,11 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -646,8 +875,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -661,12 +891,12 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -674,8 +904,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -690,20 +921,21 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, _ => throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -718,20 +950,21 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -747,19 +980,20 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, _ => throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -775,17 +1009,424 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), _ => throw new InvalidOperationException() }; } +#endif public bool TryPickT0(out T0 value, out OneOf remainder) { diff --git a/OneOf.Extended/OneOfT16.generated.cs b/OneOf.Extended/OneOfT16.generated.cs index 51f8dc6..504dc59 100644 --- a/OneOf.Extended/OneOfT16.generated.cs +++ b/OneOf.Extended/OneOfT16.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -266,6 +269,98 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16) { if (_index == 0 && f0 != null) @@ -339,6 +434,81 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -386,6 +556,37 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -415,8 +616,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) { if (mapFunc == null) { @@ -425,8 +627,8 @@ public OneOf AsT0, - 1 => AsT1, - 2 => mapFunc(AsT2), + 1 => await mapFunc(AsT1), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -444,8 +646,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT2(Func mapFunc) { if (mapFunc == null) { @@ -455,8 +658,8 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, - 3 => mapFunc(AsT3), + 2 => mapFunc(AsT2), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -473,8 +676,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -484,9 +688,9 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => await mapFunc(AsT2), 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -502,8 +706,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -514,9 +719,9 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => mapFunc(AsT3), 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -531,8 +736,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -543,10 +749,10 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -560,8 +766,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -573,10 +780,10 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -589,8 +796,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -602,11 +810,11 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -618,8 +826,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -632,11 +841,11 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -647,8 +856,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -661,12 +871,12 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -676,8 +886,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -691,12 +902,12 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -705,8 +916,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -720,13 +932,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -734,8 +946,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -750,21 +963,22 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, _ => throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -779,21 +993,22 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -809,20 +1024,21 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, _ => throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -838,7 +1054,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -846,10 +1062,491 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), + 16 => AsT16, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT16(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => mapFunc(AsT16), + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => await mapFunc(AsT16), _ => throw new InvalidOperationException() }; } +#endif public bool TryPickT0(out T0 value, out OneOf remainder) { diff --git a/OneOf.Extended/OneOfT17.generated.cs b/OneOf.Extended/OneOfT17.generated.cs index eefe75b..03456e1 100644 --- a/OneOf.Extended/OneOfT17.generated.cs +++ b/OneOf.Extended/OneOfT17.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -280,6 +283,103 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17) { if (_index == 0 && f0 != null) @@ -357,6 +457,85 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -406,6 +585,38 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -436,8 +647,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) { if (mapFunc == null) { @@ -446,8 +658,8 @@ public OneOf AsT0, - 1 => AsT1, - 2 => mapFunc(AsT2), + 1 => await mapFunc(AsT1), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -466,8 +678,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT2(Func mapFunc) { if (mapFunc == null) { @@ -477,8 +690,8 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, - 3 => mapFunc(AsT3), + 2 => mapFunc(AsT2), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -496,8 +709,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -507,9 +721,9 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => await mapFunc(AsT2), 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -526,8 +740,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -538,9 +753,9 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => mapFunc(AsT3), 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -556,8 +771,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -568,10 +784,10 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -586,8 +802,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -599,10 +816,10 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -616,8 +833,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -629,11 +847,11 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -646,8 +864,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -660,11 +879,11 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -676,8 +895,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -690,12 +910,12 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -706,8 +926,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -721,12 +942,12 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -736,8 +957,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -751,13 +973,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -766,8 +988,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -782,13 +1005,13 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -796,8 +1019,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -812,22 +1036,23 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -843,21 +1068,22 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, _ => throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -873,7 +1099,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -881,13 +1107,14 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT9(Func mapFunc) { if (mapFunc == null) { @@ -904,7 +1131,503 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT16(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => mapFunc(AsT16), + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => await mapFunc(AsT16), + 17 => AsT17, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT17(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -917,6 +1640,38 @@ public OneOf> MapT17Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => await mapFunc(AsT17), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT18.generated.cs b/OneOf.Extended/OneOfT18.generated.cs index ba17036..abd5ef9 100644 --- a/OneOf.Extended/OneOfT18.generated.cs +++ b/OneOf.Extended/OneOfT18.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -294,6 +297,108 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18) { if (_index == 0 && f0 != null) @@ -375,6 +480,89 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -426,8 +614,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) { if (mapFunc == null) { @@ -435,8 +624,8 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 0 => await mapFunc(AsT0), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -457,8 +646,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT1(Func mapFunc) { if (mapFunc == null) { @@ -467,8 +657,8 @@ public OneOf AsT0, - 1 => AsT1, - 2 => mapFunc(AsT2), + 1 => mapFunc(AsT1), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -488,8 +678,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) { if (mapFunc == null) { @@ -498,9 +689,9 @@ public OneOf AsT0, - 1 => AsT1, + 1 => await mapFunc(AsT1), 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -519,8 +710,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT2(Func mapFunc) { if (mapFunc == null) { @@ -530,9 +722,9 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => mapFunc(AsT2), 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -550,8 +742,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -561,10 +754,10 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => await mapFunc(AsT2), 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -581,8 +774,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -593,10 +787,10 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => mapFunc(AsT3), 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -612,8 +806,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -624,11 +819,11 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -643,8 +838,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -656,11 +852,11 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -674,8 +870,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -687,12 +884,12 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -705,8 +902,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -719,12 +917,12 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -736,8 +934,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -750,13 +949,13 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -767,8 +966,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -782,13 +982,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -798,8 +998,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -813,14 +1014,14 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -829,8 +1030,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -845,14 +1047,14 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -860,8 +1062,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -876,7 +1079,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -884,15 +1087,16 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -908,7 +1112,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -916,14 +1120,15 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, _ => throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -939,7 +1144,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -948,13 +1153,14 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT9(Func mapFunc) { if (mapFunc == null) { @@ -971,7 +1177,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => mapFunc(AsT9), 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -980,10 +1186,619 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT16(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => await mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT17(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => mapFunc(AsT17), + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => await mapFunc(AsT17), + 18 => AsT18, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT18(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => mapFunc(AsT18), + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => await mapFunc(AsT18), _ => throw new InvalidOperationException() }; } +#endif public bool TryPickT0(out T0 value, out OneOf remainder) { diff --git a/OneOf.Extended/OneOfT19.generated.cs b/OneOf.Extended/OneOfT19.generated.cs index 3541ffe..bfd6772 100644 --- a/OneOf.Extended/OneOfT19.generated.cs +++ b/OneOf.Extended/OneOfT19.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -308,6 +311,113 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19) { if (_index == 0 && f0 != null) @@ -393,6 +503,93 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -446,8 +643,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) { if (mapFunc == null) { @@ -455,8 +653,8 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 0 => await mapFunc(AsT0), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -478,8 +676,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT1(Func mapFunc) { if (mapFunc == null) { @@ -488,8 +687,8 @@ public OneOf AsT0, - 1 => AsT1, - 2 => mapFunc(AsT2), + 1 => mapFunc(AsT1), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -510,8 +709,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) { if (mapFunc == null) { @@ -520,9 +720,9 @@ public OneOf AsT0, - 1 => AsT1, + 1 => await mapFunc(AsT1), 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -542,8 +742,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT2(Func mapFunc) { if (mapFunc == null) { @@ -553,9 +754,9 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => mapFunc(AsT2), 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -574,8 +775,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -585,10 +787,10 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => await mapFunc(AsT2), 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -606,8 +808,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -618,10 +821,10 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => mapFunc(AsT3), 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -638,8 +841,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -650,11 +854,11 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -670,8 +874,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -683,11 +888,11 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -702,8 +907,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -715,12 +921,12 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -734,8 +940,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -748,12 +955,12 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -766,8 +973,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -780,13 +988,13 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -798,8 +1006,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -813,13 +1022,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -830,8 +1039,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -845,14 +1055,14 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -862,8 +1072,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -878,14 +1089,14 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -894,8 +1105,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -910,7 +1122,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -918,7 +1130,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -926,8 +1138,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -943,7 +1156,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -951,15 +1164,16 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, _ => throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -975,7 +1189,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -984,14 +1198,15 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT9(Func mapFunc) { if (mapFunc == null) { @@ -1008,7 +1223,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => mapFunc(AsT9), 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -1017,11 +1232,639 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT16(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => await mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT17(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => mapFunc(AsT17), + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => await mapFunc(AsT17), + 18 => AsT18, + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT18(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => mapFunc(AsT18), + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => await mapFunc(AsT18), + 19 => AsT19, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT19(Func mapFunc) { @@ -1055,6 +1898,40 @@ public OneOf> MapT19Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => await mapFunc(AsT19), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT20.generated.cs b/OneOf.Extended/OneOfT20.generated.cs index c03bd8b..59b3341 100644 --- a/OneOf.Extended/OneOfT20.generated.cs +++ b/OneOf.Extended/OneOfT20.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -322,6 +325,118 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20) { if (_index == 0 && f0 != null) @@ -411,6 +526,97 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -466,8 +672,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) { if (mapFunc == null) { @@ -475,8 +682,8 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 0 => await mapFunc(AsT0), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -499,8 +706,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT1(Func mapFunc) { if (mapFunc == null) { @@ -509,8 +717,8 @@ public OneOf AsT0, - 1 => AsT1, - 2 => mapFunc(AsT2), + 1 => mapFunc(AsT1), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -532,8 +740,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) { if (mapFunc == null) { @@ -542,9 +751,9 @@ public OneOf AsT0, - 1 => AsT1, + 1 => await mapFunc(AsT1), 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -565,8 +774,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT2(Func mapFunc) { if (mapFunc == null) { @@ -576,9 +786,9 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => mapFunc(AsT2), 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -598,8 +808,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) { if (mapFunc == null) { @@ -609,10 +820,10 @@ public OneOf AsT0, 1 => AsT1, - 2 => AsT2, + 2 => await mapFunc(AsT2), 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -631,8 +842,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT3(Func mapFunc) { if (mapFunc == null) { @@ -643,10 +855,10 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => mapFunc(AsT3), 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -664,8 +876,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) { if (mapFunc == null) { @@ -676,11 +889,11 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => AsT3, + 3 => await mapFunc(AsT3), 4 => AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -697,8 +910,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT4(Func mapFunc) { if (mapFunc == null) { @@ -710,11 +924,11 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -730,8 +944,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) { if (mapFunc == null) { @@ -743,12 +958,12 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => AsT4, + 4 => await mapFunc(AsT4), 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -763,8 +978,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT5(Func mapFunc) { if (mapFunc == null) { @@ -777,12 +993,12 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -796,8 +1012,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) { if (mapFunc == null) { @@ -810,13 +1027,13 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => AsT5, + 5 => await mapFunc(AsT5), 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -829,8 +1046,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT6(Func mapFunc) { if (mapFunc == null) { @@ -844,13 +1062,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -862,8 +1080,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) { if (mapFunc == null) { @@ -877,14 +1096,14 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => AsT6, + 6 => await mapFunc(AsT6), 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -895,8 +1114,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT7(Func mapFunc) { if (mapFunc == null) { @@ -911,14 +1131,14 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -928,8 +1148,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) { if (mapFunc == null) { @@ -944,7 +1165,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => AsT7, + 7 => await mapFunc(AsT7), 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -952,7 +1173,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -961,8 +1182,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT8(Func mapFunc) { if (mapFunc == null) { @@ -978,7 +1200,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -986,7 +1208,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -994,8 +1216,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) { if (mapFunc == null) { @@ -1011,7 +1234,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => AsT8, + 8 => await mapFunc(AsT8), 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -1020,13 +1243,626 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => await mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT16(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => await mapFunc(AsT16), + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT17(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => mapFunc(AsT17), + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT18(Func mapFunc) { @@ -1060,6 +1896,41 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => await mapFunc(AsT18), + 19 => AsT19, + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT19(Func mapFunc) { @@ -1093,6 +1964,41 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => await mapFunc(AsT19), + 20 => AsT20, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT20(Func mapFunc) { @@ -1127,6 +2033,41 @@ public OneOf> MapT20Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => await mapFunc(AsT20), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT21.generated.cs b/OneOf.Extended/OneOfT21.generated.cs index 1d89b7b..df179ee 100644 --- a/OneOf.Extended/OneOfT21.generated.cs +++ b/OneOf.Extended/OneOfT21.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -336,6 +339,123 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21) { if (_index == 0 && f0 != null) @@ -429,6 +549,101 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -461,7 +676,637 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -470,7 +1315,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => mapFunc(AsT9), 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -486,8 +1331,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) { if (mapFunc == null) { @@ -496,7 +1342,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -504,7 +1350,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => await mapFunc(AsT9), 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -520,8 +1366,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT10(Func mapFunc) { if (mapFunc == null) { @@ -531,7 +1378,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -539,7 +1386,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -554,8 +1401,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) { if (mapFunc == null) { @@ -566,14 +1414,14 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => await mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -588,8 +1436,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT11(Func mapFunc) { if (mapFunc == null) { @@ -601,14 +1450,14 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -622,8 +1471,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) { if (mapFunc == null) { @@ -636,13 +1486,13 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => await mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -656,8 +1506,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT12(Func mapFunc) { if (mapFunc == null) { @@ -671,13 +1522,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -690,8 +1541,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -706,12 +1558,12 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -724,8 +1576,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -741,12 +1594,12 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -758,8 +1611,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -776,11 +1630,11 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -792,8 +1646,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -811,11 +1666,11 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -826,8 +1681,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -846,10 +1702,10 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -860,8 +1716,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -881,10 +1738,10 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -894,8 +1751,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -916,9 +1774,9 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -928,8 +1786,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -951,9 +1810,9 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -962,8 +1821,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -986,8 +1846,8 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), - 16 => AsT16, + 15 => AsT15, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -996,8 +1856,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -1021,8 +1882,8 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), - 17 => AsT17, + 16 => AsT16, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1030,8 +1891,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -1056,7 +1918,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1064,6 +1926,7 @@ public OneOf throw new InvalidOperationException() }; } +#endif public OneOf MapT18(Func mapFunc) { @@ -1098,6 +1961,42 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => await mapFunc(AsT18), + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT19(Func mapFunc) { @@ -1132,6 +2031,42 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => await mapFunc(AsT19), + 20 => AsT20, + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT20(Func mapFunc) { @@ -1166,6 +2101,42 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => await mapFunc(AsT20), + 21 => AsT21, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT21(Func mapFunc) { @@ -1201,6 +2172,42 @@ public OneOf> MapT21Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => await mapFunc(AsT21), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT22.generated.cs b/OneOf.Extended/OneOfT22.generated.cs index 58f9f5d..a659a94 100644 --- a/OneOf.Extended/OneOfT22.generated.cs +++ b/OneOf.Extended/OneOfT22.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -350,6 +353,128 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22) { if (_index == 0 && f0 != null) @@ -447,6 +572,105 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -471,8 +695,692 @@ public TResult Match(Func f0, Func f1, Func FromT21(T21 input) => input; public static OneOf FromT22(T22 input) => input; - - public OneOf MapT0(Func mapFunc) + + public OneOf MapT0(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) { if (mapFunc == null) { @@ -480,7 +1388,7 @@ public OneOf mapFunc(AsT0), + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -489,7 +1397,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => AsT9, + 9 => await mapFunc(AsT9), 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -506,8 +1414,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT1(Func mapFunc) + public OneOf MapT10(Func mapFunc) { if (mapFunc == null) { @@ -516,7 +1425,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -525,7 +1434,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -541,8 +1450,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) { if (mapFunc == null) { @@ -552,7 +1462,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -560,7 +1470,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => await mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -576,8 +1486,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT11(Func mapFunc) { if (mapFunc == null) { @@ -588,7 +1499,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -596,7 +1507,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -611,8 +1522,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) { if (mapFunc == null) { @@ -624,14 +1536,14 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => await mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -646,8 +1558,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT12(Func mapFunc) { if (mapFunc == null) { @@ -660,14 +1573,14 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -681,8 +1594,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -696,13 +1610,13 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -716,8 +1630,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -732,13 +1647,13 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -751,8 +1666,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -768,12 +1684,12 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -786,8 +1702,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -804,12 +1721,12 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -821,8 +1738,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -840,11 +1758,11 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -856,8 +1774,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -876,11 +1795,11 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -891,8 +1810,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -912,10 +1832,10 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -926,8 +1846,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -948,10 +1869,10 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -961,8 +1882,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -984,9 +1906,9 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -996,8 +1918,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -1020,9 +1943,9 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1031,8 +1954,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -1056,8 +1980,8 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), - 17 => AsT17, + 16 => AsT16, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1066,8 +1990,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -1092,8 +2017,8 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), - 18 => AsT18, + 17 => AsT17, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1101,8 +2026,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT18(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1128,7 +2054,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1136,6 +2062,7 @@ public OneOf throw new InvalidOperationException() }; } +#endif public OneOf MapT19(Func mapFunc) { @@ -1171,6 +2098,43 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => await mapFunc(AsT19), + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT20(Func mapFunc) { @@ -1206,6 +2170,43 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => await mapFunc(AsT20), + 21 => AsT21, + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT21(Func mapFunc) { @@ -1241,6 +2242,43 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => await mapFunc(AsT21), + 22 => AsT22, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT22(Func mapFunc) { @@ -1277,6 +2315,43 @@ public OneOf> MapT22Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => await mapFunc(AsT22), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT23.generated.cs b/OneOf.Extended/OneOfT23.generated.cs index aa8881c..fac4c11 100644 --- a/OneOf.Extended/OneOfT23.generated.cs +++ b/OneOf.Extended/OneOfT23.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -364,6 +367,133 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23) { if (_index == 0 && f0 != null) @@ -465,6 +595,109 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -499,7 +732,747 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -509,7 +1482,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -526,8 +1499,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) { if (mapFunc == null) { @@ -536,7 +1510,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -545,7 +1519,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => AsT10, + 10 => await mapFunc(AsT10), 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -562,8 +1536,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT11(Func mapFunc) { if (mapFunc == null) { @@ -573,7 +1548,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -582,7 +1557,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -598,8 +1573,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) { if (mapFunc == null) { @@ -610,7 +1586,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -618,7 +1594,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => await mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -634,8 +1610,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT12(Func mapFunc) { if (mapFunc == null) { @@ -647,7 +1624,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -655,7 +1632,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -670,8 +1647,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -684,14 +1662,14 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -706,8 +1684,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -721,14 +1700,14 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -742,8 +1721,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -758,13 +1738,13 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -778,8 +1758,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -795,13 +1776,13 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -814,8 +1795,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -832,12 +1814,12 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -850,8 +1832,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -869,12 +1852,12 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -886,8 +1869,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -906,11 +1890,11 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -922,8 +1906,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -943,11 +1928,11 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -958,8 +1943,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -980,10 +1966,10 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -994,8 +1980,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -1017,10 +2004,10 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1030,8 +2017,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -1054,9 +2042,9 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1066,8 +2054,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -1091,9 +2080,9 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1102,8 +2091,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1128,8 +2118,8 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), - 18 => AsT18, + 17 => AsT17, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1138,8 +2128,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1165,8 +2156,8 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), - 19 => AsT19, + 18 => AsT18, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1174,8 +2165,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT19(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1202,7 +2194,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1210,6 +2202,7 @@ public OneOf throw new InvalidOperationException() }; } +#endif public OneOf MapT20(Func mapFunc) { @@ -1246,6 +2239,44 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => await mapFunc(AsT20), + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT21(Func mapFunc) { @@ -1282,6 +2313,44 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => await mapFunc(AsT21), + 22 => AsT22, + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT22(Func mapFunc) { @@ -1318,6 +2387,44 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => await mapFunc(AsT22), + 23 => AsT23, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT23(Func mapFunc) { @@ -1355,6 +2462,44 @@ public OneOf> MapT23Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => await mapFunc(AsT23), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT24.generated.cs b/OneOf.Extended/OneOfT24.generated.cs index 87854ed..4ac5d6e 100644 --- a/OneOf.Extended/OneOfT24.generated.cs +++ b/OneOf.Extended/OneOfT24.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -378,6 +381,138 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24) { if (_index == 0 && f0 != null) @@ -483,6 +618,113 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -518,7 +760,843 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -529,7 +1607,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -546,8 +1624,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) { if (mapFunc == null) { @@ -556,7 +1635,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -566,7 +1645,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => await mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -583,8 +1662,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT12(Func mapFunc) { if (mapFunc == null) { @@ -594,7 +1674,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -604,7 +1684,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -620,8 +1700,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -632,7 +1713,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -641,7 +1722,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -657,8 +1738,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -670,7 +1752,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -679,7 +1761,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -694,8 +1776,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -708,7 +1791,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -716,7 +1799,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -731,8 +1814,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -746,7 +1830,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -754,7 +1838,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -768,8 +1852,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -784,14 +1869,14 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -805,8 +1890,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -822,14 +1908,14 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -842,8 +1928,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -860,13 +1947,13 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -879,8 +1966,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -898,13 +1986,13 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -916,8 +2004,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -936,12 +2025,12 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -953,8 +2042,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -974,12 +2064,12 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -990,8 +2080,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -1012,11 +2103,11 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1027,8 +2118,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -1050,11 +2142,11 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1064,8 +2156,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1088,10 +2181,10 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1101,8 +2194,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1126,10 +2220,10 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1138,8 +2232,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1164,9 +2259,9 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1175,8 +2270,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1202,9 +2298,9 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1212,8 +2308,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT19(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1240,8 +2337,8 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), - 20 => AsT20, + 19 => AsT19, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1249,8 +2346,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT20(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1278,16 +2376,17 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), - 21 => AsT21, + 20 => AsT20, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, _ => throw new InvalidOperationException() }; } - - public OneOf MapT21(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1316,13 +2415,14 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT22(Func mapFunc) { @@ -1360,6 +2460,45 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => await mapFunc(AsT22), + 23 => AsT23, + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT23(Func mapFunc) { @@ -1397,6 +2536,45 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => await mapFunc(AsT23), + 24 => AsT24, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT24(Func mapFunc) { @@ -1435,6 +2613,45 @@ public OneOf> MapT24Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => await mapFunc(AsT24), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT25.generated.cs b/OneOf.Extended/OneOfT25.generated.cs index dcc509c..94aad4d 100644 --- a/OneOf.Extended/OneOfT25.generated.cs +++ b/OneOf.Extended/OneOfT25.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -392,6 +395,143 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25) { if (_index == 0 && f0 != null) @@ -501,6 +641,117 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -528,8 +779,905 @@ public TResult Match(Func f0, Func f1, Func FromT24(T24 input) => input; public static OneOf FromT25(T25 input) => input; - - public OneOf MapT0(Func mapFunc) + + public OneOf MapT0(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) { if (mapFunc == null) { @@ -537,7 +1685,7 @@ public OneOf mapFunc(AsT0), + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -548,7 +1696,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => AsT11, + 11 => await mapFunc(AsT11), 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -566,8 +1714,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT1(Func mapFunc) + public OneOf MapT12(Func mapFunc) { if (mapFunc == null) { @@ -576,7 +1725,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -587,7 +1736,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -604,8 +1753,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -615,7 +1765,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -625,7 +1775,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -642,8 +1792,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -654,7 +1805,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -664,7 +1815,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -680,8 +1831,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -693,7 +1845,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -702,7 +1854,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -718,8 +1870,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -732,7 +1885,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -741,7 +1894,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -756,8 +1909,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -771,7 +1925,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -779,7 +1933,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -794,8 +1948,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -810,7 +1965,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -818,7 +1973,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -832,8 +1987,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -849,14 +2005,14 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -870,8 +2026,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -888,14 +2045,14 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -908,8 +2065,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -927,13 +2085,13 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -946,8 +2104,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -966,13 +2125,13 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -984,8 +2143,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -1005,12 +2165,12 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1022,8 +2182,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -1044,12 +2205,12 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1060,8 +2221,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1083,11 +2245,11 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1098,8 +2260,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1122,11 +2285,11 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1136,8 +2299,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1161,10 +2325,10 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1174,8 +2338,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1200,10 +2365,10 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1212,8 +2377,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT18(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1239,9 +2405,9 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1250,8 +2416,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT19(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1278,9 +2445,9 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1288,8 +2455,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT20(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1317,8 +2485,8 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), - 21 => AsT21, + 20 => AsT20, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1326,8 +2494,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT21(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1356,16 +2525,17 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), - 22 => AsT22, + 21 => AsT21, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, _ => throw new InvalidOperationException() }; } - - public OneOf MapT22(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1395,13 +2565,14 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT23(Func mapFunc) { @@ -1440,6 +2611,46 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => await mapFunc(AsT23), + 24 => AsT24, + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT24(Func mapFunc) { @@ -1478,6 +2689,46 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => await mapFunc(AsT24), + 25 => AsT25, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT25(Func mapFunc) { @@ -1517,6 +2768,46 @@ public OneOf> MapT25Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => await mapFunc(AsT25), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT26.generated.cs b/OneOf.Extended/OneOfT26.generated.cs index a70fda0..596e1df 100644 --- a/OneOf.Extended/OneOfT26.generated.cs +++ b/OneOf.Extended/OneOfT26.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -406,6 +409,148 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26) { if (_index == 0 && f0 != null) @@ -519,6 +664,121 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -556,7 +816,967 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -568,7 +1788,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -586,8 +1806,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) { if (mapFunc == null) { @@ -596,7 +1817,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -607,7 +1828,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => AsT12, + 12 => await mapFunc(AsT12), 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -625,8 +1846,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT13(Func mapFunc) { if (mapFunc == null) { @@ -636,7 +1858,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -647,7 +1869,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -664,8 +1886,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -676,7 +1899,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -686,7 +1909,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -703,8 +1926,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -716,7 +1940,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -726,7 +1950,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -742,8 +1966,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -756,7 +1981,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -765,7 +1990,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -781,8 +2006,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -796,7 +2022,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -805,7 +2031,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -820,8 +2046,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -836,7 +2063,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -844,7 +2071,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -859,8 +2086,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -876,7 +2104,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -884,7 +2112,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -898,8 +2126,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -916,14 +2145,14 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -937,8 +2166,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -956,14 +2186,14 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -976,8 +2206,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -996,13 +2227,13 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -1015,8 +2246,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -1036,13 +2268,13 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1054,8 +2286,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1076,12 +2309,12 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1093,8 +2326,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1116,12 +2350,12 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1132,8 +2366,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1156,11 +2391,11 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1171,8 +2406,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1196,11 +2432,11 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1210,8 +2446,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1236,10 +2473,10 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1249,8 +2486,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1276,10 +2514,10 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1288,8 +2526,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT19(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1316,9 +2555,9 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1327,8 +2566,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT20(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1356,9 +2596,9 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1366,8 +2606,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT21(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1396,8 +2637,8 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), - 22 => AsT22, + 21 => AsT21, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1405,8 +2646,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT22(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1436,16 +2678,17 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), - 23 => AsT23, + 22 => AsT22, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, _ => throw new InvalidOperationException() }; } - - public OneOf MapT23(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1476,13 +2719,14 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT24(Func mapFunc) { @@ -1522,6 +2766,47 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => await mapFunc(AsT24), + 25 => AsT25, + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT25(Func mapFunc) { @@ -1561,6 +2846,47 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => await mapFunc(AsT25), + 26 => AsT26, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT26(Func mapFunc) { @@ -1601,6 +2927,47 @@ public OneOf> MapT26Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => await mapFunc(AsT26), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT27.generated.cs b/OneOf.Extended/OneOfT27.generated.cs index fc45eab..9ec18c9 100644 --- a/OneOf.Extended/OneOfT27.generated.cs +++ b/OneOf.Extended/OneOfT27.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -420,6 +423,153 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27) { if (_index == 0 && f0 != null) @@ -537,6 +687,125 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -575,7 +844,1073 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -588,7 +1923,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -606,8 +1941,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -616,7 +1952,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -628,7 +1964,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -646,8 +1982,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -657,7 +1994,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -669,7 +2006,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -686,8 +2023,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -698,7 +2036,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -709,7 +2047,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -726,8 +2064,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -739,7 +2078,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -750,7 +2089,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -766,8 +2105,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -780,7 +2120,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -790,7 +2130,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -806,8 +2146,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -821,7 +2162,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -831,7 +2172,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -846,8 +2187,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -862,7 +2204,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -871,7 +2213,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -886,8 +2228,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -903,7 +2246,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -912,7 +2255,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -926,8 +2269,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -944,7 +2288,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -952,7 +2296,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -966,8 +2310,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -985,7 +2330,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -993,7 +2338,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1006,8 +2351,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1026,14 +2372,14 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1046,8 +2392,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1067,14 +2414,14 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1086,8 +2433,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1108,13 +2456,13 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1126,8 +2474,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1149,13 +2498,13 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1166,8 +2515,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1190,12 +2540,12 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1206,8 +2556,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1231,12 +2582,12 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1246,8 +2597,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1272,11 +2624,11 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1286,8 +2638,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1313,11 +2666,11 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1326,8 +2679,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT19(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1354,10 +2708,10 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1366,8 +2720,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT20(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1395,10 +2750,10 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1406,8 +2761,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT21(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1436,9 +2792,9 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1446,8 +2802,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT22(Func mapFunc) + public OneOf MapT24(Func mapFunc) { if (mapFunc == null) { @@ -1477,17 +2834,18 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, _ => throw new InvalidOperationException() }; } - - public OneOf MapT23(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) { if (mapFunc == null) { @@ -1518,16 +2876,17 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), - 24 => AsT24, + 23 => AsT23, + 24 => await mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT24(Func mapFunc) + public OneOf MapT25(Func mapFunc) { if (mapFunc == null) { @@ -1559,15 +2918,16 @@ public OneOf AsT21, 22 => AsT22, 23 => AsT23, - 24 => mapFunc(AsT24), - 25 => AsT25, + 24 => AsT24, + 25 => mapFunc(AsT25), 26 => AsT26, 27 => AsT27, _ => throw new InvalidOperationException() }; } - - public OneOf MapT25(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) { if (mapFunc == null) { @@ -1600,12 +2960,13 @@ public OneOf AsT22, 23 => AsT23, 24 => AsT24, - 25 => mapFunc(AsT25), + 25 => await mapFunc(AsT25), 26 => AsT26, 27 => AsT27, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT26(Func mapFunc) { @@ -1646,6 +3007,48 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT26Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => await mapFunc(AsT26), + 27 => AsT27, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT27(Func mapFunc) { @@ -1687,6 +3090,48 @@ public OneOf> MapT27Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => await mapFunc(AsT27), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT28.generated.cs b/OneOf.Extended/OneOfT28.generated.cs index bdaa11f..1eb5566 100644 --- a/OneOf.Extended/OneOfT28.generated.cs +++ b/OneOf.Extended/OneOfT28.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -434,6 +437,158 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28) { if (_index == 0 && f0 != null) @@ -555,6 +710,129 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -585,8 +863,1142 @@ public TResult Match(Func f0, Func f1, Func FromT27(T27 input) => input; public static OneOf FromT28(T28 input) => input; - - public OneOf MapT0(Func mapFunc) + + public OneOf MapT0(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) { if (mapFunc == null) { @@ -594,7 +2006,7 @@ public OneOf mapFunc(AsT0), + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -607,7 +2019,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => AsT13, + 13 => await mapFunc(AsT13), 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -626,8 +2038,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT1(Func mapFunc) + public OneOf MapT14(Func mapFunc) { if (mapFunc == null) { @@ -636,7 +2049,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -649,7 +2062,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -667,8 +2080,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -678,7 +2092,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -690,7 +2104,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -708,8 +2122,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -720,7 +2135,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -732,7 +2147,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -749,8 +2164,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -762,7 +2178,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -773,7 +2189,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -790,8 +2206,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -804,7 +2221,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -815,7 +2232,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -831,8 +2248,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -846,7 +2264,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -856,7 +2274,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -872,8 +2290,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -888,7 +2307,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -898,7 +2317,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -913,8 +2332,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -930,7 +2350,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -939,7 +2359,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -954,8 +2374,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -972,7 +2393,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -981,7 +2402,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -995,8 +2416,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1014,7 +2436,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -1022,7 +2444,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1036,8 +2458,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1056,7 +2479,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -1064,7 +2487,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1077,8 +2500,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1098,14 +2522,14 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1118,8 +2542,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1140,14 +2565,14 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1159,8 +2584,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1182,13 +2608,13 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1200,8 +2626,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1224,13 +2651,13 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1241,8 +2668,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1266,12 +2694,12 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1282,8 +2710,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1308,12 +2737,12 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1323,8 +2752,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT18(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1350,11 +2780,11 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1364,8 +2794,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT19(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1392,11 +2823,11 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1405,8 +2836,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT20(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1434,10 +2866,10 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1446,8 +2878,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT21(Func mapFunc) + public OneOf MapT24(Func mapFunc) { if (mapFunc == null) { @@ -1476,10 +2909,10 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1487,8 +2920,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT22(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) { if (mapFunc == null) { @@ -1518,9 +2952,9 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => await mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1528,8 +2962,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT23(Func mapFunc) + public OneOf MapT25(Func mapFunc) { if (mapFunc == null) { @@ -1560,17 +2995,18 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), + 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, _ => throw new InvalidOperationException() }; } - - public OneOf MapT24(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) { if (mapFunc == null) { @@ -1602,16 +3038,17 @@ public OneOf AsT21, 22 => AsT22, 23 => AsT23, - 24 => mapFunc(AsT24), - 25 => AsT25, + 24 => AsT24, + 25 => await mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT25(Func mapFunc) + public OneOf MapT26(Func mapFunc) { if (mapFunc == null) { @@ -1644,15 +3081,16 @@ public OneOf AsT22, 23 => AsT23, 24 => AsT24, - 25 => mapFunc(AsT25), - 26 => AsT26, + 25 => AsT25, + 26 => mapFunc(AsT26), 27 => AsT27, 28 => AsT28, _ => throw new InvalidOperationException() }; } - - public OneOf MapT26(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT26Async(Func> mapFunc) { if (mapFunc == null) { @@ -1686,12 +3124,13 @@ public OneOf AsT23, 24 => AsT24, 25 => AsT25, - 26 => mapFunc(AsT26), + 26 => await mapFunc(AsT26), 27 => AsT27, 28 => AsT28, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT27(Func mapFunc) { @@ -1733,6 +3172,49 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT27Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => await mapFunc(AsT27), + 28 => AsT28, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT28(Func mapFunc) { @@ -1775,6 +3257,49 @@ public OneOf> MapT28Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => await mapFunc(AsT28), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT29.generated.cs b/OneOf.Extended/OneOfT29.generated.cs index 74ec58e..fbc9c19 100644 --- a/OneOf.Extended/OneOfT29.generated.cs +++ b/OneOf.Extended/OneOfT29.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -448,6 +451,163 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29) { if (_index == 0 && f0 != null) @@ -573,6 +733,133 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -613,7 +900,1211 @@ public OneOf mapFunc(AsT0), + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -627,7 +2118,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -646,8 +2137,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT1(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -656,7 +2148,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -669,7 +2161,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -688,8 +2180,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT2(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -699,7 +2192,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -712,7 +2205,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -730,8 +2223,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT3(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -742,7 +2236,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -754,7 +2248,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -772,8 +2266,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT4(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -785,7 +2280,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -797,7 +2292,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -814,8 +2309,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT5(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -828,7 +2324,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -839,7 +2335,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -856,8 +2352,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT6(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -871,7 +2368,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -882,7 +2379,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -898,8 +2395,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT7(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -914,7 +2412,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -924,7 +2422,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -940,8 +2438,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT8(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -957,7 +2456,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -967,7 +2466,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -982,8 +2481,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT9(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -1000,7 +2500,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -1009,7 +2509,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1024,8 +2524,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT10(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1043,7 +2544,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -1052,7 +2553,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1066,8 +2567,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT11(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1086,7 +2588,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -1094,7 +2596,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1108,8 +2610,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT12(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1129,7 +2632,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -1137,7 +2640,7 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1150,8 +2653,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT13(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1172,14 +2676,14 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1192,8 +2696,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT14(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1215,14 +2720,14 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1234,8 +2739,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT15(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1258,13 +2764,13 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1276,8 +2782,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT16(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1301,13 +2808,13 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1318,8 +2825,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT17(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1344,12 +2852,12 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1360,8 +2868,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT18(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1387,12 +2896,12 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1402,8 +2911,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT19(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1430,11 +2940,11 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1444,8 +2954,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT20(Func mapFunc) + public OneOf MapT24(Func mapFunc) { if (mapFunc == null) { @@ -1473,11 +2984,11 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1486,8 +2997,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT21(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) { if (mapFunc == null) { @@ -1516,10 +3028,10 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => await mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1528,8 +3040,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT22(Func mapFunc) + public OneOf MapT25(Func mapFunc) { if (mapFunc == null) { @@ -1559,10 +3072,10 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => AsT22, 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1570,8 +3083,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT23(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) { if (mapFunc == null) { @@ -1602,9 +3116,9 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), + 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => await mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1612,8 +3126,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT24(Func mapFunc) + public OneOf MapT26(Func mapFunc) { if (mapFunc == null) { @@ -1645,17 +3160,18 @@ public OneOf AsT21, 22 => AsT22, 23 => AsT23, - 24 => mapFunc(AsT24), + 24 => AsT24, 25 => AsT25, - 26 => AsT26, + 26 => mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, _ => throw new InvalidOperationException() }; } - - public OneOf MapT25(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT26Async(Func> mapFunc) { if (mapFunc == null) { @@ -1688,16 +3204,17 @@ public OneOf AsT22, 23 => AsT23, 24 => AsT24, - 25 => mapFunc(AsT25), - 26 => AsT26, + 25 => AsT25, + 26 => await mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT26(Func mapFunc) + public OneOf MapT27(Func mapFunc) { if (mapFunc == null) { @@ -1731,15 +3248,16 @@ public OneOf AsT23, 24 => AsT24, 25 => AsT25, - 26 => mapFunc(AsT26), - 27 => AsT27, + 26 => AsT26, + 27 => mapFunc(AsT27), 28 => AsT28, 29 => AsT29, _ => throw new InvalidOperationException() }; } - - public OneOf MapT27(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT27Async(Func> mapFunc) { if (mapFunc == null) { @@ -1774,12 +3292,13 @@ public OneOf AsT24, 25 => AsT25, 26 => AsT26, - 27 => mapFunc(AsT27), + 27 => await mapFunc(AsT27), 28 => AsT28, 29 => AsT29, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT28(Func mapFunc) { @@ -1822,6 +3341,50 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT28Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => await mapFunc(AsT28), + 29 => AsT29, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT29(Func mapFunc) { @@ -1865,6 +3428,50 @@ public OneOf> MapT29Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => await mapFunc(AsT29), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT30.generated.cs b/OneOf.Extended/OneOfT30.generated.cs index 5c6e763..c9859bf 100644 --- a/OneOf.Extended/OneOfT30.generated.cs +++ b/OneOf.Extended/OneOfT30.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -462,6 +465,168 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + if (_index == 30 && f30 != null) + { + await f30(_value30); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30) { if (_index == 0 && f0 != null) @@ -591,6 +756,137 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29, Func> f30) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + if (_index == 30 && f30 != null) + { + return await f30(_value30); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -623,8 +919,1284 @@ public TResult Match(Func f0, Func f1, Func FromT29(T29 input) => input; public static OneOf FromT30(T30 input) => input; - - public OneOf MapT0(Func mapFunc) + + public OneOf MapT0(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) { if (mapFunc == null) { @@ -632,7 +2204,7 @@ public OneOf mapFunc(AsT0), + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -646,7 +2218,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => AsT14, + 14 => await mapFunc(AsT14), 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -666,8 +2238,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT1(Func mapFunc) + public OneOf MapT15(Func mapFunc) { if (mapFunc == null) { @@ -676,7 +2249,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -690,7 +2263,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -709,8 +2282,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -720,7 +2294,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -733,7 +2307,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -752,8 +2326,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -764,7 +2339,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -777,7 +2352,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -795,8 +2370,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -808,7 +2384,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -820,7 +2396,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -838,8 +2414,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -852,7 +2429,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -864,7 +2441,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -881,8 +2458,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -896,7 +2474,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -907,7 +2485,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -924,8 +2502,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -940,7 +2519,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -951,7 +2530,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -967,8 +2546,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -984,7 +2564,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -994,7 +2574,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -1010,8 +2590,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -1028,7 +2609,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -1038,7 +2619,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1053,8 +2634,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1072,7 +2654,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -1081,7 +2663,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1096,8 +2678,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1116,7 +2699,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -1125,7 +2708,7 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1139,8 +2722,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1160,7 +2744,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -1168,7 +2752,7 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1182,8 +2766,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1204,7 +2789,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -1212,7 +2797,7 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1225,8 +2810,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1248,14 +2834,14 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1268,8 +2854,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1292,14 +2879,14 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1311,8 +2898,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1336,13 +2924,13 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1354,8 +2942,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1380,13 +2969,13 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1397,8 +2986,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT18(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1424,12 +3014,12 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1440,8 +3030,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT19(Func mapFunc) + public OneOf MapT24(Func mapFunc) { if (mapFunc == null) { @@ -1468,12 +3059,12 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1483,8 +3074,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT20(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) { if (mapFunc == null) { @@ -1512,11 +3104,11 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => await mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1526,8 +3118,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT21(Func mapFunc) + public OneOf MapT25(Func mapFunc) { if (mapFunc == null) { @@ -1556,11 +3149,11 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => AsT21, 22 => AsT22, 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1569,8 +3162,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT22(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) { if (mapFunc == null) { @@ -1600,10 +3194,10 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => AsT22, 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => await mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1612,8 +3206,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT23(Func mapFunc) + public OneOf MapT26(Func mapFunc) { if (mapFunc == null) { @@ -1644,10 +3239,10 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), + 23 => AsT23, 24 => AsT24, 25 => AsT25, - 26 => AsT26, + 26 => mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, @@ -1655,8 +3250,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT24(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT26Async(Func> mapFunc) { if (mapFunc == null) { @@ -1688,9 +3284,9 @@ public OneOf AsT21, 22 => AsT22, 23 => AsT23, - 24 => mapFunc(AsT24), + 24 => AsT24, 25 => AsT25, - 26 => AsT26, + 26 => await mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, @@ -1698,8 +3294,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT25(Func mapFunc) + public OneOf MapT27(Func mapFunc) { if (mapFunc == null) { @@ -1732,17 +3329,18 @@ public OneOf AsT22, 23 => AsT23, 24 => AsT24, - 25 => mapFunc(AsT25), + 25 => AsT25, 26 => AsT26, - 27 => AsT27, + 27 => mapFunc(AsT27), 28 => AsT28, 29 => AsT29, 30 => AsT30, _ => throw new InvalidOperationException() }; } - - public OneOf MapT26(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT27Async(Func> mapFunc) { if (mapFunc == null) { @@ -1776,16 +3374,17 @@ public OneOf AsT23, 24 => AsT24, 25 => AsT25, - 26 => mapFunc(AsT26), - 27 => AsT27, + 26 => AsT26, + 27 => await mapFunc(AsT27), 28 => AsT28, 29 => AsT29, 30 => AsT30, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT27(Func mapFunc) + public OneOf MapT28(Func mapFunc) { if (mapFunc == null) { @@ -1820,15 +3419,16 @@ public OneOf AsT24, 25 => AsT25, 26 => AsT26, - 27 => mapFunc(AsT27), - 28 => AsT28, + 27 => AsT27, + 28 => mapFunc(AsT28), 29 => AsT29, 30 => AsT30, _ => throw new InvalidOperationException() }; } - - public OneOf MapT28(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT28Async(Func> mapFunc) { if (mapFunc == null) { @@ -1864,12 +3464,13 @@ public OneOf AsT25, 26 => AsT26, 27 => AsT27, - 28 => mapFunc(AsT28), + 28 => await mapFunc(AsT28), 29 => AsT29, 30 => AsT30, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT29(Func mapFunc) { @@ -1913,6 +3514,51 @@ public OneOf throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT29Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => await mapFunc(AsT29), + 30 => AsT30, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT30(Func mapFunc) { @@ -1957,6 +3603,51 @@ public OneOf> MapT30Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => await mapFunc(AsT30), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT31.generated.cs b/OneOf.Extended/OneOfT31.generated.cs index 5e2686e..9b1b000 100644 --- a/OneOf.Extended/OneOfT31.generated.cs +++ b/OneOf.Extended/OneOfT31.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -476,6 +479,173 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30, Func f31) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + if (_index == 10 && f10 != null) + { + await f10(_value10); + return; + } + if (_index == 11 && f11 != null) + { + await f11(_value11); + return; + } + if (_index == 12 && f12 != null) + { + await f12(_value12); + return; + } + if (_index == 13 && f13 != null) + { + await f13(_value13); + return; + } + if (_index == 14 && f14 != null) + { + await f14(_value14); + return; + } + if (_index == 15 && f15 != null) + { + await f15(_value15); + return; + } + if (_index == 16 && f16 != null) + { + await f16(_value16); + return; + } + if (_index == 17 && f17 != null) + { + await f17(_value17); + return; + } + if (_index == 18 && f18 != null) + { + await f18(_value18); + return; + } + if (_index == 19 && f19 != null) + { + await f19(_value19); + return; + } + if (_index == 20 && f20 != null) + { + await f20(_value20); + return; + } + if (_index == 21 && f21 != null) + { + await f21(_value21); + return; + } + if (_index == 22 && f22 != null) + { + await f22(_value22); + return; + } + if (_index == 23 && f23 != null) + { + await f23(_value23); + return; + } + if (_index == 24 && f24 != null) + { + await f24(_value24); + return; + } + if (_index == 25 && f25 != null) + { + await f25(_value25); + return; + } + if (_index == 26 && f26 != null) + { + await f26(_value26); + return; + } + if (_index == 27 && f27 != null) + { + await f27(_value27); + return; + } + if (_index == 28 && f28 != null) + { + await f28(_value28); + return; + } + if (_index == 29 && f29 != null) + { + await f29(_value29); + return; + } + if (_index == 30 && f30 != null) + { + await f30(_value30); + return; + } + if (_index == 31 && f31 != null) + { + await f31(_value31); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9, Func f10, Func f11, Func f12, Func f13, Func f14, Func f15, Func f16, Func f17, Func f18, Func f19, Func f20, Func f21, Func f22, Func f23, Func f24, Func f25, Func f26, Func f27, Func f28, Func f29, Func f30, Func f31) { if (_index == 0 && f0 != null) @@ -609,6 +779,141 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9, Func> f10, Func> f11, Func> f12, Func> f13, Func> f14, Func> f15, Func> f16, Func> f17, Func> f18, Func> f19, Func> f20, Func> f21, Func> f22, Func> f23, Func> f24, Func> f25, Func> f26, Func> f27, Func> f28, Func> f29, Func> f30, Func> f31) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + if (_index == 10 && f10 != null) + { + return await f10(_value10); + } + if (_index == 11 && f11 != null) + { + return await f11(_value11); + } + if (_index == 12 && f12 != null) + { + return await f12(_value12); + } + if (_index == 13 && f13 != null) + { + return await f13(_value13); + } + if (_index == 14 && f14 != null) + { + return await f14(_value14); + } + if (_index == 15 && f15 != null) + { + return await f15(_value15); + } + if (_index == 16 && f16 != null) + { + return await f16(_value16); + } + if (_index == 17 && f17 != null) + { + return await f17(_value17); + } + if (_index == 18 && f18 != null) + { + return await f18(_value18); + } + if (_index == 19 && f19 != null) + { + return await f19(_value19); + } + if (_index == 20 && f20 != null) + { + return await f20(_value20); + } + if (_index == 21 && f21 != null) + { + return await f21(_value21); + } + if (_index == 22 && f22 != null) + { + return await f22(_value22); + } + if (_index == 23 && f23 != null) + { + return await f23(_value23); + } + if (_index == 24 && f24 != null) + { + return await f24(_value24); + } + if (_index == 25 && f25 != null) + { + return await f25(_value25); + } + if (_index == 26 && f26 != null) + { + return await f26(_value26); + } + if (_index == 27 && f27 != null) + { + return await f27(_value27); + } + if (_index == 28 && f28 != null) + { + return await f28(_value28); + } + if (_index == 29 && f29 != null) + { + return await f29(_value29); + } + if (_index == 30 && f30 != null) + { + return await f30(_value30); + } + if (_index == 31 && f31 != null) + { + return await f31(_value31); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -642,8 +947,1403 @@ public TResult Match(Func f0, Func f1, Func FromT30(T30 input) => input; public static OneOf FromT31(T31 input) => input; - - public OneOf MapT0(Func mapFunc) + + public OneOf MapT0(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT1(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT2(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT3(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT4(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT5(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT6(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT7(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT8(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT9(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT10(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT10Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => await mapFunc(AsT10), + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT11(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT11Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => await mapFunc(AsT11), + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT12(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT12Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => await mapFunc(AsT12), + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT13(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT13Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => await mapFunc(AsT13), + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT14(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT14Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => await mapFunc(AsT14), + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } +#endif + + public OneOf MapT15(Func mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => mapFunc(AsT15), + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => AsT31, + _ => throw new InvalidOperationException() + }; + } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT15Async(Func> mapFunc) { if (mapFunc == null) { @@ -651,7 +2351,7 @@ public OneOf mapFunc(AsT0), + 0 => AsT0, 1 => AsT1, 2 => AsT2, 3 => AsT3, @@ -666,7 +2366,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => AsT15, + 15 => await mapFunc(AsT15), 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -686,8 +2386,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT1(Func mapFunc) + public OneOf MapT16(Func mapFunc) { if (mapFunc == null) { @@ -696,7 +2397,7 @@ public OneOf AsT0, - 1 => mapFunc(AsT1), + 1 => AsT1, 2 => AsT2, 3 => AsT3, 4 => AsT4, @@ -711,7 +2412,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -730,8 +2431,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT2(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT16Async(Func> mapFunc) { if (mapFunc == null) { @@ -741,7 +2443,7 @@ public OneOf AsT0, 1 => AsT1, - 2 => mapFunc(AsT2), + 2 => AsT2, 3 => AsT3, 4 => AsT4, 5 => AsT5, @@ -755,7 +2457,7 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => AsT16, + 16 => await mapFunc(AsT16), 17 => AsT17, 18 => AsT18, 19 => AsT19, @@ -774,8 +2476,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT3(Func mapFunc) + public OneOf MapT17(Func mapFunc) { if (mapFunc == null) { @@ -786,7 +2489,7 @@ public OneOf AsT0, 1 => AsT1, 2 => AsT2, - 3 => mapFunc(AsT3), + 3 => AsT3, 4 => AsT4, 5 => AsT5, 6 => AsT6, @@ -800,7 +2503,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -818,8 +2521,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT4(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT17Async(Func> mapFunc) { if (mapFunc == null) { @@ -831,7 +2535,7 @@ public OneOf AsT1, 2 => AsT2, 3 => AsT3, - 4 => mapFunc(AsT4), + 4 => AsT4, 5 => AsT5, 6 => AsT6, 7 => AsT7, @@ -844,7 +2548,7 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => AsT17, + 17 => await mapFunc(AsT17), 18 => AsT18, 19 => AsT19, 20 => AsT20, @@ -862,8 +2566,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT5(Func mapFunc) + public OneOf MapT18(Func mapFunc) { if (mapFunc == null) { @@ -876,7 +2581,7 @@ public OneOf AsT2, 3 => AsT3, 4 => AsT4, - 5 => mapFunc(AsT5), + 5 => AsT5, 6 => AsT6, 7 => AsT7, 8 => AsT8, @@ -889,7 +2594,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -906,8 +2611,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT6(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT18Async(Func> mapFunc) { if (mapFunc == null) { @@ -921,7 +2627,7 @@ public OneOf AsT3, 4 => AsT4, 5 => AsT5, - 6 => mapFunc(AsT6), + 6 => AsT6, 7 => AsT7, 8 => AsT8, 9 => AsT9, @@ -933,7 +2639,7 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => AsT18, + 18 => await mapFunc(AsT18), 19 => AsT19, 20 => AsT20, 21 => AsT21, @@ -950,8 +2656,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT7(Func mapFunc) + public OneOf MapT19(Func mapFunc) { if (mapFunc == null) { @@ -966,7 +2673,7 @@ public OneOf AsT4, 5 => AsT5, 6 => AsT6, - 7 => mapFunc(AsT7), + 7 => AsT7, 8 => AsT8, 9 => AsT9, 10 => AsT10, @@ -978,7 +2685,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -994,8 +2701,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT8(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT19Async(Func> mapFunc) { if (mapFunc == null) { @@ -1011,7 +2719,7 @@ public OneOf AsT5, 6 => AsT6, 7 => AsT7, - 8 => mapFunc(AsT8), + 8 => AsT8, 9 => AsT9, 10 => AsT10, 11 => AsT11, @@ -1022,7 +2730,7 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => AsT19, + 19 => await mapFunc(AsT19), 20 => AsT20, 21 => AsT21, 22 => AsT22, @@ -1038,8 +2746,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT9(Func mapFunc) + public OneOf MapT20(Func mapFunc) { if (mapFunc == null) { @@ -1056,7 +2765,7 @@ public OneOf AsT6, 7 => AsT7, 8 => AsT8, - 9 => mapFunc(AsT9), + 9 => AsT9, 10 => AsT10, 11 => AsT11, 12 => AsT12, @@ -1067,7 +2776,7 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1082,8 +2791,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT10(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT20Async(Func> mapFunc) { if (mapFunc == null) { @@ -1101,7 +2811,7 @@ public OneOf AsT7, 8 => AsT8, 9 => AsT9, - 10 => mapFunc(AsT10), + 10 => AsT10, 11 => AsT11, 12 => AsT12, 13 => AsT13, @@ -1111,7 +2821,7 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => AsT20, + 20 => await mapFunc(AsT20), 21 => AsT21, 22 => AsT22, 23 => AsT23, @@ -1126,8 +2836,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT11(Func mapFunc) + public OneOf MapT21(Func mapFunc) { if (mapFunc == null) { @@ -1146,7 +2857,7 @@ public OneOf AsT8, 9 => AsT9, 10 => AsT10, - 11 => mapFunc(AsT11), + 11 => AsT11, 12 => AsT12, 13 => AsT13, 14 => AsT14, @@ -1156,7 +2867,7 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1170,8 +2881,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT12(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT21Async(Func> mapFunc) { if (mapFunc == null) { @@ -1191,7 +2903,7 @@ public OneOf AsT9, 10 => AsT10, 11 => AsT11, - 12 => mapFunc(AsT12), + 12 => AsT12, 13 => AsT13, 14 => AsT14, 15 => AsT15, @@ -1200,7 +2912,7 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => AsT21, + 21 => await mapFunc(AsT21), 22 => AsT22, 23 => AsT23, 24 => AsT24, @@ -1214,8 +2926,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT13(Func mapFunc) + public OneOf MapT22(Func mapFunc) { if (mapFunc == null) { @@ -1236,7 +2949,7 @@ public OneOf AsT10, 11 => AsT11, 12 => AsT12, - 13 => mapFunc(AsT13), + 13 => AsT13, 14 => AsT14, 15 => AsT15, 16 => AsT16, @@ -1245,7 +2958,7 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1258,8 +2971,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT14(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT22Async(Func> mapFunc) { if (mapFunc == null) { @@ -1281,7 +2995,7 @@ public OneOf AsT11, 12 => AsT12, 13 => AsT13, - 14 => mapFunc(AsT14), + 14 => AsT14, 15 => AsT15, 16 => AsT16, 17 => AsT17, @@ -1289,7 +3003,7 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => AsT22, + 22 => await mapFunc(AsT22), 23 => AsT23, 24 => AsT24, 25 => AsT25, @@ -1302,8 +3016,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT15(Func mapFunc) + public OneOf MapT23(Func mapFunc) { if (mapFunc == null) { @@ -1326,7 +3041,7 @@ public OneOf AsT12, 13 => AsT13, 14 => AsT14, - 15 => mapFunc(AsT15), + 15 => AsT15, 16 => AsT16, 17 => AsT17, 18 => AsT18, @@ -1334,7 +3049,7 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1346,8 +3061,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT16(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT23Async(Func> mapFunc) { if (mapFunc == null) { @@ -1371,14 +3087,14 @@ public OneOf AsT13, 14 => AsT14, 15 => AsT15, - 16 => mapFunc(AsT16), + 16 => AsT16, 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, - 23 => AsT23, + 23 => await mapFunc(AsT23), 24 => AsT24, 25 => AsT25, 26 => AsT26, @@ -1390,8 +3106,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT17(Func mapFunc) + public OneOf MapT24(Func mapFunc) { if (mapFunc == null) { @@ -1416,14 +3133,14 @@ public OneOf AsT14, 15 => AsT15, 16 => AsT16, - 17 => mapFunc(AsT17), + 17 => AsT17, 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1434,8 +3151,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT18(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT24Async(Func> mapFunc) { if (mapFunc == null) { @@ -1461,13 +3179,13 @@ public OneOf AsT15, 16 => AsT16, 17 => AsT17, - 18 => mapFunc(AsT18), + 18 => AsT18, 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, - 24 => AsT24, + 24 => await mapFunc(AsT24), 25 => AsT25, 26 => AsT26, 27 => AsT27, @@ -1478,8 +3196,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT19(Func mapFunc) + public OneOf MapT25(Func mapFunc) { if (mapFunc == null) { @@ -1506,13 +3225,13 @@ public OneOf AsT16, 17 => AsT17, 18 => AsT18, - 19 => mapFunc(AsT19), + 19 => AsT19, 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1522,8 +3241,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT20(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT25Async(Func> mapFunc) { if (mapFunc == null) { @@ -1551,12 +3271,12 @@ public OneOf AsT17, 18 => AsT18, 19 => AsT19, - 20 => mapFunc(AsT20), + 20 => AsT20, 21 => AsT21, 22 => AsT22, 23 => AsT23, 24 => AsT24, - 25 => AsT25, + 25 => await mapFunc(AsT25), 26 => AsT26, 27 => AsT27, 28 => AsT28, @@ -1566,8 +3286,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT21(Func mapFunc) + public OneOf MapT26(Func mapFunc) { if (mapFunc == null) { @@ -1596,12 +3317,12 @@ public OneOf AsT18, 19 => AsT19, 20 => AsT20, - 21 => mapFunc(AsT21), + 21 => AsT21, 22 => AsT22, 23 => AsT23, 24 => AsT24, 25 => AsT25, - 26 => AsT26, + 26 => mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, @@ -1610,8 +3331,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT22(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT26Async(Func> mapFunc) { if (mapFunc == null) { @@ -1641,11 +3363,11 @@ public OneOf AsT19, 20 => AsT20, 21 => AsT21, - 22 => mapFunc(AsT22), + 22 => AsT22, 23 => AsT23, 24 => AsT24, 25 => AsT25, - 26 => AsT26, + 26 => await mapFunc(AsT26), 27 => AsT27, 28 => AsT28, 29 => AsT29, @@ -1654,8 +3376,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT23(Func mapFunc) + public OneOf MapT27(Func mapFunc) { if (mapFunc == null) { @@ -1686,11 +3409,11 @@ public OneOf AsT20, 21 => AsT21, 22 => AsT22, - 23 => mapFunc(AsT23), + 23 => AsT23, 24 => AsT24, 25 => AsT25, 26 => AsT26, - 27 => AsT27, + 27 => mapFunc(AsT27), 28 => AsT28, 29 => AsT29, 30 => AsT30, @@ -1698,8 +3421,9 @@ public OneOf throw new InvalidOperationException() }; } - - public OneOf MapT24(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT27Async(Func> mapFunc) { if (mapFunc == null) { @@ -1731,10 +3455,10 @@ public OneOf AsT21, 22 => AsT22, 23 => AsT23, - 24 => mapFunc(AsT24), + 24 => AsT24, 25 => AsT25, 26 => AsT26, - 27 => AsT27, + 27 => await mapFunc(AsT27), 28 => AsT28, 29 => AsT29, 30 => AsT30, @@ -1742,8 +3466,9 @@ public OneOf throw new InvalidOperationException() }; } +#endif - public OneOf MapT25(Func mapFunc) + public OneOf MapT28(Func mapFunc) { if (mapFunc == null) { @@ -1776,18 +3501,19 @@ public OneOf AsT22, 23 => AsT23, 24 => AsT24, - 25 => mapFunc(AsT25), + 25 => AsT25, 26 => AsT26, 27 => AsT27, - 28 => AsT28, + 28 => mapFunc(AsT28), 29 => AsT29, 30 => AsT30, 31 => AsT31, _ => throw new InvalidOperationException() }; } - - public OneOf MapT26(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT28Async(Func> mapFunc) { if (mapFunc == null) { @@ -1821,17 +3547,18 @@ public OneOf AsT23, 24 => AsT24, 25 => AsT25, - 26 => mapFunc(AsT26), + 26 => AsT26, 27 => AsT27, - 28 => AsT28, + 28 => await mapFunc(AsT28), 29 => AsT29, 30 => AsT30, 31 => AsT31, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT27(Func mapFunc) + public OneOf MapT29(Func mapFunc) { if (mapFunc == null) { @@ -1866,16 +3593,17 @@ public OneOf AsT24, 25 => AsT25, 26 => AsT26, - 27 => mapFunc(AsT27), + 27 => AsT27, 28 => AsT28, - 29 => AsT29, + 29 => mapFunc(AsT29), 30 => AsT30, 31 => AsT31, _ => throw new InvalidOperationException() }; } - - public OneOf MapT28(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT29Async(Func> mapFunc) { if (mapFunc == null) { @@ -1911,15 +3639,16 @@ public OneOf AsT25, 26 => AsT26, 27 => AsT27, - 28 => mapFunc(AsT28), - 29 => AsT29, + 28 => AsT28, + 29 => await mapFunc(AsT29), 30 => AsT30, 31 => AsT31, _ => throw new InvalidOperationException() }; } +#endif - public OneOf MapT29(Func mapFunc) + public OneOf MapT30(Func mapFunc) { if (mapFunc == null) { @@ -1956,14 +3685,15 @@ public OneOf AsT26, 27 => AsT27, 28 => AsT28, - 29 => mapFunc(AsT29), - 30 => AsT30, + 29 => AsT29, + 30 => mapFunc(AsT30), 31 => AsT31, _ => throw new InvalidOperationException() }; } - - public OneOf MapT30(Func mapFunc) + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT30Async(Func> mapFunc) { if (mapFunc == null) { @@ -2001,11 +3731,12 @@ public OneOf AsT27, 28 => AsT28, 29 => AsT29, - 30 => mapFunc(AsT30), + 30 => await mapFunc(AsT30), 31 => AsT31, _ => throw new InvalidOperationException() }; } +#endif public OneOf MapT31(Func mapFunc) { @@ -2051,6 +3782,52 @@ public OneOf> MapT31Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + 10 => AsT10, + 11 => AsT11, + 12 => AsT12, + 13 => AsT13, + 14 => AsT14, + 15 => AsT15, + 16 => AsT16, + 17 => AsT17, + 18 => AsT18, + 19 => AsT19, + 20 => AsT20, + 21 => AsT21, + 22 => AsT22, + 23 => AsT23, + 24 => AsT24, + 25 => AsT25, + 26 => AsT26, + 27 => AsT27, + 28 => AsT28, + 29 => AsT29, + 30 => AsT30, + 31 => await mapFunc(AsT31), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Extended/OneOfT9.generated.cs b/OneOf.Extended/OneOfT9.generated.cs index a1efcd2..a76cbba 100644 --- a/OneOf.Extended/OneOfT9.generated.cs +++ b/OneOf.Extended/OneOfT9.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -168,6 +171,63 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + if (_index == 9 && f9 != null) + { + await f9(_value9); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8, Func f9) { if (_index == 0 && f0 != null) @@ -213,6 +273,53 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8, Func> f9) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + if (_index == 9 && f9 != null) + { + return await f9(_value9); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -246,6 +353,30 @@ public OneOf MapT0(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -268,6 +399,30 @@ public OneOf MapT1(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -290,6 +445,30 @@ public OneOf MapT2(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -312,6 +491,30 @@ public OneOf MapT3(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -334,6 +537,30 @@ public OneOf MapT4(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -356,6 +583,30 @@ public OneOf MapT5(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -378,6 +629,30 @@ public OneOf MapT6(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -400,6 +675,30 @@ public OneOf MapT7(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -422,6 +721,30 @@ public OneOf MapT8(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + 9 => AsT9, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT9(Func mapFunc) { @@ -445,6 +768,30 @@ public OneOf MapT9(Func> MapT9Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + 9 => await mapFunc(AsT9), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf.Tests/MapTests.cs b/OneOf.Tests/MapTests.cs index 45dbfa8..96edb24 100644 --- a/OneOf.Tests/MapTests.cs +++ b/OneOf.Tests/MapTests.cs @@ -1,4 +1,6 @@ -using System.Globalization; +using System; +using System.Globalization; +using System.Threading.Tasks; using NUnit.Framework; using OneOf; @@ -14,10 +16,34 @@ public void MapValue() var resolveString = ResolveString("6"); } + [Test] + [TestCase(2.1, ExpectedResult = "2.1")] + [TestCase(4, ExpectedResult = "4")] + [TestCase("6", ExpectedResult = "6")] + public async Task MapValueAsync(T value) + { + OneOf oneOf = value switch + { + double v => v, + int v => v, + string v => v, + _ => throw new InvalidOperationException("Invalid value type for this OneOf type") + }; + + return await ResolveStringAsync(oneOf); + } + private string ResolveString(OneOf input) => input .MapT0(d => d.ToString(CultureInfo.InvariantCulture)) .MapT1(i => i.ToString(CultureInfo.InvariantCulture)) .Match(t1 => t1, t2 => t2, t3 => t3); + + private async Task ResolveStringAsync(OneOf input) + { + var map1 = await input.MapT0Async(d => Task.FromResult(d.ToString(CultureInfo.InvariantCulture))); + var map2 = await map1.MapT1Async(i => Task.FromResult(i.ToString(CultureInfo.InvariantCulture))); + return await map2.MatchAsync(t1 => Task.FromResult(t1), t2 => Task.FromResult(t2), t3 => Task.FromResult(t3)); + } } } diff --git a/OneOf.Tests/OneOf.Tests.csproj b/OneOf.Tests/OneOf.Tests.csproj index 4598ccc..c4e4560 100644 --- a/OneOf.Tests/OneOf.Tests.csproj +++ b/OneOf.Tests/OneOf.Tests.csproj @@ -2,6 +2,7 @@ net451 + 9.0 @@ -14,4 +15,5 @@ + \ No newline at end of file diff --git a/OneOf/OneOfBaseT0.generated.cs b/OneOf/OneOfBaseT0.generated.cs index 52a7fba..80dfba3 100644 --- a/OneOf/OneOfBaseT0.generated.cs +++ b/OneOf/OneOfBaseT0.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -46,6 +49,18 @@ public void Switch(Action f0) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0) { if (_index == 0 && f0 != null) @@ -55,6 +70,17 @@ public TResult Match(Func f0) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task MatchAsync(Func> f0) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT1.generated.cs b/OneOf/OneOfBaseT1.generated.cs index b5816b4..d4cd6ae 100644 --- a/OneOf/OneOfBaseT1.generated.cs +++ b/OneOf/OneOfBaseT1.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -59,6 +62,23 @@ public void Switch(Action f0, Action f1) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1) { if (_index == 0 && f0 != null) @@ -72,6 +92,21 @@ public TResult Match(Func f0, Func f1) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task MatchAsync(Func> f0, Func> f1) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT2.generated.cs b/OneOf/OneOfBaseT2.generated.cs index d8ed1a8..434c3ed 100644 --- a/OneOf/OneOfBaseT2.generated.cs +++ b/OneOf/OneOfBaseT2.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -72,6 +75,28 @@ public void Switch(Action f0, Action f1, Action f2) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2) { if (_index == 0 && f0 != null) @@ -89,6 +114,25 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT3.generated.cs b/OneOf/OneOfBaseT3.generated.cs index c47bd8e..d39c3e9 100644 --- a/OneOf/OneOfBaseT3.generated.cs +++ b/OneOf/OneOfBaseT3.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -85,6 +88,33 @@ public void Switch(Action f0, Action f1, Action f2, Action f3) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3) { if (_index == 0 && f0 != null) @@ -106,6 +136,29 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT4.generated.cs b/OneOf/OneOfBaseT4.generated.cs index 454c6cf..55e737d 100644 --- a/OneOf/OneOfBaseT4.generated.cs +++ b/OneOf/OneOfBaseT4.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -98,6 +101,38 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4) { if (_index == 0 && f0 != null) @@ -123,6 +158,33 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT5.generated.cs b/OneOf/OneOfBaseT5.generated.cs index feb72c3..5732bc9 100644 --- a/OneOf/OneOfBaseT5.generated.cs +++ b/OneOf/OneOfBaseT5.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -111,6 +114,43 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5) { if (_index == 0 && f0 != null) @@ -140,6 +180,37 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT6.generated.cs b/OneOf/OneOfBaseT6.generated.cs index 607b865..c1fe8c6 100644 --- a/OneOf/OneOfBaseT6.generated.cs +++ b/OneOf/OneOfBaseT6.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -124,6 +127,48 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6) { if (_index == 0 && f0 != null) @@ -157,6 +202,41 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT7.generated.cs b/OneOf/OneOfBaseT7.generated.cs index c30d6bf..4a2624f 100644 --- a/OneOf/OneOfBaseT7.generated.cs +++ b/OneOf/OneOfBaseT7.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -137,6 +140,53 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7) { if (_index == 0 && f0 != null) @@ -174,6 +224,45 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfBaseT8.generated.cs b/OneOf/OneOfBaseT8.generated.cs index 5ee8beb..2dc8392 100644 --- a/OneOf/OneOfBaseT8.generated.cs +++ b/OneOf/OneOfBaseT8.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -150,6 +153,58 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8) { if (_index == 0 && f0 != null) @@ -191,6 +246,49 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + throw new InvalidOperationException(); + } +#endif + diff --git a/OneOf/OneOfT0.generated.cs b/OneOf/OneOfT0.generated.cs index 1f3090b..d116e6f 100644 --- a/OneOf/OneOfT0.generated.cs +++ b/OneOf/OneOfT0.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -42,6 +45,18 @@ public void Switch(Action f0) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0) { if (_index == 0 && f0 != null) @@ -51,6 +66,17 @@ public TResult Match(Func f0) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task MatchAsync(Func> f0) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; @@ -67,6 +93,21 @@ public OneOf MapT0(Func mapFunc) }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + _ => throw new InvalidOperationException() + }; + } +#endif + bool Equals(OneOf other) => _index == other._index && _index switch diff --git a/OneOf/OneOfT1.generated.cs b/OneOf/OneOfT1.generated.cs index e6b645c..9e59883 100644 --- a/OneOf/OneOfT1.generated.cs +++ b/OneOf/OneOfT1.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -56,6 +59,23 @@ public void Switch(Action f0, Action f1) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1) { if (_index == 0 && f0 != null) @@ -69,6 +89,21 @@ public TResult Match(Func f0, Func f1) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task MatchAsync(Func> f0, Func> f1) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; @@ -86,6 +121,22 @@ public OneOf MapT0(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -101,6 +152,22 @@ public OneOf MapT1(Func mapFunc) }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out T1 remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT2.generated.cs b/OneOf/OneOfT2.generated.cs index 9e4e68c..95a01f2 100644 --- a/OneOf/OneOfT2.generated.cs +++ b/OneOf/OneOfT2.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -70,6 +73,28 @@ public void Switch(Action f0, Action f1, Action f2) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2) { if (_index == 0 && f0 != null) @@ -87,6 +112,25 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -106,6 +150,23 @@ public OneOf MapT0(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -121,6 +182,23 @@ public OneOf MapT1(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -137,6 +215,23 @@ public OneOf MapT2(Func mapFunc) }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT3.generated.cs b/OneOf/OneOfT3.generated.cs index b6556fc..07a8036 100644 --- a/OneOf/OneOfT3.generated.cs +++ b/OneOf/OneOfT3.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -84,6 +87,33 @@ public void Switch(Action f0, Action f1, Action f2, Action f3) throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3) { if (_index == 0 && f0 != null) @@ -105,6 +135,29 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -126,6 +179,24 @@ public OneOf MapT0(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -142,6 +213,24 @@ public OneOf MapT1(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -158,6 +247,24 @@ public OneOf MapT2(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -175,6 +282,24 @@ public OneOf MapT3(Func mapFunc) }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT4.generated.cs b/OneOf/OneOfT4.generated.cs index 38245fb..26762d7 100644 --- a/OneOf/OneOfT4.generated.cs +++ b/OneOf/OneOfT4.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -98,6 +101,38 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4) { if (_index == 0 && f0 != null) @@ -123,6 +158,33 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -146,6 +208,25 @@ public OneOf MapT0(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -163,6 +244,25 @@ public OneOf MapT1(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -180,6 +280,25 @@ public OneOf MapT2(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -197,6 +316,25 @@ public OneOf MapT3(Func mapFunc) _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -215,6 +353,25 @@ public OneOf MapT4(Func mapFunc) }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT5.generated.cs b/OneOf/OneOfT5.generated.cs index 83ac23e..b9a71b3 100644 --- a/OneOf/OneOfT5.generated.cs +++ b/OneOf/OneOfT5.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -112,6 +115,43 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5) { if (_index == 0 && f0 != null) @@ -141,6 +181,37 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -166,6 +237,26 @@ public OneOf MapT0(Func mapFu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -184,6 +275,26 @@ public OneOf MapT1(Func mapFu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -202,6 +313,26 @@ public OneOf MapT2(Func mapFu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -220,6 +351,26 @@ public OneOf MapT3(Func mapFu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -238,6 +389,26 @@ public OneOf MapT4(Func mapFu _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -257,6 +428,26 @@ public OneOf MapT5(Func mapFu }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT6.generated.cs b/OneOf/OneOfT6.generated.cs index 9922c8a..07f7005 100644 --- a/OneOf/OneOfT6.generated.cs +++ b/OneOf/OneOfT6.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -126,6 +129,48 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6) { if (_index == 0 && f0 != null) @@ -159,6 +204,41 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -186,6 +266,27 @@ public OneOf MapT0(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -205,6 +306,27 @@ public OneOf MapT1(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -224,6 +346,27 @@ public OneOf MapT2(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -243,6 +386,27 @@ public OneOf MapT3(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -262,6 +426,27 @@ public OneOf MapT4(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -281,6 +466,27 @@ public OneOf MapT5(Func m _ => throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -301,6 +507,27 @@ public OneOf MapT6(Func m }; } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT7.generated.cs b/OneOf/OneOfT7.generated.cs index c0b0160..311ee4a 100644 --- a/OneOf/OneOfT7.generated.cs +++ b/OneOf/OneOfT7.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -140,6 +143,53 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7) { if (_index == 0 && f0 != null) @@ -177,6 +227,45 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -206,6 +295,28 @@ public OneOf MapT0(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -226,6 +337,28 @@ public OneOf MapT1(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -246,6 +379,28 @@ public OneOf MapT2(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -266,6 +421,28 @@ public OneOf MapT3(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -286,6 +463,28 @@ public OneOf MapT4(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -306,6 +505,28 @@ public OneOf MapT5(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -326,6 +547,28 @@ public OneOf MapT6(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -347,6 +590,28 @@ public OneOf MapT7(Func> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default; diff --git a/OneOf/OneOfT8.generated.cs b/OneOf/OneOfT8.generated.cs index e040095..5cb57e9 100644 --- a/OneOf/OneOfT8.generated.cs +++ b/OneOf/OneOfT8.generated.cs @@ -1,5 +1,8 @@ using System; using static OneOf.Functions; +#if NETSTANDARD2_0 || NET40_OR_GREATER +using System.Threading.Tasks; +#endif namespace OneOf { @@ -154,6 +157,58 @@ public void Switch(Action f0, Action f1, Action f2, Action f3, A throw new InvalidOperationException(); } +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task SwitchAsync(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8) + { + if (_index == 0 && f0 != null) + { + await f0(_value0); + return; + } + if (_index == 1 && f1 != null) + { + await f1(_value1); + return; + } + if (_index == 2 && f2 != null) + { + await f2(_value2); + return; + } + if (_index == 3 && f3 != null) + { + await f3(_value3); + return; + } + if (_index == 4 && f4 != null) + { + await f4(_value4); + return; + } + if (_index == 5 && f5 != null) + { + await f5(_value5); + return; + } + if (_index == 6 && f6 != null) + { + await f6(_value6); + return; + } + if (_index == 7 && f7 != null) + { + await f7(_value7); + return; + } + if (_index == 8 && f8 != null) + { + await f8(_value8); + return; + } + throw new InvalidOperationException(); + } +#endif + public TResult Match(Func f0, Func f1, Func f2, Func f3, Func f4, Func f5, Func f6, Func f7, Func f8) { if (_index == 0 && f0 != null) @@ -195,6 +250,49 @@ public TResult Match(Func f0, Func f1, Func MatchAsync(Func> f0, Func> f1, Func> f2, Func> f3, Func> f4, Func> f5, Func> f6, Func> f7, Func> f8) + { + if (_index == 0 && f0 != null) + { + return await f0(_value0); + } + if (_index == 1 && f1 != null) + { + return await f1(_value1); + } + if (_index == 2 && f2 != null) + { + return await f2(_value2); + } + if (_index == 3 && f3 != null) + { + return await f3(_value3); + } + if (_index == 4 && f4 != null) + { + return await f4(_value4); + } + if (_index == 5 && f5 != null) + { + return await f5(_value5); + } + if (_index == 6 && f6 != null) + { + return await f6(_value6); + } + if (_index == 7 && f7 != null) + { + return await f7(_value7); + } + if (_index == 8 && f8 != null) + { + return await f8(_value8); + } + throw new InvalidOperationException(); + } +#endif + public static OneOf FromT0(T0 input) => input; public static OneOf FromT1(T1 input) => input; public static OneOf FromT2(T2 input) => input; @@ -226,6 +324,29 @@ public OneOf MapT0(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT0Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => await mapFunc(AsT0), + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT1(Func mapFunc) { @@ -247,6 +368,29 @@ public OneOf MapT1(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT1Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => await mapFunc(AsT1), + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT2(Func mapFunc) { @@ -268,6 +412,29 @@ public OneOf MapT2(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT2Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => await mapFunc(AsT2), + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT3(Func mapFunc) { @@ -289,6 +456,29 @@ public OneOf MapT3(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT3Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => await mapFunc(AsT3), + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT4(Func mapFunc) { @@ -310,6 +500,29 @@ public OneOf MapT4(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT4Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => await mapFunc(AsT4), + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT5(Func mapFunc) { @@ -331,6 +544,29 @@ public OneOf MapT5(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT5Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => await mapFunc(AsT5), + 6 => AsT6, + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT6(Func mapFunc) { @@ -352,6 +588,29 @@ public OneOf MapT6(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT6Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => await mapFunc(AsT6), + 7 => AsT7, + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT7(Func mapFunc) { @@ -373,6 +632,29 @@ public OneOf MapT7(Func throw new InvalidOperationException() }; } + +#if NETSTANDARD2_0 || NET40_OR_GREATER + public async Task> MapT7Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => await mapFunc(AsT7), + 8 => AsT8, + _ => throw new InvalidOperationException() + }; + } +#endif public OneOf MapT8(Func mapFunc) { @@ -395,6 +677,29 @@ public OneOf MapT8(Func> MapT8Async(Func> mapFunc) + { + if (mapFunc == null) + { + throw new ArgumentNullException(nameof(mapFunc)); + } + return _index switch + { + 0 => AsT0, + 1 => AsT1, + 2 => AsT2, + 3 => AsT3, + 4 => AsT4, + 5 => AsT5, + 6 => AsT6, + 7 => AsT7, + 8 => await mapFunc(AsT8), + _ => throw new InvalidOperationException() + }; + } +#endif + public bool TryPickT0(out T0 value, out OneOf remainder) { value = IsT0 ? AsT0 : default;