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