|
| 1 | +// <auto-generated /> |
| 2 | +#nullable enable |
| 3 | + |
| 4 | +namespace Thinktecture.Tests; |
| 5 | + |
| 6 | +[global::System.Diagnostics.CodeAnalysis.SuppressMessage("ThinktectureRuntimeExtensionsAnalyzer", "TTRESG1000:Internal Thinktecture.Runtime.Extensions API usage")] |
| 7 | +abstract partial class TestUnion : |
| 8 | + global::Thinktecture.Internal.IMetadataOwner |
| 9 | +{ |
| 10 | + static global::Thinktecture.Internal.Metadata global::Thinktecture.Internal.IMetadataOwner.Metadata { get; } |
| 11 | + = new global::Thinktecture.Internal.Metadata.RegularUnion(typeof(global::Thinktecture.Tests.TestUnion)) |
| 12 | + { |
| 13 | + TypeMembers = new global::System.Collections.Generic.List<global::System.Type> |
| 14 | + { |
| 15 | + typeof(global::Thinktecture.Tests.TestUnion.Child1), |
| 16 | + typeof(global::Thinktecture.Tests.TestUnion.Child1.Child2) |
| 17 | + } |
| 18 | + .AsReadOnly() |
| 19 | + }; |
| 20 | + |
| 21 | + private TestUnion() |
| 22 | + { |
| 23 | + } |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Executes an action depending on the current type. |
| 27 | + /// </summary> |
| 28 | + /// <param name="child1Child2">The action to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1.Child2"/>.</param> |
| 29 | + /// <param name="child1">The action to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1"/>.</param> |
| 30 | + [global::System.Diagnostics.DebuggerStepThroughAttribute] |
| 31 | + public void Switch( |
| 32 | + global::System.Action<global::Thinktecture.Tests.TestUnion.Child1.Child2> @child1Child2, |
| 33 | + global::System.Action<global::Thinktecture.Tests.TestUnion.Child1> @child1) |
| 34 | + { |
| 35 | + switch (this) |
| 36 | + { |
| 37 | + case global::Thinktecture.Tests.TestUnion.Child1.Child2 value: |
| 38 | + @child1Child2(value); |
| 39 | + return; |
| 40 | + case global::Thinktecture.Tests.TestUnion.Child1 value: |
| 41 | + @child1(value); |
| 42 | + return; |
| 43 | + default: |
| 44 | + throw new global::System.ArgumentOutOfRangeException($"Unexpected type '{this.GetType().FullName}'."); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Executes an action depending on the current type. |
| 50 | + /// </summary> |
| 51 | + /// <param name="state">State to be passed to the callbacks.</param> |
| 52 | + /// <param name="child1Child2">The action to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1.Child2"/>.</param> |
| 53 | + /// <param name="child1">The action to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1"/>.</param> |
| 54 | + [global::System.Diagnostics.DebuggerStepThroughAttribute] |
| 55 | + public void Switch<TState>( |
| 56 | + TState @state, |
| 57 | + global::System.Action<TState, global::Thinktecture.Tests.TestUnion.Child1.Child2> @child1Child2, |
| 58 | + global::System.Action<TState, global::Thinktecture.Tests.TestUnion.Child1> @child1) |
| 59 | +#if NET9_0_OR_GREATER |
| 60 | + where TState : allows ref struct |
| 61 | +#endif |
| 62 | + { |
| 63 | + switch (this) |
| 64 | + { |
| 65 | + case global::Thinktecture.Tests.TestUnion.Child1.Child2 value: |
| 66 | + @child1Child2(@state, value); |
| 67 | + return; |
| 68 | + case global::Thinktecture.Tests.TestUnion.Child1 value: |
| 69 | + @child1(@state, value); |
| 70 | + return; |
| 71 | + default: |
| 72 | + throw new global::System.ArgumentOutOfRangeException($"Unexpected type '{this.GetType().FullName}'."); |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + /// <summary> |
| 77 | + /// Executes a function depending on the current type. |
| 78 | + /// </summary> |
| 79 | + /// <param name="child1Child2">The function to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1.Child2"/>.</param> |
| 80 | + /// <param name="child1">The function to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1"/>.</param> |
| 81 | + [global::System.Diagnostics.DebuggerStepThroughAttribute] |
| 82 | + public TResult Switch<TResult>( |
| 83 | + global::System.Func<global::Thinktecture.Tests.TestUnion.Child1.Child2, TResult> @child1Child2, |
| 84 | + global::System.Func<global::Thinktecture.Tests.TestUnion.Child1, TResult> @child1) |
| 85 | +#if NET9_0_OR_GREATER |
| 86 | + where TResult : allows ref struct |
| 87 | +#endif |
| 88 | + { |
| 89 | + switch (this) |
| 90 | + { |
| 91 | + case global::Thinktecture.Tests.TestUnion.Child1.Child2 value: |
| 92 | + return @child1Child2(value); |
| 93 | + case global::Thinktecture.Tests.TestUnion.Child1 value: |
| 94 | + return @child1(value); |
| 95 | + default: |
| 96 | + throw new global::System.ArgumentOutOfRangeException($"Unexpected type '{this.GetType().FullName}'."); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Executes a function depending on the current type. |
| 102 | + /// </summary> |
| 103 | + /// <param name="state">State to be passed to the callbacks.</param> |
| 104 | + /// <param name="child1Child2">The function to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1.Child2"/>.</param> |
| 105 | + /// <param name="child1">The function to execute if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1"/>.</param> |
| 106 | + [global::System.Diagnostics.DebuggerStepThroughAttribute] |
| 107 | + public TResult Switch<TState, TResult>( |
| 108 | + TState @state, |
| 109 | + global::System.Func<TState, global::Thinktecture.Tests.TestUnion.Child1.Child2, TResult> @child1Child2, |
| 110 | + global::System.Func<TState, global::Thinktecture.Tests.TestUnion.Child1, TResult> @child1) |
| 111 | +#if NET9_0_OR_GREATER |
| 112 | + where TResult : allows ref struct |
| 113 | + where TState : allows ref struct |
| 114 | +#endif |
| 115 | + { |
| 116 | + switch (this) |
| 117 | + { |
| 118 | + case global::Thinktecture.Tests.TestUnion.Child1.Child2 value: |
| 119 | + return @child1Child2(@state, value); |
| 120 | + case global::Thinktecture.Tests.TestUnion.Child1 value: |
| 121 | + return @child1(@state, value); |
| 122 | + default: |
| 123 | + throw new global::System.ArgumentOutOfRangeException($"Unexpected type '{this.GetType().FullName}'."); |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | +#pragma warning disable CS0108 // Map in nested union hides Map from base class |
| 128 | + /// <summary> |
| 129 | + /// Maps current instance to an instance of type <typeparamref name="TResult"/>. |
| 130 | + /// </summary> |
| 131 | + /// <param name="child1Child2">The instance to return if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1.Child2"/>.</param> |
| 132 | + /// <param name="child1">The instance to return if the current type is <see cref="global::Thinktecture.Tests.TestUnion.Child1"/>.</param> |
| 133 | + [global::System.Diagnostics.DebuggerStepThroughAttribute] |
| 134 | + public TResult Map<TResult>( |
| 135 | + TResult @child1Child2, |
| 136 | + TResult @child1) |
| 137 | +#if NET9_0_OR_GREATER |
| 138 | + where TResult : allows ref struct |
| 139 | +#endif |
| 140 | + { |
| 141 | + switch (this) |
| 142 | + { |
| 143 | + case global::Thinktecture.Tests.TestUnion.Child1.Child2 value: |
| 144 | + return @child1Child2; |
| 145 | + case global::Thinktecture.Tests.TestUnion.Child1 value: |
| 146 | + return @child1; |
| 147 | + default: |
| 148 | + throw new global::System.ArgumentOutOfRangeException($"Unexpected type '{this.GetType().FullName}'."); |
| 149 | + } |
| 150 | + } |
| 151 | +#pragma warning restore CS0108 // Map in nested union hides Map from base class |
| 152 | +} |
0 commit comments