From bb18c040e29ac7edc644759ae661e8a49017da21 Mon Sep 17 00:00:00 2001 From: Alexander Wiedemann Date: Tue, 9 Dec 2025 20:00:41 +0100 Subject: [PATCH 1/5] - add MustUseReturnValue attribute if resharper annotations package is referenced --- .../ResultType.cs | 1114 ++++++++-------- .../ResultTypeWithMerge.cs | 94 +- .../ResultType/Generator.cs | 42 +- .../UnionType/Generator.cs | 2 + ...witch.Generators.ExtendMonadAttribute.g.cs | 28 +- .../FunicularSwitch.Result.g.cs | 1114 ++++++++-------- .../FunicularSwitch.ResultWithMerge.g.cs | 248 ++-- ...ch.Generators.TransformMonadAttribute.g.cs | 28 +- ...witch.Generators.ExtendMonadAttribute.g.cs | 28 +- .../StandardMinLangVersion.Result.g.cs | 1114 ++++++++-------- ...tandardMinLangVersion.ResultWithMerge.g.cs | 248 ++-- ...ch.Generators.TransformMonadAttribute.g.cs | 28 +- ...rdMinLangVersionMyUnionMatchExtension.g.cs | 160 +-- ...monCSharpAccessModifierMatchExtension.g.cs | 214 ++-- ...eFormatterDetectionModeMatchExtension.g.cs | 150 +-- ...ertionsDataRowMatchModeMatchExtension.g.cs | 134 +- ...CyclicReferenceHandlingMatchExtension.g.cs | 134 +- ...EnumEquivalencyHandlingMatchExtension.g.cs | 134 +- ...valencyEqualityStrategyMatchExtension.g.cs | 166 +-- ...alencyEquivalencyResultMatchExtension.g.cs | 134 +- ...ivalencyOrderStrictnessMatchExtension.g.cs | 150 +-- ...itivesTimeSpanConditionMatchExtension.g.cs | 182 +-- ...SpecsPlatformIdentifierMatchExtension.g.cs | 150 +-- ...ConsumerErrorUnionCasesMatchExtension.g.cs | 166 +-- ...lEnumParentInternalEnumMatchExtension.g.cs | 134 +- ...orsConsumerSystemMyEnumMatchExtension.g.cs | 134 +- .../SystemDateTimeKindMatchExtension.g.cs | 150 +-- ...ularSwitch.Generators.Consumer.Writer.g.cs | 102 +- ...witch.Generators.ExtendMonadAttribute.g.cs | 28 +- ...h.Generators.Consumer.OperationResult.g.cs | 1118 +++++++++-------- ...ors.Consumer.OperationResultWithMerge.g.cs | 248 ++-- ...ularSwitch.Generators.Consumer.Result.g.cs | 1118 +++++++++-------- ...h.Generators.Consumer.ResultWithMerge.g.cs | 248 ++-- ...tch.Generators.Consumer.System.Result.g.cs | 1118 +++++++++-------- .../MyNamespace.Result.g.cs | 1118 +++++++++-------- .../MyNamespace.ResultWithMerge.g.cs | 248 ++-- ...itch.Generators.Consumer.OptionResult.g.cs | 240 ++-- ....Generators.Consumer.ResultEnumerable.g.cs | 240 ++-- ...itch.Generators.Consumer.ResultOption.g.cs | 240 ++-- ...itch.Generators.Consumer.WriterResult.g.cs | 160 +-- ...ch.Generators.TransformMonadAttribute.g.cs | 28 +- ...nsumerArgumentExceptionMatchExtension.g.cs | 160 +-- ...eratorsConsumerCardTypeMatchExtension.g.cs | 160 +-- ...GeneratorsConsumerErrorMatchExtension.g.cs | 200 +-- ...neratorsConsumerFailureMatchExtension.g.cs | 160 +-- ...nericResultOfT_TFailureMatchExtension.g.cs | 160 +-- ...eneratorsConsumerIUnionMatchExtension.g.cs | 160 +-- ...SystemArgumentExceptionMatchExtension.g.cs | 160 +-- ...rWithPrimaryConstructorMatchExtension.g.cs | 140 +-- .../TransformerSpecs.cs | 4 +- ...rSwitch.Test.OperationResult.g.verified.cs | 1102 ++++++++-------- ...est.OperationResultWithMerge.g.verified.cs | 204 ++- ...#FunicularSwitch.Test.Result.g.verified.cs | 1102 ++++++++-------- ...rSwitch.Test.ResultWithMerge.g.verified.cs | 204 ++- ...rSwitch.Test.OperationResult.g.verified.cs | 1102 ++++++++-------- ...est.OperationResultWithMerge.g.verified.cs | 204 ++- ...rSwitch.Test.OperationResult.g.verified.cs | 1102 ++++++++-------- ...est.OperationResultWithMerge.g.verified.cs | 204 ++- ...rSwitch.Test.OperationResult.g.verified.cs | 1102 ++++++++-------- ...est.OperationResultWithMerge.g.verified.cs | 204 ++- ...rSwitch.Test.OperationResult.g.verified.cs | 1102 ++++++++-------- ...butes#BaseTypeMatchExtension.g.verified.cs | 4 + ...#FunicularSwitch.Test.MonadA.g.verified.cs | 1102 ++++++++-------- ...#FunicularSwitch.Test.MonadB.g.verified.cs | 1102 ++++++++-------- 64 files changed, 12898 insertions(+), 10880 deletions(-) diff --git a/Source/FunicularSwitch.Generators.Templates/ResultType.cs b/Source/FunicularSwitch.Generators.Templates/ResultType.cs index 76ed661d..9c5923f8 100644 --- a/Source/FunicularSwitch.Generators.Templates/ResultType.cs +++ b/Source/FunicularSwitch.Generators.Templates/ResultType.cs @@ -1,540 +1,606 @@ #nullable enable - -using global::System.Linq; -//additional using directives - + +using global::System.Linq; +//additional using directives + namespace FunicularSwitch.Generators.Templates -{ +{ #pragma warning disable 1591 - public abstract partial class MyResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Error(MyError details) => new MyResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Ok(T value) => new MyResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MyResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Try([global::JetBrains.Annotations.InstantHandle]global::System.Func action, [global::JetBrains.Annotations.InstantHandle]global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Try([global::JetBrains.Annotations.InstantHandle]global::System.Func> action, [global::JetBrains.Annotations.InstantHandle]global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class MyResult : MyResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new MyResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static MyResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MyResult(T value) => MyResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MyResult(MyResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(MyResult result) => result.IsOk; - public static bool operator false(MyResult result) => result.IsError; - - public static bool operator !(MyResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(MyResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MyResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MyResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((MyResult)obj); - } - - public static bool operator ==(MyResult? left, MyResult? right) => Equals(left, right); - - public static bool operator !=(MyResult? left, MyResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match([global::JetBrains.Annotations.InstantHandle]global::System.Action ok, [global::JetBrains.Annotations.InstantHandle]global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match([global::JetBrains.Annotations.InstantHandle]global::System.Func ok, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - { - return this switch - { - Ok_ okMyResult => ok(okMyResult.Value), - Error_ errorMyResult => error(errorMyResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> error) - { - return this switch - { - Ok_ okMyResult => await ok(okMyResult.Value).ConfigureAwait(false), - Error_ errorMyResult => await error(errorMyResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func ok) - { - if (this is Ok_ okMyResult) await ok(okMyResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match([global::JetBrains.Annotations.InstantHandle]global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public MyResult Bind([global::JetBrains.Annotations.InstantHandle]global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class MyResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static MyResult Error(MyError details) => new MyResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MyResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MyResult Ok(T value) => new MyResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MyResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Try([global::JetBrains.Annotations.InstantHandle] global::System.Func action, [global::JetBrains.Annotations.InstantHandle] global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Try([global::JetBrains.Annotations.InstantHandle] global::System.Func> action, [global::JetBrains.Annotations.InstantHandle] global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class MyResult : MyResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + [global::JetBrains.Annotations.MustUseReturnValue] + public new static MyResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static implicit operator MyResult(T value) => MyResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static implicit operator MyResult(MyResultError myResultError) => myResultError.WithOk(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator true(MyResult result) => result.IsOk; + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator false(MyResult result) => result.IsError; + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator !(MyResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(MyResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MyResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MyResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((MyResult)obj); + } + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator ==(MyResult? left, MyResult? right) => Equals(left, right); + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator !=(MyResult? left, MyResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match([global::JetBrains.Annotations.InstantHandle] global::System.Action ok, [global::JetBrains.Annotations.InstantHandle] global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T1 Match([global::JetBrains.Annotations.InstantHandle] global::System.Func ok, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + { + return this switch + { + Ok_ okMyResult => ok(okMyResult.Value), + Error_ errorMyResult => error(errorMyResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> error) + { + return this switch + { + Ok_ okMyResult => await ok(okMyResult.Value).ConfigureAwait(false), + Error_ errorMyResult => await error(errorMyResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func ok) + { + if (this is Ok_ okMyResult) await ok(okMyResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T Match([global::JetBrains.Annotations.InstantHandle] global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public MyResult Bind([global::JetBrains.Annotations.InstantHandle] global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task> Bind([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public MyResult Map([global::JetBrains.Annotations.InstantHandle]global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return MyResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public MyResult Map([global::JetBrains.Annotations.InstantHandle] global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return MyResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return MyResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task> Map( + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return MyResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault([global::JetBrains.Annotations.InstantHandle]global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : MyResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : MyResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public MyResult.Error_ Convert() => new MyResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct MyResultError : global::System.IEquatable - { - readonly MyError _details; - - internal MyResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public MyResult WithOk() => MyResult.Error(_details); - - public bool Equals(MyResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is MyResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(MyResultError left, MyResultError right) => left.Equals(right); - - public static bool operator !=(MyResultError left, MyResultError right) => !left.Equals(right); - } - - public static partial class MyResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> bind) - => Bind(result, async v => MyResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult MapError(this MyResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func mapError) - { - if (result is MyResult.Error_ e) - return MyResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Flatten(this MyResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult As(this MyResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return MyResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult As(this MyResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult Select(this MyResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult SelectMany(this MyResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this MyResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T GetValueOrDefault([global::JetBrains.Annotations.InstantHandle] global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + [global::JetBrains.Annotations.MustUseReturnValue] + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : MyResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : MyResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public MyResult.Error_ Convert() => new MyResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct MyResultError : global::System.IEquatable + { + readonly MyError _details; + + internal MyResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public MyResult WithOk() => MyResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(MyResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is MyResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(MyResultError left, MyResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(MyResultError left, MyResultError right) => !left.Equals(right); + } + + public static partial class MyResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> bind) + => Bind(result, async v => MyResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult MapError(this MyResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func mapError) + { + if (result is MyResult.Error_ e) + return MyResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static MyResult Flatten(this MyResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult As(this MyResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return MyResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult As(this MyResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Select(this MyResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult SelectMany(this MyResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this MyResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Generators.Templates.Extensions -{ - public static partial class MyResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult As(this object? item, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) => - !(item is T t) ? MyResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult NotNull(this T? item, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) => - item ?? MyResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult NotNullOrEmpty(this string? s, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - => string.IsNullOrEmpty(s) ? MyResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MyResult NotNullOrWhiteSpace(this string? s, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? MyResult.Error(error()) : s!; - - public static MyResult First(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func predicate, [global::JetBrains.Annotations.InstantHandle]global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class MyResultExtension + { + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult As(this object? item, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) => + !(item is T t) ? MyResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult NotNull(this T? item, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) => + item ?? MyResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult NotNullOrEmpty(this string? s, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + => string.IsNullOrEmpty(s) ? MyResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult NotNullOrWhiteSpace(this string? s, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? MyResult.Error(error()) : s!; + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult First(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle] global::System.Func predicate, [global::JetBrains.Annotations.InstantHandle] global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/FunicularSwitch.Generators.Templates/ResultTypeWithMerge.cs b/Source/FunicularSwitch.Generators.Templates/ResultTypeWithMerge.cs index f61bdc8a..036e3ce0 100644 --- a/Source/FunicularSwitch.Generators.Templates/ResultTypeWithMerge.cs +++ b/Source/FunicularSwitch.Generators.Templates/ResultTypeWithMerge.cs @@ -12,23 +12,28 @@ public abstract partial class MyResult public static partial class MyResultExtension { - public static MyResult> Map(this global::System.Collections.Generic.IEnumerable> results, + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> Map(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static MyResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> Bind(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static MyResult> Bind(this MyResult result, + results.Select(r => r.Bind(bind)).Aggregate(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> Bind(this MyResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static MyResult Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Bind(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func, MyResult> bind) => - results.Aggregate().Bind(bind); - - public static MyResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; MyError aggregated = default!; @@ -48,27 +53,31 @@ public static MyResult Bind(this global::System.Collections.Generic.I return isError ? MyResult.Error>(aggregated) : MyResult.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - //generated aggregate extension methods - - public static MyResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) + .Aggregate(); + + //generated aggregate extension methods + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -83,15 +92,17 @@ public static MyResult FirstOk(this global::System.Collections.Generic.IEn errors.Add(onEmpty()); return MyResult.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -117,21 +128,25 @@ public static MyResult FirstOk(this global::System.Collections.Generic.IEn } })).ConfigureAwait(false); } - } + } - public static MyResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static MyResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static MyResult Validate(this MyResult item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static MyResult Validate(this T item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Validate(this MyResult item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult Validate(this T item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) { try { @@ -145,9 +160,10 @@ public static MyResult Validate(this T item, [global::JetBrains.Annotation { throw; //createGenericErrorResult } - } + } - public static MyResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static MyResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/FunicularSwitch.Generators/ResultType/Generator.cs b/Source/FunicularSwitch.Generators/ResultType/Generator.cs index cc663af0..1b228872 100644 --- a/Source/FunicularSwitch.Generators/ResultType/Generator.cs +++ b/Source/FunicularSwitch.Generators/ResultType/Generator.cs @@ -9,6 +9,7 @@ static class Generator const string TemplateNamespace = "FunicularSwitch.Generators.Templates"; const string TemplateResultTypeName = "MyResult"; const string TemplateErrorTypeName = "MyError"; + const string MustUseReturnValueAttribute = "[global::JetBrains.Annotations.MustUseReturnValue]"; public static IEnumerable<(string filename, string source)> Emit(ResultTypeSchema resultTypeSchema, SymbolWrapper defaultErrorType, @@ -39,7 +40,8 @@ string Replace(string code, IReadOnlyCollection additionalNamespaces, st { code = code .Replace("[global::JetBrains.Annotations.InstantHandle]", "") - .Replace("[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]", ""); + .Replace("[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]", "") + .Replace(MustUseReturnValueAttribute, ""); } code = code .Replace($"namespace {TemplateNamespace}", $"namespace {resultTypeNamespace}") @@ -132,8 +134,8 @@ string Replace(string code, IReadOnlyCollection additionalNamespaces, st var mergeCode = Replace( Templates.ResultTypeTemplates.ResultTypeWithMerge - .Replace("//generated aggregate methods", GenerateAggregateMethods(10)) - .Replace("//generated aggregate extension methods", GenerateAggregateExtensionMethods(10, isValueType)) + .Replace("//generated aggregate methods", GenerateAggregateMethods(10, referencesJetBrainsAnnotations)) + .Replace("//generated aggregate extension methods", GenerateAggregateExtensionMethods(10, isValueType, referencesJetBrainsAnnotations)) .Replace("Merge__MemberOrExtensionMethod", mergeErrorMethod.MethodName), additionalNamespaces, "T" @@ -143,8 +145,9 @@ string Replace(string code, IReadOnlyCollection additionalNamespaces, st } } - static string GenerateAggregateExtensionMethods(int maxParameterCount, bool isValueType) => Generate(maxParameterCount, i => MakeAggregateExtensionMethod(i, isValueType)); - static string GenerateAggregateMethods(int maxParameterCount) => Generate(maxParameterCount, GenerateAggregateMethod); + static string GenerateAggregateExtensionMethods(int maxParameterCount, bool isValueType, bool referencesJetBrainsAnnotations) => Generate(maxParameterCount, i => MakeAggregateExtensionMethod(i, isValueType, referencesJetBrainsAnnotations)); + static string GenerateAggregateMethods(int maxParameterCount, bool referencesJetBrainsAnnotations) => Generate(maxParameterCount, + i => GenerateAggregateMethod(i, referencesJetBrainsAnnotations)); static string Generate(int maxParameterCount, Func generateMethods) => @@ -153,7 +156,7 @@ static string Generate(int maxParameterCount, Func generateMethods) .Select(generateMethods) .ToSeparatedString("\n"); - static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueType) + static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueType, bool referencesJetBrainsAnnotations) { var range = Enumerable.Range(1, typeParameterCount).ToImmutableArray(); string Expand(Func strAtIndex, string separator = ", ") => range.Select(strAtIndex).ToSeparatedString(separator); @@ -172,10 +175,13 @@ static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueT var taskResultArrayElements = Expand(i => $"r{i}.Result"); var tupleArguments = Expand(i => $"v{i}"); + var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? MustUseReturnValueAttribute : ""; return $@" - public static MyResult<({typeArguments})> Aggregate<{typeArguments}>(this {parameterDeclarations}) => + {mustUseReturnValueAttribute} + public static MyResult<({typeArguments})> Aggregate<{typeArguments}>(this {parameterDeclarations}) => Aggregate({resultArrayElements}, ({tupleArguments}) => ({tupleArguments})); + {mustUseReturnValueAttribute} public static MyResult Aggregate<{typeArgumentsWithResult}>(this {parametersWithCombine}) {{ if ({okCheck}) @@ -188,9 +194,11 @@ static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueT )!); }} + {mustUseReturnValueAttribute} public static global::System.Threading.Tasks.Task> Aggregate<{typeArguments}>(this {taskParameterDeclarations}) => Aggregate({resultArrayElements}, ({tupleArguments}) => ({tupleArguments})); - + + {mustUseReturnValueAttribute} public static async global::System.Threading.Tasks.Task> Aggregate<{typeArgumentsWithResult}>(this {taskParameterDeclarations}, global::System.Func<{typeArgumentsWithResult}> combine) {{ await global::System.Threading.Tasks.Task.WhenAll({resultArrayElements}); @@ -198,7 +206,7 @@ static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueT }}"; } - public static string GenerateAggregateMethod(int typeParameterCount) + public static string GenerateAggregateMethod(int typeParameterCount, bool referencesJetBrainsAnnotations) { var range = Enumerable.Range(1, typeParameterCount).ToImmutableArray(); string Expand(Func strAtIndex, string separator = ", ") => range.Select(strAtIndex).ToSeparatedString(separator); @@ -206,15 +214,21 @@ public static string GenerateAggregateMethod(int typeParameterCount) var typeParameters = Expand(i => $"T{i}"); var parameterDeclarations = Expand(i => $"MyResult r{i}"); var taskParameterDeclarations = Expand(i => $"global::System.Threading.Tasks.Task> r{i}"); - var parameters = Expand(i => $"r{i}"); + var parameters = Expand(i => $"r{i}"); - return $@" - public static MyResult<({typeParameters})> Aggregate<{typeParameters}>({parameterDeclarations}) => MyResultExtension.Aggregate({parameters}); + var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? MustUseReturnValueAttribute : ""; + return $@" + {mustUseReturnValueAttribute} + public static MyResult<({typeParameters})> Aggregate<{typeParameters}>({parameterDeclarations}) => MyResultExtension.Aggregate({parameters}); + + {mustUseReturnValueAttribute} public static MyResult Aggregate<{typeParameters}, TResult>({parameterDeclarations}, global::System.Func<{typeParameters}, TResult> combine) => MyResultExtension.Aggregate({parameters}, combine); - + + {mustUseReturnValueAttribute} public static global::System.Threading.Tasks.Task> Aggregate<{typeParameters}>({taskParameterDeclarations}) => MyResultExtension.Aggregate({parameters}); - + + {mustUseReturnValueAttribute} public static global::System.Threading.Tasks.Task> Aggregate<{typeParameters}, TResult>({taskParameterDeclarations}, global::System.Func<{typeParameters}, TResult> combine) => MyResultExtension.Aggregate({parameters}, combine);"; } } \ No newline at end of file diff --git a/Source/FunicularSwitch.Generators/UnionType/Generator.cs b/Source/FunicularSwitch.Generators/UnionType/Generator.cs index 7c66471a..b1feb309 100644 --- a/Source/FunicularSwitch.Generators/UnionType/Generator.cs +++ b/Source/FunicularSwitch.Generators/UnionType/Generator.cs @@ -12,6 +12,7 @@ public static class Generator private const string MatchMethodName = "Match"; private const string InstantHandleAttribute = "[global::JetBrains.Annotations.InstantHandle]"; private const string InstantHandleRequireAwaitAttribute = "[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]"; + private const string MustUseReturnValueAttribute = "global::JetBrains.Annotations.MustUseReturnValue"; private const string DebuggerStepThroughAttribute = "global::System.Diagnostics.DebuggerStepThrough"; public static (string filename, string source) Emit( @@ -304,6 +305,7 @@ static void WriteMatchSignature( var typeParameterList = unionTypeSchema.TypeParameters.Concat([t]).ToSeparatedString(); builder.WriteAttribute(DebuggerStepThroughAttribute); + if (hasJetBrainsAnnotationsReference) builder.WriteAttribute(MustUseReturnValueAttribute); builder.WriteMethodSignature( modifiers: modifiers, returnType: returnType, diff --git a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs index 622189e4..9ff9ed82 100644 --- a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs +++ b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class ExtendMonadAttribute : Attribute - { - public ExtendMonadAttribute() { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class ExtendMonadAttribute : Attribute + { + public ExtendMonadAttribute() { } + } +} diff --git a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs index 074f7314..db67e134 100644 --- a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs +++ b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs @@ -1,540 +1,606 @@ #nullable enable - -using global::System.Linq; -using System; - + +using global::System.Linq; +using System; + namespace FunicularSwitch -{ +{ #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(String details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(String details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract String? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(String message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(String details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(String details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract String? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(String message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public String Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(String details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly String _details; - - internal ResultError(String details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public String Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(String details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly String _details; + + internal ResultError(String details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Extensions -{ - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.ResultWithMerge.g.cs b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.ResultWithMerge.g.cs index 33ef4819..9d1bb872 100644 --- a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.ResultWithMerge.g.cs +++ b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.ResultWithMerge.g.cs @@ -8,90 +8,135 @@ namespace FunicularSwitch public abstract partial class Result { - public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result Aggregate(Result r1, Result r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => ResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result Aggregate(Result r1, Result r2, Result r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => ResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => ResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class ResultExtension { - public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static Result> Bind(this Result result, + results.Select(r => r.Bind(bind)).Aggregate(); + + + public static Result> Bind(this Result result, global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + + public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, Result> bind) => - results.Aggregate().Bind(bind); - - public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + + public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; String aggregated = default!; @@ -111,28 +156,33 @@ public static Result Bind(this global::System.Collections.Generic.IEn return isError ? Result.Error>(aggregated) : Result.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - - public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => + .Aggregate(); + + + + public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static Result Aggregate(this Result r1, Result r2, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2) @@ -145,18 +195,22 @@ public static Result Aggregate(this Result r1, Res )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => + + public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static Result Aggregate(this Result r1, Result r2, Result r3, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3) @@ -169,18 +223,22 @@ public static Result Aggregate(this Result r1, )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => + + public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4) @@ -193,18 +251,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5) @@ -217,18 +279,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6) @@ -241,18 +307,22 @@ public static Result Aggregate(this Re )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7) @@ -265,18 +335,22 @@ public static Result Aggregate(thi )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8) @@ -289,18 +363,22 @@ public static Result Aggregate )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8 && r9 is Result.Ok_ ok9) @@ -313,16 +391,19 @@ public static Result Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); - } - - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + } + + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -337,15 +418,17 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum errors.Add(onEmpty()); return Result.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -371,21 +454,25 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum } })).ConfigureAwait(false); } - } + } - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static Result Validate(this T item, global::System.Func> validate) + + public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + + public static Result Validate(this T item, global::System.Func> validate) { try { @@ -399,9 +486,10 @@ public static Result Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs index c566832f..270984ae 100644 --- a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs +++ b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class TransformMonadAttribute : Attribute - { - public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class TransformMonadAttribute : Attribute + { + public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs index 622189e4..9ff9ed82 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class ExtendMonadAttribute : Attribute - { - public ExtendMonadAttribute() { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class ExtendMonadAttribute : Attribute + { + public ExtendMonadAttribute() { } + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs index 8370142b..b8f08246 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs @@ -1,540 +1,606 @@ #nullable enable - -using global::System.Linq; -using System; - + +using global::System.Linq; +using System; + namespace StandardMinLangVersion -{ +{ #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(String details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(String details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract String? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(String message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(String details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(String details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract String? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(String message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public String Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(String details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly String _details; - - internal ResultError(String details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public String Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(String details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly String _details; + + internal ResultError(String details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace StandardMinLangVersion.Extensions -{ - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.ResultWithMerge.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.ResultWithMerge.g.cs index c9bf8ff6..051ccea8 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.ResultWithMerge.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.ResultWithMerge.g.cs @@ -8,90 +8,135 @@ namespace StandardMinLangVersion public abstract partial class Result { - public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result Aggregate(Result r1, Result r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => ResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result Aggregate(Result r1, Result r2, Result r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => ResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => ResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class ResultExtension { - public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static Result> Bind(this Result result, + results.Select(r => r.Bind(bind)).Aggregate(); + + + public static Result> Bind(this Result result, global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + + public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, Result> bind) => - results.Aggregate().Bind(bind); - - public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + + public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; String aggregated = default!; @@ -111,28 +156,33 @@ public static Result Bind(this global::System.Collections.Generic.IEn return isError ? Result.Error>(aggregated) : Result.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - - public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => + .Aggregate(); + + + + public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static Result Aggregate(this Result r1, Result r2, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2) @@ -145,18 +195,22 @@ public static Result Aggregate(this Result r1, Res )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => + + public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static Result Aggregate(this Result r1, Result r2, Result r3, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3) @@ -169,18 +223,22 @@ public static Result Aggregate(this Result r1, )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => + + public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4) @@ -193,18 +251,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5) @@ -217,18 +279,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6) @@ -241,18 +307,22 @@ public static Result Aggregate(this Re )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7) @@ -265,18 +335,22 @@ public static Result Aggregate(thi )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8) @@ -289,18 +363,22 @@ public static Result Aggregate )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8 && r9 is Result.Ok_ ok9) @@ -313,16 +391,19 @@ public static Result Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); - } - - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + } + + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -337,15 +418,17 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum errors.Add(onEmpty()); return Result.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -371,21 +454,25 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum } })).ConfigureAwait(false); } - } + } - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static Result Validate(this T item, global::System.Func> validate) + + public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + + public static Result Validate(this T item, global::System.Func> validate) { try { @@ -399,9 +486,10 @@ public static Result Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs index c566832f..270984ae 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class TransformMonadAttribute : Attribute - { - public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class TransformMonadAttribute : Attribute + { + public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/StandardMinLangVersionMyUnionMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/StandardMinLangVersionMyUnionMatchExtension.g.cs index 260c0e12..db8b9002 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/StandardMinLangVersionMyUnionMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/StandardMinLangVersionMyUnionMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace StandardMinLangVersion -{ +{ public static partial class MyUnionMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func case1, global::System.Func case2) => - myUnion switch - { - StandardMinLangVersion.MyUnion.Case1_ case11 => case1(case11), - StandardMinLangVersion.MyUnion.MyUnionCase2 case22 => case2(case22), - _ => throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task Match(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func> case1, global::System.Func> case2) => - myUnion switch - { - StandardMinLangVersion.MyUnion.Case1_ case11 => case1(case11), - StandardMinLangVersion.MyUnion.MyUnionCase2 case22 => case2(case22), - _ => throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myUnion, global::System.Func case1, global::System.Func case2) => - (await myUnion.ConfigureAwait(false)).Match(case1, case2); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myUnion, global::System.Func> case1, global::System.Func> case2) => - await (await myUnion.ConfigureAwait(false)).Match(case1, case2).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Action case1, global::System.Action case2) - { - switch (myUnion) - { - case StandardMinLangVersion.MyUnion.Case1_ case11: - case1(case11); - break; - case StandardMinLangVersion.MyUnion.MyUnionCase2 case22: - case2(case22); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func case1, global::System.Func case2) - { - switch (myUnion) - { - case StandardMinLangVersion.MyUnion.Case1_ case11: - await case1(case11).ConfigureAwait(false); - break; - case StandardMinLangVersion.MyUnion.MyUnionCase2 case22: - await case2(case22).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myUnion, global::System.Action case1, global::System.Action case2) => - (await myUnion.ConfigureAwait(false)).Switch(case1, case2); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myUnion, global::System.Func case1, global::System.Func case2) => - await (await myUnion.ConfigureAwait(false)).Switch(case1, case2).ConfigureAwait(false); - } - - public abstract partial class MyUnion - { - [global::System.Diagnostics.DebuggerStepThrough] - public static StandardMinLangVersion.MyUnion Case1() => new StandardMinLangVersion.MyUnion.Case1_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static StandardMinLangVersion.MyUnion Case2() => new StandardMinLangVersion.MyUnion.MyUnionCase2(); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func case1, global::System.Func case2) => + myUnion switch + { + StandardMinLangVersion.MyUnion.Case1_ case11 => case1(case11), + StandardMinLangVersion.MyUnion.MyUnionCase2 case22 => case2(case22), + _ => throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func> case1, global::System.Func> case2) => + myUnion switch + { + StandardMinLangVersion.MyUnion.Case1_ case11 => await case1(case11).ConfigureAwait(false), + StandardMinLangVersion.MyUnion.MyUnionCase2 case22 => await case2(case22).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myUnion, global::System.Func case1, global::System.Func case2) => + (await myUnion.ConfigureAwait(false)).Match(case1, case2); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myUnion, global::System.Func> case1, global::System.Func> case2) => + await (await myUnion.ConfigureAwait(false)).Match(case1, case2).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Action case1, global::System.Action case2) + { + switch (myUnion) + { + case StandardMinLangVersion.MyUnion.Case1_ case11: + case1(case11); + break; + case StandardMinLangVersion.MyUnion.MyUnionCase2 case22: + case2(case22); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::StandardMinLangVersion.MyUnion myUnion, global::System.Func case1, global::System.Func case2) + { + switch (myUnion) + { + case StandardMinLangVersion.MyUnion.Case1_ case11: + await case1(case11).ConfigureAwait(false); + break; + case StandardMinLangVersion.MyUnion.MyUnionCase2 case22: + await case2(case22).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from StandardMinLangVersion.MyUnion: {myUnion.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myUnion, global::System.Action case1, global::System.Action case2) => + (await myUnion.ConfigureAwait(false)).Switch(case1, case2); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myUnion, global::System.Func case1, global::System.Func case2) => + await (await myUnion.ConfigureAwait(false)).Switch(case1, case2).ConfigureAwait(false); + } + + public abstract partial class MyUnion + { + [global::System.Diagnostics.DebuggerStepThrough] + public static StandardMinLangVersion.MyUnion Case1() => new StandardMinLangVersion.MyUnion.Case1_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static StandardMinLangVersion.MyUnion Case2() => new StandardMinLangVersion.MyUnion.MyUnionCase2(); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonCSharpAccessModifierMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonCSharpAccessModifierMatchExtension.g.cs index 920f08e5..46d3c79a 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonCSharpAccessModifierMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonCSharpAccessModifierMatchExtension.g.cs @@ -1,105 +1,113 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Common -{ +{ internal static partial class CSharpAccessModifierMatchExtension - { - public static T Match(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => - cSharpAccessModifier switch - { - FluentAssertions.Common.CSharpAccessModifier.Internal => @internal(), - FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp => invalidForCSharp(), - FluentAssertions.Common.CSharpAccessModifier.Private => @private(), - FluentAssertions.Common.CSharpAccessModifier.PrivateProtected => privateProtected(), - FluentAssertions.Common.CSharpAccessModifier.Protected => @protected(), - FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal => protectedInternal(), - FluentAssertions.Common.CSharpAccessModifier.Public => @public(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func> @internal, global::System.Func> invalidForCSharp, global::System.Func> @private, global::System.Func> privateProtected, global::System.Func> @protected, global::System.Func> protectedInternal, global::System.Func> @public) => - cSharpAccessModifier switch - { - FluentAssertions.Common.CSharpAccessModifier.Internal => @internal(), - FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp => invalidForCSharp(), - FluentAssertions.Common.CSharpAccessModifier.Private => @private(), - FluentAssertions.Common.CSharpAccessModifier.PrivateProtected => privateProtected(), - FluentAssertions.Common.CSharpAccessModifier.Protected => @protected(), - FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal => protectedInternal(), - FluentAssertions.Common.CSharpAccessModifier.Public => @public(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => - (await cSharpAccessModifier.ConfigureAwait(false)).Match(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func> @internal, global::System.Func> invalidForCSharp, global::System.Func> @private, global::System.Func> privateProtected, global::System.Func> @protected, global::System.Func> protectedInternal, global::System.Func> @public) => - await (await cSharpAccessModifier.ConfigureAwait(false)).Match(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Action @internal, global::System.Action invalidForCSharp, global::System.Action @private, global::System.Action privateProtected, global::System.Action @protected, global::System.Action protectedInternal, global::System.Action @public) - { - switch (cSharpAccessModifier) - { - case FluentAssertions.Common.CSharpAccessModifier.Internal: - @internal(); - break; - case FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp: - invalidForCSharp(); - break; - case FluentAssertions.Common.CSharpAccessModifier.Private: - @private(); - break; - case FluentAssertions.Common.CSharpAccessModifier.PrivateProtected: - privateProtected(); - break; - case FluentAssertions.Common.CSharpAccessModifier.Protected: - @protected(); - break; - case FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal: - protectedInternal(); - break; - case FluentAssertions.Common.CSharpAccessModifier.Public: - @public(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) - { - switch (cSharpAccessModifier) - { - case FluentAssertions.Common.CSharpAccessModifier.Internal: - await @internal().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp: - await invalidForCSharp().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.Private: - await @private().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.PrivateProtected: - await privateProtected().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.Protected: - await @protected().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal: - await protectedInternal().ConfigureAwait(false); - break; - case FluentAssertions.Common.CSharpAccessModifier.Public: - await @public().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Action @internal, global::System.Action invalidForCSharp, global::System.Action @private, global::System.Action privateProtected, global::System.Action @protected, global::System.Action protectedInternal, global::System.Action @public) => - (await cSharpAccessModifier.ConfigureAwait(false)).Switch(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => - await (await cSharpAccessModifier.ConfigureAwait(false)).Switch(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => + cSharpAccessModifier switch + { + FluentAssertions.Common.CSharpAccessModifier.Internal => @internal(), + FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp => invalidForCSharp(), + FluentAssertions.Common.CSharpAccessModifier.Private => @private(), + FluentAssertions.Common.CSharpAccessModifier.PrivateProtected => privateProtected(), + FluentAssertions.Common.CSharpAccessModifier.Protected => @protected(), + FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal => protectedInternal(), + FluentAssertions.Common.CSharpAccessModifier.Public => @public(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func> @internal, global::System.Func> invalidForCSharp, global::System.Func> @private, global::System.Func> privateProtected, global::System.Func> @protected, global::System.Func> protectedInternal, global::System.Func> @public) => + cSharpAccessModifier switch + { + FluentAssertions.Common.CSharpAccessModifier.Internal => await @internal().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp => await invalidForCSharp().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.Private => await @private().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.PrivateProtected => await privateProtected().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.Protected => await @protected().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal => await protectedInternal().ConfigureAwait(false), + FluentAssertions.Common.CSharpAccessModifier.Public => await @public().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => + (await cSharpAccessModifier.ConfigureAwait(false)).Match(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func> @internal, global::System.Func> invalidForCSharp, global::System.Func> @private, global::System.Func> privateProtected, global::System.Func> @protected, global::System.Func> protectedInternal, global::System.Func> @public) => + await (await cSharpAccessModifier.ConfigureAwait(false)).Match(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Action @internal, global::System.Action invalidForCSharp, global::System.Action @private, global::System.Action privateProtected, global::System.Action @protected, global::System.Action protectedInternal, global::System.Action @public) + { + switch (cSharpAccessModifier) + { + case FluentAssertions.Common.CSharpAccessModifier.Internal: + @internal(); + break; + case FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp: + invalidForCSharp(); + break; + case FluentAssertions.Common.CSharpAccessModifier.Private: + @private(); + break; + case FluentAssertions.Common.CSharpAccessModifier.PrivateProtected: + privateProtected(); + break; + case FluentAssertions.Common.CSharpAccessModifier.Protected: + @protected(); + break; + case FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal: + protectedInternal(); + break; + case FluentAssertions.Common.CSharpAccessModifier.Public: + @public(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Common.CSharpAccessModifier cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) + { + switch (cSharpAccessModifier) + { + case FluentAssertions.Common.CSharpAccessModifier.Internal: + await @internal().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.InvalidForCSharp: + await invalidForCSharp().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.Private: + await @private().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.PrivateProtected: + await privateProtected().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.Protected: + await @protected().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.ProtectedInternal: + await protectedInternal().ConfigureAwait(false); + break; + case FluentAssertions.Common.CSharpAccessModifier.Public: + await @public().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.CSharpAccessModifier: {cSharpAccessModifier.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Action @internal, global::System.Action invalidForCSharp, global::System.Action @private, global::System.Action privateProtected, global::System.Action @protected, global::System.Action protectedInternal, global::System.Action @public) => + (await cSharpAccessModifier.ConfigureAwait(false)).Switch(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cSharpAccessModifier, global::System.Func @internal, global::System.Func invalidForCSharp, global::System.Func @private, global::System.Func privateProtected, global::System.Func @protected, global::System.Func protectedInternal, global::System.Func @public) => + await (await cSharpAccessModifier.ConfigureAwait(false)).Switch(@internal, invalidForCSharp, @private, privateProtected, @protected, protectedInternal, @public).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonValueFormatterDetectionModeMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonValueFormatterDetectionModeMatchExtension.g.cs index 8bbf6f6b..d1d7e420 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonValueFormatterDetectionModeMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsCommonValueFormatterDetectionModeMatchExtension.g.cs @@ -1,73 +1,81 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Common -{ +{ internal static partial class ValueFormatterDetectionModeMatchExtension - { - public static T Match(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => - valueFormatterDetectionMode switch - { - FluentAssertions.Common.ValueFormatterDetectionMode.Disabled => disabled(), - FluentAssertions.Common.ValueFormatterDetectionMode.Scan => scan(), - FluentAssertions.Common.ValueFormatterDetectionMode.Specific => specific(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func> disabled, global::System.Func> scan, global::System.Func> specific) => - valueFormatterDetectionMode switch - { - FluentAssertions.Common.ValueFormatterDetectionMode.Disabled => disabled(), - FluentAssertions.Common.ValueFormatterDetectionMode.Scan => scan(), - FluentAssertions.Common.ValueFormatterDetectionMode.Specific => specific(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => - (await valueFormatterDetectionMode.ConfigureAwait(false)).Match(disabled, scan, specific); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func> disabled, global::System.Func> scan, global::System.Func> specific) => - await (await valueFormatterDetectionMode.ConfigureAwait(false)).Match(disabled, scan, specific).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Action disabled, global::System.Action scan, global::System.Action specific) - { - switch (valueFormatterDetectionMode) - { - case FluentAssertions.Common.ValueFormatterDetectionMode.Disabled: - disabled(); - break; - case FluentAssertions.Common.ValueFormatterDetectionMode.Scan: - scan(); - break; - case FluentAssertions.Common.ValueFormatterDetectionMode.Specific: - specific(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) - { - switch (valueFormatterDetectionMode) - { - case FluentAssertions.Common.ValueFormatterDetectionMode.Disabled: - await disabled().ConfigureAwait(false); - break; - case FluentAssertions.Common.ValueFormatterDetectionMode.Scan: - await scan().ConfigureAwait(false); - break; - case FluentAssertions.Common.ValueFormatterDetectionMode.Specific: - await specific().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Action disabled, global::System.Action scan, global::System.Action specific) => - (await valueFormatterDetectionMode.ConfigureAwait(false)).Switch(disabled, scan, specific); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => - await (await valueFormatterDetectionMode.ConfigureAwait(false)).Switch(disabled, scan, specific).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => + valueFormatterDetectionMode switch + { + FluentAssertions.Common.ValueFormatterDetectionMode.Disabled => disabled(), + FluentAssertions.Common.ValueFormatterDetectionMode.Scan => scan(), + FluentAssertions.Common.ValueFormatterDetectionMode.Specific => specific(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func> disabled, global::System.Func> scan, global::System.Func> specific) => + valueFormatterDetectionMode switch + { + FluentAssertions.Common.ValueFormatterDetectionMode.Disabled => await disabled().ConfigureAwait(false), + FluentAssertions.Common.ValueFormatterDetectionMode.Scan => await scan().ConfigureAwait(false), + FluentAssertions.Common.ValueFormatterDetectionMode.Specific => await specific().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => + (await valueFormatterDetectionMode.ConfigureAwait(false)).Match(disabled, scan, specific); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func> disabled, global::System.Func> scan, global::System.Func> specific) => + await (await valueFormatterDetectionMode.ConfigureAwait(false)).Match(disabled, scan, specific).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Action disabled, global::System.Action scan, global::System.Action specific) + { + switch (valueFormatterDetectionMode) + { + case FluentAssertions.Common.ValueFormatterDetectionMode.Disabled: + disabled(); + break; + case FluentAssertions.Common.ValueFormatterDetectionMode.Scan: + scan(); + break; + case FluentAssertions.Common.ValueFormatterDetectionMode.Specific: + specific(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Common.ValueFormatterDetectionMode valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) + { + switch (valueFormatterDetectionMode) + { + case FluentAssertions.Common.ValueFormatterDetectionMode.Disabled: + await disabled().ConfigureAwait(false); + break; + case FluentAssertions.Common.ValueFormatterDetectionMode.Scan: + await scan().ConfigureAwait(false); + break; + case FluentAssertions.Common.ValueFormatterDetectionMode.Specific: + await specific().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Common.ValueFormatterDetectionMode: {valueFormatterDetectionMode.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Action disabled, global::System.Action scan, global::System.Action specific) => + (await valueFormatterDetectionMode.ConfigureAwait(false)).Switch(disabled, scan, specific); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task valueFormatterDetectionMode, global::System.Func disabled, global::System.Func scan, global::System.Func specific) => + await (await valueFormatterDetectionMode.ConfigureAwait(false)).Switch(disabled, scan, specific).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsDataRowMatchModeMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsDataRowMatchModeMatchExtension.g.cs index d7c3a67f..e609296a 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsDataRowMatchModeMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsDataRowMatchModeMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Data -{ +{ internal static partial class RowMatchModeMatchExtension - { - public static T Match(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func index, global::System.Func primaryKey) => - rowMatchMode switch - { - FluentAssertions.Data.RowMatchMode.Index => index(), - FluentAssertions.Data.RowMatchMode.PrimaryKey => primaryKey(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func> index, global::System.Func> primaryKey) => - rowMatchMode switch - { - FluentAssertions.Data.RowMatchMode.Index => index(), - FluentAssertions.Data.RowMatchMode.PrimaryKey => primaryKey(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func index, global::System.Func primaryKey) => - (await rowMatchMode.ConfigureAwait(false)).Match(index, primaryKey); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func> index, global::System.Func> primaryKey) => - await (await rowMatchMode.ConfigureAwait(false)).Match(index, primaryKey).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Action index, global::System.Action primaryKey) - { - switch (rowMatchMode) - { - case FluentAssertions.Data.RowMatchMode.Index: - index(); - break; - case FluentAssertions.Data.RowMatchMode.PrimaryKey: - primaryKey(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func index, global::System.Func primaryKey) - { - switch (rowMatchMode) - { - case FluentAssertions.Data.RowMatchMode.Index: - await index().ConfigureAwait(false); - break; - case FluentAssertions.Data.RowMatchMode.PrimaryKey: - await primaryKey().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Action index, global::System.Action primaryKey) => - (await rowMatchMode.ConfigureAwait(false)).Switch(index, primaryKey); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func index, global::System.Func primaryKey) => - await (await rowMatchMode.ConfigureAwait(false)).Switch(index, primaryKey).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func index, global::System.Func primaryKey) => + rowMatchMode switch + { + FluentAssertions.Data.RowMatchMode.Index => index(), + FluentAssertions.Data.RowMatchMode.PrimaryKey => primaryKey(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func> index, global::System.Func> primaryKey) => + rowMatchMode switch + { + FluentAssertions.Data.RowMatchMode.Index => await index().ConfigureAwait(false), + FluentAssertions.Data.RowMatchMode.PrimaryKey => await primaryKey().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func index, global::System.Func primaryKey) => + (await rowMatchMode.ConfigureAwait(false)).Match(index, primaryKey); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func> index, global::System.Func> primaryKey) => + await (await rowMatchMode.ConfigureAwait(false)).Match(index, primaryKey).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Action index, global::System.Action primaryKey) + { + switch (rowMatchMode) + { + case FluentAssertions.Data.RowMatchMode.Index: + index(); + break; + case FluentAssertions.Data.RowMatchMode.PrimaryKey: + primaryKey(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Data.RowMatchMode rowMatchMode, global::System.Func index, global::System.Func primaryKey) + { + switch (rowMatchMode) + { + case FluentAssertions.Data.RowMatchMode.Index: + await index().ConfigureAwait(false); + break; + case FluentAssertions.Data.RowMatchMode.PrimaryKey: + await primaryKey().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Data.RowMatchMode: {rowMatchMode.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Action index, global::System.Action primaryKey) => + (await rowMatchMode.ConfigureAwait(false)).Switch(index, primaryKey); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task rowMatchMode, global::System.Func index, global::System.Func primaryKey) => + await (await rowMatchMode.ConfigureAwait(false)).Switch(index, primaryKey).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyCyclicReferenceHandlingMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyCyclicReferenceHandlingMatchExtension.g.cs index f7b0472a..b36dcbf0 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyCyclicReferenceHandlingMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyCyclicReferenceHandlingMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Equivalency -{ +{ internal static partial class CyclicReferenceHandlingMatchExtension - { - public static T Match(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => - cyclicReferenceHandling switch - { - FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore => ignore(), - FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException => throwException(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func> ignore, global::System.Func> throwException) => - cyclicReferenceHandling switch - { - FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore => ignore(), - FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException => throwException(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => - (await cyclicReferenceHandling.ConfigureAwait(false)).Match(ignore, throwException); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func> ignore, global::System.Func> throwException) => - await (await cyclicReferenceHandling.ConfigureAwait(false)).Match(ignore, throwException).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Action ignore, global::System.Action throwException) - { - switch (cyclicReferenceHandling) - { - case FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore: - ignore(); - break; - case FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException: - throwException(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) - { - switch (cyclicReferenceHandling) - { - case FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore: - await ignore().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException: - await throwException().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Action ignore, global::System.Action throwException) => - (await cyclicReferenceHandling.ConfigureAwait(false)).Switch(ignore, throwException); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => - await (await cyclicReferenceHandling.ConfigureAwait(false)).Switch(ignore, throwException).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => + cyclicReferenceHandling switch + { + FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore => ignore(), + FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException => throwException(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func> ignore, global::System.Func> throwException) => + cyclicReferenceHandling switch + { + FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore => await ignore().ConfigureAwait(false), + FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException => await throwException().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => + (await cyclicReferenceHandling.ConfigureAwait(false)).Match(ignore, throwException); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func> ignore, global::System.Func> throwException) => + await (await cyclicReferenceHandling.ConfigureAwait(false)).Match(ignore, throwException).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Action ignore, global::System.Action throwException) + { + switch (cyclicReferenceHandling) + { + case FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore: + ignore(); + break; + case FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException: + throwException(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.CyclicReferenceHandling cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) + { + switch (cyclicReferenceHandling) + { + case FluentAssertions.Equivalency.CyclicReferenceHandling.Ignore: + await ignore().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.CyclicReferenceHandling.ThrowException: + await throwException().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.CyclicReferenceHandling: {cyclicReferenceHandling.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Action ignore, global::System.Action throwException) => + (await cyclicReferenceHandling.ConfigureAwait(false)).Switch(ignore, throwException); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cyclicReferenceHandling, global::System.Func ignore, global::System.Func throwException) => + await (await cyclicReferenceHandling.ConfigureAwait(false)).Switch(ignore, throwException).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEnumEquivalencyHandlingMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEnumEquivalencyHandlingMatchExtension.g.cs index 8ebe2a5c..f887be55 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEnumEquivalencyHandlingMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEnumEquivalencyHandlingMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Equivalency -{ +{ internal static partial class EnumEquivalencyHandlingMatchExtension - { - public static T Match(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => - enumEquivalencyHandling switch - { - FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName => byName(), - FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue => byValue(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func> byName, global::System.Func> byValue) => - enumEquivalencyHandling switch - { - FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName => byName(), - FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue => byValue(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => - (await enumEquivalencyHandling.ConfigureAwait(false)).Match(byName, byValue); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func> byName, global::System.Func> byValue) => - await (await enumEquivalencyHandling.ConfigureAwait(false)).Match(byName, byValue).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Action byName, global::System.Action byValue) - { - switch (enumEquivalencyHandling) - { - case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName: - byName(); - break; - case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue: - byValue(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) - { - switch (enumEquivalencyHandling) - { - case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName: - await byName().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue: - await byValue().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Action byName, global::System.Action byValue) => - (await enumEquivalencyHandling.ConfigureAwait(false)).Switch(byName, byValue); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => - await (await enumEquivalencyHandling.ConfigureAwait(false)).Switch(byName, byValue).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => + enumEquivalencyHandling switch + { + FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName => byName(), + FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue => byValue(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func> byName, global::System.Func> byValue) => + enumEquivalencyHandling switch + { + FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName => await byName().ConfigureAwait(false), + FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue => await byValue().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => + (await enumEquivalencyHandling.ConfigureAwait(false)).Match(byName, byValue); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func> byName, global::System.Func> byValue) => + await (await enumEquivalencyHandling.ConfigureAwait(false)).Match(byName, byValue).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Action byName, global::System.Action byValue) + { + switch (enumEquivalencyHandling) + { + case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName: + byName(); + break; + case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue: + byValue(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EnumEquivalencyHandling enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) + { + switch (enumEquivalencyHandling) + { + case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByName: + await byName().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.EnumEquivalencyHandling.ByValue: + await byValue().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EnumEquivalencyHandling: {enumEquivalencyHandling.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Action byName, global::System.Action byValue) => + (await enumEquivalencyHandling.ConfigureAwait(false)).Switch(byName, byValue); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task enumEquivalencyHandling, global::System.Func byName, global::System.Func byValue) => + await (await enumEquivalencyHandling.ConfigureAwait(false)).Switch(byName, byValue).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEqualityStrategyMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEqualityStrategyMatchExtension.g.cs index 41ae03db..6c552ea9 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEqualityStrategyMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEqualityStrategyMatchExtension.g.cs @@ -1,81 +1,89 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Equivalency -{ +{ internal static partial class EqualityStrategyMatchExtension - { - public static T Match(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => - equalityStrategy switch - { - FluentAssertions.Equivalency.EqualityStrategy.Equals => @equals(), - FluentAssertions.Equivalency.EqualityStrategy.ForceEquals => forceEquals(), - FluentAssertions.Equivalency.EqualityStrategy.ForceMembers => forceMembers(), - FluentAssertions.Equivalency.EqualityStrategy.Members => members(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func> @equals, global::System.Func> forceEquals, global::System.Func> forceMembers, global::System.Func> members) => - equalityStrategy switch - { - FluentAssertions.Equivalency.EqualityStrategy.Equals => @equals(), - FluentAssertions.Equivalency.EqualityStrategy.ForceEquals => forceEquals(), - FluentAssertions.Equivalency.EqualityStrategy.ForceMembers => forceMembers(), - FluentAssertions.Equivalency.EqualityStrategy.Members => members(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => - (await equalityStrategy.ConfigureAwait(false)).Match(@equals, forceEquals, forceMembers, members); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func> @equals, global::System.Func> forceEquals, global::System.Func> forceMembers, global::System.Func> members) => - await (await equalityStrategy.ConfigureAwait(false)).Match(@equals, forceEquals, forceMembers, members).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Action @equals, global::System.Action forceEquals, global::System.Action forceMembers, global::System.Action members) - { - switch (equalityStrategy) - { - case FluentAssertions.Equivalency.EqualityStrategy.Equals: - @equals(); - break; - case FluentAssertions.Equivalency.EqualityStrategy.ForceEquals: - forceEquals(); - break; - case FluentAssertions.Equivalency.EqualityStrategy.ForceMembers: - forceMembers(); - break; - case FluentAssertions.Equivalency.EqualityStrategy.Members: - members(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) - { - switch (equalityStrategy) - { - case FluentAssertions.Equivalency.EqualityStrategy.Equals: - await @equals().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.EqualityStrategy.ForceEquals: - await forceEquals().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.EqualityStrategy.ForceMembers: - await forceMembers().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.EqualityStrategy.Members: - await members().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Action @equals, global::System.Action forceEquals, global::System.Action forceMembers, global::System.Action members) => - (await equalityStrategy.ConfigureAwait(false)).Switch(@equals, forceEquals, forceMembers, members); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => - await (await equalityStrategy.ConfigureAwait(false)).Switch(@equals, forceEquals, forceMembers, members).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => + equalityStrategy switch + { + FluentAssertions.Equivalency.EqualityStrategy.Equals => @equals(), + FluentAssertions.Equivalency.EqualityStrategy.ForceEquals => forceEquals(), + FluentAssertions.Equivalency.EqualityStrategy.ForceMembers => forceMembers(), + FluentAssertions.Equivalency.EqualityStrategy.Members => members(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func> @equals, global::System.Func> forceEquals, global::System.Func> forceMembers, global::System.Func> members) => + equalityStrategy switch + { + FluentAssertions.Equivalency.EqualityStrategy.Equals => await @equals().ConfigureAwait(false), + FluentAssertions.Equivalency.EqualityStrategy.ForceEquals => await forceEquals().ConfigureAwait(false), + FluentAssertions.Equivalency.EqualityStrategy.ForceMembers => await forceMembers().ConfigureAwait(false), + FluentAssertions.Equivalency.EqualityStrategy.Members => await members().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => + (await equalityStrategy.ConfigureAwait(false)).Match(@equals, forceEquals, forceMembers, members); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func> @equals, global::System.Func> forceEquals, global::System.Func> forceMembers, global::System.Func> members) => + await (await equalityStrategy.ConfigureAwait(false)).Match(@equals, forceEquals, forceMembers, members).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Action @equals, global::System.Action forceEquals, global::System.Action forceMembers, global::System.Action members) + { + switch (equalityStrategy) + { + case FluentAssertions.Equivalency.EqualityStrategy.Equals: + @equals(); + break; + case FluentAssertions.Equivalency.EqualityStrategy.ForceEquals: + forceEquals(); + break; + case FluentAssertions.Equivalency.EqualityStrategy.ForceMembers: + forceMembers(); + break; + case FluentAssertions.Equivalency.EqualityStrategy.Members: + members(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EqualityStrategy equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) + { + switch (equalityStrategy) + { + case FluentAssertions.Equivalency.EqualityStrategy.Equals: + await @equals().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.EqualityStrategy.ForceEquals: + await forceEquals().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.EqualityStrategy.ForceMembers: + await forceMembers().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.EqualityStrategy.Members: + await members().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EqualityStrategy: {equalityStrategy.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Action @equals, global::System.Action forceEquals, global::System.Action forceMembers, global::System.Action members) => + (await equalityStrategy.ConfigureAwait(false)).Switch(@equals, forceEquals, forceMembers, members); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equalityStrategy, global::System.Func @equals, global::System.Func forceEquals, global::System.Func forceMembers, global::System.Func members) => + await (await equalityStrategy.ConfigureAwait(false)).Switch(@equals, forceEquals, forceMembers, members).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEquivalencyResultMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEquivalencyResultMatchExtension.g.cs index e836e700..35fca4a6 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEquivalencyResultMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyEquivalencyResultMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Equivalency -{ +{ internal static partial class EquivalencyResultMatchExtension - { - public static T Match(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => - equivalencyResult switch - { - FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted => assertionCompleted(), - FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext => continueWithNext(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func> assertionCompleted, global::System.Func> continueWithNext) => - equivalencyResult switch - { - FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted => assertionCompleted(), - FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext => continueWithNext(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => - (await equivalencyResult.ConfigureAwait(false)).Match(assertionCompleted, continueWithNext); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func> assertionCompleted, global::System.Func> continueWithNext) => - await (await equivalencyResult.ConfigureAwait(false)).Match(assertionCompleted, continueWithNext).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Action assertionCompleted, global::System.Action continueWithNext) - { - switch (equivalencyResult) - { - case FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted: - assertionCompleted(); - break; - case FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext: - continueWithNext(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) - { - switch (equivalencyResult) - { - case FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted: - await assertionCompleted().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext: - await continueWithNext().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Action assertionCompleted, global::System.Action continueWithNext) => - (await equivalencyResult.ConfigureAwait(false)).Switch(assertionCompleted, continueWithNext); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => - await (await equivalencyResult.ConfigureAwait(false)).Switch(assertionCompleted, continueWithNext).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => + equivalencyResult switch + { + FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted => assertionCompleted(), + FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext => continueWithNext(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func> assertionCompleted, global::System.Func> continueWithNext) => + equivalencyResult switch + { + FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted => await assertionCompleted().ConfigureAwait(false), + FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext => await continueWithNext().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => + (await equivalencyResult.ConfigureAwait(false)).Match(assertionCompleted, continueWithNext); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func> assertionCompleted, global::System.Func> continueWithNext) => + await (await equivalencyResult.ConfigureAwait(false)).Match(assertionCompleted, continueWithNext).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Action assertionCompleted, global::System.Action continueWithNext) + { + switch (equivalencyResult) + { + case FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted: + assertionCompleted(); + break; + case FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext: + continueWithNext(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.EquivalencyResult equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) + { + switch (equivalencyResult) + { + case FluentAssertions.Equivalency.EquivalencyResult.AssertionCompleted: + await assertionCompleted().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.EquivalencyResult.ContinueWithNext: + await continueWithNext().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.EquivalencyResult: {equivalencyResult.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Action assertionCompleted, global::System.Action continueWithNext) => + (await equivalencyResult.ConfigureAwait(false)).Switch(assertionCompleted, continueWithNext); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task equivalencyResult, global::System.Func assertionCompleted, global::System.Func continueWithNext) => + await (await equivalencyResult.ConfigureAwait(false)).Switch(assertionCompleted, continueWithNext).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyOrderStrictnessMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyOrderStrictnessMatchExtension.g.cs index 41d4b38b..19a21fae 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyOrderStrictnessMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsEquivalencyOrderStrictnessMatchExtension.g.cs @@ -1,73 +1,81 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Equivalency -{ +{ internal static partial class OrderStrictnessMatchExtension - { - public static T Match(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => - orderStrictness switch - { - FluentAssertions.Equivalency.OrderStrictness.Irrelevant => irrelevant(), - FluentAssertions.Equivalency.OrderStrictness.NotStrict => notStrict(), - FluentAssertions.Equivalency.OrderStrictness.Strict => strict(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func> irrelevant, global::System.Func> notStrict, global::System.Func> strict) => - orderStrictness switch - { - FluentAssertions.Equivalency.OrderStrictness.Irrelevant => irrelevant(), - FluentAssertions.Equivalency.OrderStrictness.NotStrict => notStrict(), - FluentAssertions.Equivalency.OrderStrictness.Strict => strict(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => - (await orderStrictness.ConfigureAwait(false)).Match(irrelevant, notStrict, strict); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func> irrelevant, global::System.Func> notStrict, global::System.Func> strict) => - await (await orderStrictness.ConfigureAwait(false)).Match(irrelevant, notStrict, strict).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Action irrelevant, global::System.Action notStrict, global::System.Action strict) - { - switch (orderStrictness) - { - case FluentAssertions.Equivalency.OrderStrictness.Irrelevant: - irrelevant(); - break; - case FluentAssertions.Equivalency.OrderStrictness.NotStrict: - notStrict(); - break; - case FluentAssertions.Equivalency.OrderStrictness.Strict: - strict(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) - { - switch (orderStrictness) - { - case FluentAssertions.Equivalency.OrderStrictness.Irrelevant: - await irrelevant().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.OrderStrictness.NotStrict: - await notStrict().ConfigureAwait(false); - break; - case FluentAssertions.Equivalency.OrderStrictness.Strict: - await strict().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task orderStrictness, global::System.Action irrelevant, global::System.Action notStrict, global::System.Action strict) => - (await orderStrictness.ConfigureAwait(false)).Switch(irrelevant, notStrict, strict); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => - await (await orderStrictness.ConfigureAwait(false)).Switch(irrelevant, notStrict, strict).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => + orderStrictness switch + { + FluentAssertions.Equivalency.OrderStrictness.Irrelevant => irrelevant(), + FluentAssertions.Equivalency.OrderStrictness.NotStrict => notStrict(), + FluentAssertions.Equivalency.OrderStrictness.Strict => strict(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func> irrelevant, global::System.Func> notStrict, global::System.Func> strict) => + orderStrictness switch + { + FluentAssertions.Equivalency.OrderStrictness.Irrelevant => await irrelevant().ConfigureAwait(false), + FluentAssertions.Equivalency.OrderStrictness.NotStrict => await notStrict().ConfigureAwait(false), + FluentAssertions.Equivalency.OrderStrictness.Strict => await strict().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => + (await orderStrictness.ConfigureAwait(false)).Match(irrelevant, notStrict, strict); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func> irrelevant, global::System.Func> notStrict, global::System.Func> strict) => + await (await orderStrictness.ConfigureAwait(false)).Match(irrelevant, notStrict, strict).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Action irrelevant, global::System.Action notStrict, global::System.Action strict) + { + switch (orderStrictness) + { + case FluentAssertions.Equivalency.OrderStrictness.Irrelevant: + irrelevant(); + break; + case FluentAssertions.Equivalency.OrderStrictness.NotStrict: + notStrict(); + break; + case FluentAssertions.Equivalency.OrderStrictness.Strict: + strict(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Equivalency.OrderStrictness orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) + { + switch (orderStrictness) + { + case FluentAssertions.Equivalency.OrderStrictness.Irrelevant: + await irrelevant().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.OrderStrictness.NotStrict: + await notStrict().ConfigureAwait(false); + break; + case FluentAssertions.Equivalency.OrderStrictness.Strict: + await strict().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Equivalency.OrderStrictness: {orderStrictness.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task orderStrictness, global::System.Action irrelevant, global::System.Action notStrict, global::System.Action strict) => + (await orderStrictness.ConfigureAwait(false)).Switch(irrelevant, notStrict, strict); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task orderStrictness, global::System.Func irrelevant, global::System.Func notStrict, global::System.Func strict) => + await (await orderStrictness.ConfigureAwait(false)).Switch(irrelevant, notStrict, strict).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsPrimitivesTimeSpanConditionMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsPrimitivesTimeSpanConditionMatchExtension.g.cs index 98ac2d86..5f9c6c7b 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsPrimitivesTimeSpanConditionMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FluentAssertionsPrimitivesTimeSpanConditionMatchExtension.g.cs @@ -1,89 +1,97 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FluentAssertions.Primitives -{ +{ internal static partial class TimeSpanConditionMatchExtension - { - public static T Match(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => - timeSpanCondition switch - { - FluentAssertions.Primitives.TimeSpanCondition.AtLeast => atLeast(), - FluentAssertions.Primitives.TimeSpanCondition.Exactly => exactly(), - FluentAssertions.Primitives.TimeSpanCondition.LessThan => lessThan(), - FluentAssertions.Primitives.TimeSpanCondition.MoreThan => moreThan(), - FluentAssertions.Primitives.TimeSpanCondition.Within => within(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func> atLeast, global::System.Func> exactly, global::System.Func> lessThan, global::System.Func> moreThan, global::System.Func> within) => - timeSpanCondition switch - { - FluentAssertions.Primitives.TimeSpanCondition.AtLeast => atLeast(), - FluentAssertions.Primitives.TimeSpanCondition.Exactly => exactly(), - FluentAssertions.Primitives.TimeSpanCondition.LessThan => lessThan(), - FluentAssertions.Primitives.TimeSpanCondition.MoreThan => moreThan(), - FluentAssertions.Primitives.TimeSpanCondition.Within => within(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => - (await timeSpanCondition.ConfigureAwait(false)).Match(atLeast, exactly, lessThan, moreThan, within); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func> atLeast, global::System.Func> exactly, global::System.Func> lessThan, global::System.Func> moreThan, global::System.Func> within) => - await (await timeSpanCondition.ConfigureAwait(false)).Match(atLeast, exactly, lessThan, moreThan, within).ConfigureAwait(false); - - public static void Switch(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Action atLeast, global::System.Action exactly, global::System.Action lessThan, global::System.Action moreThan, global::System.Action within) - { - switch (timeSpanCondition) - { - case FluentAssertions.Primitives.TimeSpanCondition.AtLeast: - atLeast(); - break; - case FluentAssertions.Primitives.TimeSpanCondition.Exactly: - exactly(); - break; - case FluentAssertions.Primitives.TimeSpanCondition.LessThan: - lessThan(); - break; - case FluentAssertions.Primitives.TimeSpanCondition.MoreThan: - moreThan(); - break; - case FluentAssertions.Primitives.TimeSpanCondition.Within: - within(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) - { - switch (timeSpanCondition) - { - case FluentAssertions.Primitives.TimeSpanCondition.AtLeast: - await atLeast().ConfigureAwait(false); - break; - case FluentAssertions.Primitives.TimeSpanCondition.Exactly: - await exactly().ConfigureAwait(false); - break; - case FluentAssertions.Primitives.TimeSpanCondition.LessThan: - await lessThan().ConfigureAwait(false); - break; - case FluentAssertions.Primitives.TimeSpanCondition.MoreThan: - await moreThan().ConfigureAwait(false); - break; - case FluentAssertions.Primitives.TimeSpanCondition.Within: - await within().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Action atLeast, global::System.Action exactly, global::System.Action lessThan, global::System.Action moreThan, global::System.Action within) => - (await timeSpanCondition.ConfigureAwait(false)).Switch(atLeast, exactly, lessThan, moreThan, within); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => - await (await timeSpanCondition.ConfigureAwait(false)).Switch(atLeast, exactly, lessThan, moreThan, within).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => + timeSpanCondition switch + { + FluentAssertions.Primitives.TimeSpanCondition.AtLeast => atLeast(), + FluentAssertions.Primitives.TimeSpanCondition.Exactly => exactly(), + FluentAssertions.Primitives.TimeSpanCondition.LessThan => lessThan(), + FluentAssertions.Primitives.TimeSpanCondition.MoreThan => moreThan(), + FluentAssertions.Primitives.TimeSpanCondition.Within => within(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func> atLeast, global::System.Func> exactly, global::System.Func> lessThan, global::System.Func> moreThan, global::System.Func> within) => + timeSpanCondition switch + { + FluentAssertions.Primitives.TimeSpanCondition.AtLeast => await atLeast().ConfigureAwait(false), + FluentAssertions.Primitives.TimeSpanCondition.Exactly => await exactly().ConfigureAwait(false), + FluentAssertions.Primitives.TimeSpanCondition.LessThan => await lessThan().ConfigureAwait(false), + FluentAssertions.Primitives.TimeSpanCondition.MoreThan => await moreThan().ConfigureAwait(false), + FluentAssertions.Primitives.TimeSpanCondition.Within => await within().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => + (await timeSpanCondition.ConfigureAwait(false)).Match(atLeast, exactly, lessThan, moreThan, within); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func> atLeast, global::System.Func> exactly, global::System.Func> lessThan, global::System.Func> moreThan, global::System.Func> within) => + await (await timeSpanCondition.ConfigureAwait(false)).Match(atLeast, exactly, lessThan, moreThan, within).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Action atLeast, global::System.Action exactly, global::System.Action lessThan, global::System.Action moreThan, global::System.Action within) + { + switch (timeSpanCondition) + { + case FluentAssertions.Primitives.TimeSpanCondition.AtLeast: + atLeast(); + break; + case FluentAssertions.Primitives.TimeSpanCondition.Exactly: + exactly(); + break; + case FluentAssertions.Primitives.TimeSpanCondition.LessThan: + lessThan(); + break; + case FluentAssertions.Primitives.TimeSpanCondition.MoreThan: + moreThan(); + break; + case FluentAssertions.Primitives.TimeSpanCondition.Within: + within(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FluentAssertions.Primitives.TimeSpanCondition timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) + { + switch (timeSpanCondition) + { + case FluentAssertions.Primitives.TimeSpanCondition.AtLeast: + await atLeast().ConfigureAwait(false); + break; + case FluentAssertions.Primitives.TimeSpanCondition.Exactly: + await exactly().ConfigureAwait(false); + break; + case FluentAssertions.Primitives.TimeSpanCondition.LessThan: + await lessThan().ConfigureAwait(false); + break; + case FluentAssertions.Primitives.TimeSpanCondition.MoreThan: + await moreThan().ConfigureAwait(false); + break; + case FluentAssertions.Primitives.TimeSpanCondition.Within: + await within().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FluentAssertions.Primitives.TimeSpanCondition: {timeSpanCondition.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Action atLeast, global::System.Action exactly, global::System.Action lessThan, global::System.Action moreThan, global::System.Action within) => + (await timeSpanCondition.ConfigureAwait(false)).Switch(atLeast, exactly, lessThan, moreThan, within); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task timeSpanCondition, global::System.Func atLeast, global::System.Func exactly, global::System.Func lessThan, global::System.Func moreThan, global::System.Func within) => + await (await timeSpanCondition.ConfigureAwait(false)).Switch(atLeast, exactly, lessThan, moreThan, within).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerEnumSpecsPlatformIdentifierMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerEnumSpecsPlatformIdentifierMatchExtension.g.cs index 7d3dc954..b77f4336 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerEnumSpecsPlatformIdentifierMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerEnumSpecsPlatformIdentifierMatchExtension.g.cs @@ -1,73 +1,81 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class EnumSpecs_PlatformIdentifierMatchExtension - { - public static T Match(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => - platformIdentifier switch - { - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine => developerMachine(), - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice => linuxDevice(), - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice => windowsDevice(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func> developerMachine, global::System.Func> linuxDevice, global::System.Func> windowsDevice) => - platformIdentifier switch - { - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine => developerMachine(), - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice => linuxDevice(), - FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice => windowsDevice(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => - (await platformIdentifier.ConfigureAwait(false)).Match(developerMachine, linuxDevice, windowsDevice); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func> developerMachine, global::System.Func> linuxDevice, global::System.Func> windowsDevice) => - await (await platformIdentifier.ConfigureAwait(false)).Match(developerMachine, linuxDevice, windowsDevice).ConfigureAwait(false); - - public static void Switch(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Action developerMachine, global::System.Action linuxDevice, global::System.Action windowsDevice) - { - switch (platformIdentifier) - { - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine: - developerMachine(); - break; - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice: - linuxDevice(); - break; - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice: - windowsDevice(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) - { - switch (platformIdentifier) - { - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine: - await developerMachine().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice: - await linuxDevice().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice: - await windowsDevice().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Action developerMachine, global::System.Action linuxDevice, global::System.Action windowsDevice) => - (await platformIdentifier.ConfigureAwait(false)).Switch(developerMachine, linuxDevice, windowsDevice); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => - await (await platformIdentifier.ConfigureAwait(false)).Switch(developerMachine, linuxDevice, windowsDevice).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => + platformIdentifier switch + { + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine => developerMachine(), + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice => linuxDevice(), + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice => windowsDevice(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func> developerMachine, global::System.Func> linuxDevice, global::System.Func> windowsDevice) => + platformIdentifier switch + { + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine => await developerMachine().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice => await linuxDevice().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice => await windowsDevice().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => + (await platformIdentifier.ConfigureAwait(false)).Match(developerMachine, linuxDevice, windowsDevice); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func> developerMachine, global::System.Func> linuxDevice, global::System.Func> windowsDevice) => + await (await platformIdentifier.ConfigureAwait(false)).Match(developerMachine, linuxDevice, windowsDevice).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Action developerMachine, global::System.Action linuxDevice, global::System.Action windowsDevice) + { + switch (platformIdentifier) + { + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine: + developerMachine(); + break; + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice: + linuxDevice(); + break; + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice: + windowsDevice(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) + { + switch (platformIdentifier) + { + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.DeveloperMachine: + await developerMachine().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.LinuxDevice: + await linuxDevice().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier.WindowsDevice: + await windowsDevice().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.EnumSpecs.PlatformIdentifier: {platformIdentifier.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Action developerMachine, global::System.Action linuxDevice, global::System.Action windowsDevice) => + (await platformIdentifier.ConfigureAwait(false)).Switch(developerMachine, linuxDevice, windowsDevice); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task platformIdentifier, global::System.Func developerMachine, global::System.Func linuxDevice, global::System.Func windowsDevice) => + await (await platformIdentifier.ConfigureAwait(false)).Switch(developerMachine, linuxDevice, windowsDevice).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerErrorUnionCasesMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerErrorUnionCasesMatchExtension.g.cs index 1afd09c9..9806bc49 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerErrorUnionCasesMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerErrorUnionCasesMatchExtension.g.cs @@ -1,81 +1,89 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FunicularSwitch.Generators.Consumer -{ +{ internal static partial class Error_UnionCasesMatchExtension - { - public static T Match(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - unionCases switch - { - FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic => generic(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound => notFound(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized => notAuthorized(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated => aggregated(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => - unionCases switch - { - FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic => generic(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound => notFound(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized => notAuthorized(), - FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated => aggregated(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - (await unionCases.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task unionCases, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => - await (await unionCases.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); - - public static void Switch(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) - { - switch (unionCases) - { - case FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic: - generic(); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound: - notFound(); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized: - notAuthorized(); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated: - aggregated(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) - { - switch (unionCases) - { - case FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic: - await generic().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound: - await notFound().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized: - await notAuthorized().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated: - await aggregated().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task unionCases, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) => - (await unionCases.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - await (await unionCases.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + unionCases switch + { + FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic => generic(), + FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound => notFound(), + FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized => notAuthorized(), + FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated => aggregated(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => + unionCases switch + { + FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic => await generic().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound => await notFound().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized => await notAuthorized().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated => await aggregated().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + (await unionCases.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task unionCases, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => + await (await unionCases.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) + { + switch (unionCases) + { + case FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic: + generic(); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound: + notFound(); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized: + notAuthorized(); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated: + aggregated(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.Error.UnionCases unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) + { + switch (unionCases) + { + case FunicularSwitch.Generators.Consumer.Error.UnionCases.Generic: + await generic().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotFound: + await notFound().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.NotAuthorized: + await notAuthorized().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.UnionCases.Aggregated: + await aggregated().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.Error.UnionCases: {unionCases.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task unionCases, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) => + (await unionCases.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task unionCases, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + await (await unionCases.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerInternalEnumParentInternalEnumMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerInternalEnumParentInternalEnumMatchExtension.g.cs index 789046eb..cc8d2dc9 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerInternalEnumParentInternalEnumMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerInternalEnumParentInternalEnumMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FunicularSwitch.Generators.Consumer -{ +{ internal static partial class InternalEnumParent_InternalEnumMatchExtension - { - public static T Match(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func one, global::System.Func two) => - internalEnum switch - { - FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One => one(), - FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two => two(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func> one, global::System.Func> two) => - internalEnum switch - { - FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One => one(), - FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two => two(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task internalEnum, global::System.Func one, global::System.Func two) => - (await internalEnum.ConfigureAwait(false)).Match(one, two); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task internalEnum, global::System.Func> one, global::System.Func> two) => - await (await internalEnum.ConfigureAwait(false)).Match(one, two).ConfigureAwait(false); - - public static void Switch(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Action one, global::System.Action two) - { - switch (internalEnum) - { - case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One: - one(); - break; - case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two: - two(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func one, global::System.Func two) - { - switch (internalEnum) - { - case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One: - await one().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two: - await two().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task internalEnum, global::System.Action one, global::System.Action two) => - (await internalEnum.ConfigureAwait(false)).Switch(one, two); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task internalEnum, global::System.Func one, global::System.Func two) => - await (await internalEnum.ConfigureAwait(false)).Switch(one, two).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func one, global::System.Func two) => + internalEnum switch + { + FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One => one(), + FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two => two(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func> one, global::System.Func> two) => + internalEnum switch + { + FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One => await one().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two => await two().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task internalEnum, global::System.Func one, global::System.Func two) => + (await internalEnum.ConfigureAwait(false)).Match(one, two); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task internalEnum, global::System.Func> one, global::System.Func> two) => + await (await internalEnum.ConfigureAwait(false)).Match(one, two).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Action one, global::System.Action two) + { + switch (internalEnum) + { + case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One: + one(); + break; + case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two: + two(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum internalEnum, global::System.Func one, global::System.Func two) + { + switch (internalEnum) + { + case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.One: + await one().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum.Two: + await two().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.InternalEnumParent.InternalEnum: {internalEnum.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task internalEnum, global::System.Action one, global::System.Action two) => + (await internalEnum.ConfigureAwait(false)).Switch(one, two); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task internalEnum, global::System.Func one, global::System.Func two) => + await (await internalEnum.ConfigureAwait(false)).Switch(one, two).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerSystemMyEnumMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerSystemMyEnumMatchExtension.g.cs index 7359603a..3e4e308a 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerSystemMyEnumMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/FunicularSwitchGeneratorsConsumerSystemMyEnumMatchExtension.g.cs @@ -1,65 +1,73 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace FunicularSwitch.Generators.Consumer.System -{ +{ public static partial class MyEnumMatchExtension - { - public static T Match(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func one, global::System.Func two) => - myEnum switch - { - FunicularSwitch.Generators.Consumer.System.MyEnum.One => one(), - FunicularSwitch.Generators.Consumer.System.MyEnum.Two => two(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func> one, global::System.Func> two) => - myEnum switch - { - FunicularSwitch.Generators.Consumer.System.MyEnum.One => one(), - FunicularSwitch.Generators.Consumer.System.MyEnum.Two => two(), - _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myEnum, global::System.Func one, global::System.Func two) => - (await myEnum.ConfigureAwait(false)).Match(one, two); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myEnum, global::System.Func> one, global::System.Func> two) => - await (await myEnum.ConfigureAwait(false)).Match(one, two).ConfigureAwait(false); - - public static void Switch(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Action one, global::System.Action two) - { - switch (myEnum) - { - case FunicularSwitch.Generators.Consumer.System.MyEnum.One: - one(); - break; - case FunicularSwitch.Generators.Consumer.System.MyEnum.Two: - two(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func one, global::System.Func two) - { - switch (myEnum) - { - case FunicularSwitch.Generators.Consumer.System.MyEnum.One: - await one().ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.System.MyEnum.Two: - await two().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myEnum, global::System.Action one, global::System.Action two) => - (await myEnum.ConfigureAwait(false)).Switch(one, two); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myEnum, global::System.Func one, global::System.Func two) => - await (await myEnum.ConfigureAwait(false)).Switch(one, two).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func one, global::System.Func two) => + myEnum switch + { + FunicularSwitch.Generators.Consumer.System.MyEnum.One => one(), + FunicularSwitch.Generators.Consumer.System.MyEnum.Two => two(), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func> one, global::System.Func> two) => + myEnum switch + { + FunicularSwitch.Generators.Consumer.System.MyEnum.One => await one().ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.System.MyEnum.Two => await two().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myEnum, global::System.Func one, global::System.Func two) => + (await myEnum.ConfigureAwait(false)).Match(one, two); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task myEnum, global::System.Func> one, global::System.Func> two) => + await (await myEnum.ConfigureAwait(false)).Match(one, two).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Action one, global::System.Action two) + { + switch (myEnum) + { + case FunicularSwitch.Generators.Consumer.System.MyEnum.One: + one(); + break; + case FunicularSwitch.Generators.Consumer.System.MyEnum.Two: + two(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this FunicularSwitch.Generators.Consumer.System.MyEnum myEnum, global::System.Func one, global::System.Func two) + { + switch (myEnum) + { + case FunicularSwitch.Generators.Consumer.System.MyEnum.One: + await one().ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.System.MyEnum.Two: + await two().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from FunicularSwitch.Generators.Consumer.System.MyEnum: {myEnum.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myEnum, global::System.Action one, global::System.Action two) => + (await myEnum.ConfigureAwait(false)).Switch(one, two); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task myEnum, global::System.Func one, global::System.Func two) => + await (await myEnum.ConfigureAwait(false)).Switch(one, two).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/SystemDateTimeKindMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/SystemDateTimeKindMatchExtension.g.cs index bfd88796..9e6ff754 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/SystemDateTimeKindMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.EnumTypeGenerator/SystemDateTimeKindMatchExtension.g.cs @@ -1,73 +1,81 @@ -#pragma warning disable 1591 +#pragma warning disable 1591 namespace System -{ +{ public static partial class DateTimeKindMatchExtension - { - public static T Match(this System.DateTimeKind dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => - dateTimeKind switch - { - System.DateTimeKind.Local => local(), - System.DateTimeKind.Unspecified => unspecified(), - System.DateTimeKind.Utc => utc(), - _ => throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}") - }; - - public static global::System.Threading.Tasks.Task Match(this System.DateTimeKind dateTimeKind, global::System.Func> local, global::System.Func> unspecified, global::System.Func> utc) => - dateTimeKind switch - { - System.DateTimeKind.Local => local(), - System.DateTimeKind.Unspecified => unspecified(), - System.DateTimeKind.Utc => utc(), - _ => throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}") - }; - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => - (await dateTimeKind.ConfigureAwait(false)).Match(local, unspecified, utc); - - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func> local, global::System.Func> unspecified, global::System.Func> utc) => - await (await dateTimeKind.ConfigureAwait(false)).Match(local, unspecified, utc).ConfigureAwait(false); - - public static void Switch(this System.DateTimeKind dateTimeKind, global::System.Action local, global::System.Action unspecified, global::System.Action utc) - { - switch (dateTimeKind) - { - case System.DateTimeKind.Local: - local(); - break; - case System.DateTimeKind.Unspecified: - unspecified(); - break; - case System.DateTimeKind.Utc: - utc(); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this System.DateTimeKind dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) - { - switch (dateTimeKind) - { - case System.DateTimeKind.Local: - await local().ConfigureAwait(false); - break; - case System.DateTimeKind.Unspecified: - await unspecified().ConfigureAwait(false); - break; - case System.DateTimeKind.Utc: - await utc().ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}"); - } - } - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Action local, global::System.Action unspecified, global::System.Action utc) => - (await dateTimeKind.ConfigureAwait(false)).Switch(local, unspecified, utc); - - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => - await (await dateTimeKind.ConfigureAwait(false)).Switch(local, unspecified, utc).ConfigureAwait(false); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this System.DateTimeKind dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => + dateTimeKind switch + { + System.DateTimeKind.Local => local(), + System.DateTimeKind.Unspecified => unspecified(), + System.DateTimeKind.Utc => utc(), + _ => throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this System.DateTimeKind dateTimeKind, global::System.Func> local, global::System.Func> unspecified, global::System.Func> utc) => + dateTimeKind switch + { + System.DateTimeKind.Local => await local().ConfigureAwait(false), + System.DateTimeKind.Unspecified => await unspecified().ConfigureAwait(false), + System.DateTimeKind.Utc => await utc().ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => + (await dateTimeKind.ConfigureAwait(false)).Match(local, unspecified, utc); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func> local, global::System.Func> unspecified, global::System.Func> utc) => + await (await dateTimeKind.ConfigureAwait(false)).Match(local, unspecified, utc).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this System.DateTimeKind dateTimeKind, global::System.Action local, global::System.Action unspecified, global::System.Action utc) + { + switch (dateTimeKind) + { + case System.DateTimeKind.Local: + local(); + break; + case System.DateTimeKind.Unspecified: + unspecified(); + break; + case System.DateTimeKind.Utc: + utc(); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this System.DateTimeKind dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) + { + switch (dateTimeKind) + { + case System.DateTimeKind.Local: + await local().ConfigureAwait(false); + break; + case System.DateTimeKind.Unspecified: + await unspecified().ConfigureAwait(false); + break; + case System.DateTimeKind.Utc: + await utc().ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown enum value from System.DateTimeKind: {dateTimeKind.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Action local, global::System.Action unspecified, global::System.Action utc) => + (await dateTimeKind.ConfigureAwait(false)).Switch(local, unspecified, utc); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task dateTimeKind, global::System.Func local, global::System.Func unspecified, global::System.Func utc) => + await (await dateTimeKind.ConfigureAwait(false)).Switch(local, unspecified, utc).ConfigureAwait(false); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs index 6a8dcc8a..5f4a1341 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs @@ -1,53 +1,53 @@ namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class Writer - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Init(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Init(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer Map(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer Select(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - } -} + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Init(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Init(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer Map(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer Select(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs index 622189e4..9ff9ed82 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.ExtendMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class ExtendMonadAttribute : Attribute - { - public ExtendMonadAttribute() { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class ExtendMonadAttribute : Attribute + { + public ExtendMonadAttribute() { } + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs index 44f61edf..592fe83e 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs @@ -1,269 +1,287 @@ #nullable enable - -using global::System.Linq; -using FunicularSwitch.Generic; - + +using global::System.Linq; +using FunicularSwitch.Generic; + namespace FunicularSwitch.Generators.Consumer -{ +{ #pragma warning disable 1591 - abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(Error details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(Error details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract Error? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(Error message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(Error details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(Error details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract Error? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static OperationResult Error(Error message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(OperationResult result) => result.IsOk; + + public static bool operator false(OperationResult result) => result.IsError; + + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - + { + return OperationResult.Error(FunicularSwitch.Generators.Consumer.Error.Generic(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + public static implicit operator global::FunicularSwitch.Generic.GenericResult(OperationResult result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, @@ -277,231 +295,272 @@ public static implicit operator OperationResult(global::FunicularSwitch.Gener public global::FunicularSwitch.Generic.GenericResult ToGenericResult() => Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override Error? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public Error Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(Error details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override Error? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - readonly partial struct OperationResultError : global::System.IEquatable - { - readonly Error _details; - - internal OperationResultError(Error details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - + global::FunicularSwitch.Generic.GenericResult.Error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Error? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public Error Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(Error details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Error? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + readonly partial struct OperationResultError : global::System.IEquatable + { + readonly Error _details; + + internal OperationResultError(Error details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult MapError(this OperationResult result, global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + public static OperationResult ToOperationResult( this global::FunicularSwitch.Generic.GenericResult result) => result.Match>( @@ -518,54 +577,61 @@ public static OperationResult ToOperationResult( this global::System.Threading.Tasks.Task> result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - } + global::FunicularSwitch.Generic.GenericResult.Error); + } } namespace FunicularSwitch.Generators.Consumer.Extensions -{ - static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + static partial class OperationResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this object? item, global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNull(this T? item, global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResultWithMerge.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResultWithMerge.g.cs index 60f770a2..ff666e2e 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResultWithMerge.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResultWithMerge.g.cs @@ -8,90 +8,135 @@ namespace FunicularSwitch.Generators.Consumer abstract partial class OperationResult { - public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => OperationResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => OperationResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } static partial class OperationResultExtension { - public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static OperationResult> Bind(this OperationResult result, + results.Select(r => r.Bind(bind)).Aggregate(); + + + public static OperationResult> Bind(this OperationResult result, global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + + public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, OperationResult> bind) => - results.Aggregate().Bind(bind); - - public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + + public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; Error aggregated = default!; @@ -111,28 +156,33 @@ public static OperationResult Bind(this global::System.Collections.Ge return isError ? OperationResult.Error>(aggregated) : OperationResult.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - - public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => + .Aggregate(); + + + + public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2) @@ -145,18 +195,22 @@ public static OperationResult Aggregate(this Operation )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => + + public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3) @@ -169,18 +223,22 @@ public static OperationResult Aggregate(this Opera )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4) @@ -193,18 +251,22 @@ public static OperationResult Aggregate(this O )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5) @@ -217,18 +279,22 @@ public static OperationResult Aggregate(th )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6) @@ -241,18 +307,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7) @@ -265,18 +335,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8) @@ -289,18 +363,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8 && r9 is OperationResult.Ok_ ok9) @@ -313,16 +391,19 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); - } - - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + } + + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -337,15 +418,17 @@ public static OperationResult FirstOk(this global::System.Collections.Gene errors.Add(onEmpty()); return OperationResult.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -371,21 +454,25 @@ public static OperationResult FirstOk(this global::System.Collections.Gene } })).ConfigureAwait(false); } - } + } - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static OperationResult Validate(this T item, global::System.Func> validate) + + public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + + public static OperationResult Validate(this T item, global::System.Func> validate) { try { @@ -399,9 +486,10 @@ public static OperationResult Validate(this T item, global::System.Func(FunicularSwitch.Generators.Consumer.Error.Generic(e)); } - } + } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs index 57be657e..9a23784f 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs @@ -1,270 +1,288 @@ #nullable enable - -using global::System.Linq; + +using global::System.Linq; using System; -using FunicularSwitch.Generic; - +using FunicularSwitch.Generic; + namespace FunicularSwitch.Generators.Consumer -{ +{ #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(String details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(String details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract String? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(String message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(String details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(String details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract String? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(String message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - + { + return Result.Error(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + public static implicit operator global::FunicularSwitch.Generic.GenericResult(Result result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, @@ -278,231 +296,272 @@ public static implicit operator Result(global::FunicularSwitch.Generic.Generi public global::FunicularSwitch.Generic.GenericResult ToGenericResult() => Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public String Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(String details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly String _details; - - internal ResultError(String details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - + global::FunicularSwitch.Generic.GenericResult.Error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public String Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(String details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly String _details; + + internal ResultError(String details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + public static Result ToResult( this global::FunicularSwitch.Generic.GenericResult result) => result.Match>( @@ -519,54 +578,61 @@ public static Result ToResult( this global::System.Threading.Tasks.Task> result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - } + global::FunicularSwitch.Generic.GenericResult.Error); + } } namespace FunicularSwitch.Generators.Consumer.Extensions -{ - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.ResultWithMerge.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.ResultWithMerge.g.cs index 77951582..7963c0fb 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.ResultWithMerge.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.ResultWithMerge.g.cs @@ -9,90 +9,135 @@ namespace FunicularSwitch.Generators.Consumer public abstract partial class Result { - public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result Aggregate(Result r1, Result r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => ResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result Aggregate(Result r1, Result r2, Result r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => ResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => ResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class ResultExtension { - public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static Result> Bind(this Result result, + results.Select(r => r.Bind(bind)).Aggregate(); + + + public static Result> Bind(this Result result, global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + + public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, Result> bind) => - results.Aggregate().Bind(bind); - - public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + + public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; String aggregated = default!; @@ -112,28 +157,33 @@ public static Result Bind(this global::System.Collections.Generic.IEn return isError ? Result.Error>(aggregated) : Result.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - - public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => + .Aggregate(); + + + + public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static Result Aggregate(this Result r1, Result r2, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2) @@ -146,18 +196,22 @@ public static Result Aggregate(this Result r1, Res )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => + + public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static Result Aggregate(this Result r1, Result r2, Result r3, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3) @@ -170,18 +224,22 @@ public static Result Aggregate(this Result r1, )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => + + public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4) @@ -194,18 +252,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5) @@ -218,18 +280,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6) @@ -242,18 +308,22 @@ public static Result Aggregate(this Re )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7) @@ -266,18 +336,22 @@ public static Result Aggregate(thi )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8) @@ -290,18 +364,22 @@ public static Result Aggregate )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8 && r9 is Result.Ok_ ok9) @@ -314,16 +392,19 @@ public static Result Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); - } - - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + } + + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -338,15 +419,17 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum errors.Add(onEmpty()); return Result.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -372,21 +455,25 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum } })).ConfigureAwait(false); } - } + } - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static Result Validate(this T item, global::System.Func> validate) + + public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + + public static Result Validate(this T item, global::System.Func> validate) { try { @@ -400,9 +487,10 @@ public static Result Validate(this T item, global::System.Func(FunicularSwitch.Generators.Consumer.ErrorExtension.UnexpectedToStringError(e)); } - } + } - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs index b0b51a71..a9176c9f 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs @@ -1,269 +1,287 @@ #nullable enable - -using global::System.Linq; -using FunicularSwitch.Generic; - + +using global::System.Linq; +using FunicularSwitch.Generic; + namespace FunicularSwitch.Generators.Consumer.System -{ +{ #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(Action details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(Action details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract Action? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(Action message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(Action details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(Action details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract Action? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(Action message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + public static implicit operator global::FunicularSwitch.Generic.GenericResult(Result result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, @@ -277,231 +295,272 @@ public static implicit operator Result(global::FunicularSwitch.Generic.Generi public global::FunicularSwitch.Generic.GenericResult ToGenericResult() => Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override Action? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public Action Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(Action details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override Action? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly Action _details; - - internal ResultError(Action details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - + global::FunicularSwitch.Generic.GenericResult.Error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Action? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public Action Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(Action details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Action? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly Action _details; + + internal ResultError(Action details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + public static Result ToResult( this global::FunicularSwitch.Generic.GenericResult result) => result.Match>( @@ -518,54 +577,61 @@ public static Result ToResult( this global::System.Threading.Tasks.Task> result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - } + global::FunicularSwitch.Generic.GenericResult.Error); + } } namespace FunicularSwitch.Generators.Consumer.System.Extensions -{ - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs index 135699a2..534afadb 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs @@ -1,270 +1,288 @@ #nullable enable - -using global::System.Linq; + +using global::System.Linq; using MyNamespace2; -using FunicularSwitch.Generic; - +using FunicularSwitch.Generic; + namespace MyNamespace -{ +{ #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(ErrorInNamespaceWithDifferentResult details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(ErrorInNamespaceWithDifferentResult details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract ErrorInNamespaceWithDifferentResult? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(ErrorInNamespaceWithDifferentResult message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(ErrorInNamespaceWithDifferentResult details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(ErrorInNamespaceWithDifferentResult details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract ErrorInNamespaceWithDifferentResult? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(ErrorInNamespaceWithDifferentResult message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + public static implicit operator global::FunicularSwitch.Generic.GenericResult(Result result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, @@ -278,231 +296,272 @@ public static implicit operator Result(global::FunicularSwitch.Generic.Generi public global::FunicularSwitch.Generic.GenericResult ToGenericResult() => Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override ErrorInNamespaceWithDifferentResult? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public ErrorInNamespaceWithDifferentResult Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(ErrorInNamespaceWithDifferentResult details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override ErrorInNamespaceWithDifferentResult? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly ErrorInNamespaceWithDifferentResult _details; - - internal ResultError(ErrorInNamespaceWithDifferentResult details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - + global::FunicularSwitch.Generic.GenericResult.Error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override ErrorInNamespaceWithDifferentResult? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public ErrorInNamespaceWithDifferentResult Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(ErrorInNamespaceWithDifferentResult details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override ErrorInNamespaceWithDifferentResult? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly ErrorInNamespaceWithDifferentResult _details; + + internal ResultError(ErrorInNamespaceWithDifferentResult details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + public static Result ToResult( this global::FunicularSwitch.Generic.GenericResult result) => result.Match>( @@ -519,54 +578,61 @@ public static Result ToResult( this global::System.Threading.Tasks.Task> result) => result.Match( global::FunicularSwitch.Generic.GenericResult.Ok, - global::FunicularSwitch.Generic.GenericResult.Error); - } + global::FunicularSwitch.Generic.GenericResult.Error); + } } namespace MyNamespace.Extensions -{ - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } +{ + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.ResultWithMerge.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.ResultWithMerge.g.cs index aa09b21a..afd60a12 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.ResultWithMerge.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.ResultWithMerge.g.cs @@ -9,90 +9,135 @@ namespace MyNamespace public abstract partial class Result { - public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result Aggregate(Result r1, Result r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => ResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result Aggregate(Result r1, Result r2, Result r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => ResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => ResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class ResultExtension { - public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => - results.Select(r => r.Map(map)).Aggregate(); + results.Select(r => r.Map(map)).Aggregate(); - public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => - results.Select(r => r.Bind(bind)).Aggregate(); - - public static Result> Bind(this Result result, + results.Select(r => r.Bind(bind)).Aggregate(); + + + public static Result> Bind(this Result result, global::System.Func>> bindMany) => - result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - - public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, + result.Map(ok => bindMany(ok).Aggregate()).Flatten(); + + + public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, Result> bind) => - results.Aggregate().Bind(bind); - - public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + results.Aggregate().Bind(bind); + + + public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; ErrorInNamespaceWithDifferentResult aggregated = default!; @@ -112,28 +157,33 @@ public static Result Bind(this global::System.Collections.Generic.IEn return isError ? Result.Error>(aggregated) : Result.Ok>(oks); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) - .Aggregate(); + .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) - .Aggregate(); - - - public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => + .Aggregate(); + + + + public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static Result Aggregate(this Result r1, Result r2, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2) @@ -146,18 +196,22 @@ public static Result Aggregate(this Result r1, Res )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => + + public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static Result Aggregate(this Result r1, Result r2, Result r3, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3) @@ -170,18 +224,22 @@ public static Result Aggregate(this Result r1, )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => + + public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4) @@ -194,18 +252,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5) @@ -218,18 +280,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6) @@ -242,18 +308,22 @@ public static Result Aggregate(this Re )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7) @@ -266,18 +336,22 @@ public static Result Aggregate(thi )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8) @@ -290,18 +364,22 @@ public static Result Aggregate )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8 && r9 is Result.Ok_ ok9) @@ -314,16 +392,19 @@ public static Result Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); - } - - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + } + + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -338,15 +419,17 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum errors.Add(onEmpty()); return Result.Error(MergeErrors(errors)); - } + } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) - .Aggregate(); - - public static async global::System.Threading.Tasks.Task>> AggregateMany( + .Aggregate(); + + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -372,21 +455,25 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum } })).ConfigureAwait(false); } - } + } - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) - .Aggregate(); - - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + .Aggregate(); + + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates - .Bind(items => items.AllOk(validate)); + .Bind(items => items.AllOk(validate)); - public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - - public static Result Validate(this T item, global::System.Func> validate) + + public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + + public static Result Validate(this T item, global::System.Func> validate) { try { @@ -400,9 +487,10 @@ public static Result Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs index a77445b5..c6659c80 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs @@ -1,123 +1,123 @@ namespace FunicularSwitch.Generators.Consumer -{ +{ public partial record OptionResult(global::FunicularSwitch.Option> M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator OptionResult(global::FunicularSwitch.Option> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Option>(OptionResult ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => OptionResult.SomeOk(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (OptionResult)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; - } - + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator OptionResult(global::FunicularSwitch.Option> ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Option>(OptionResult ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => OptionResult.SomeOk(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (OptionResult)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; + } + public static partial class OptionResult - { - private readonly record struct Impl__FunicularSwitch_Option(global::FunicularSwitch.Option M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator Impl__FunicularSwitch_Option(global::FunicularSwitch.Option ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Option(Impl__FunicularSwitch_Option ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Option)global::FunicularSwitch.Option.Some(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Option)M.Bind(a => (global::FunicularSwitch.Option)(Impl__FunicularSwitch_Option)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public B Cast() => (B)(object)M; - } - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Lift(global::FunicularSwitch.Option ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SomeOk(A a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SomeOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SomeOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Map(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Select(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - } -} + { + private readonly record struct Impl__FunicularSwitch_Option(global::FunicularSwitch.Option M) : global::FunicularSwitch.Transformers.Monad + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator Impl__FunicularSwitch_Option(global::FunicularSwitch.Option ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Option(Impl__FunicularSwitch_Option ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Option)global::FunicularSwitch.Option.Some(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Option)M.Bind(a => (global::FunicularSwitch.Option)(Impl__FunicularSwitch_Option)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public B Cast() => (B)(object)M; + } + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Lift(global::FunicularSwitch.Option ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SomeOk(A a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SomeOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SomeOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Map(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Select(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs index 171039f8..4d7808bc 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs @@ -1,123 +1,123 @@ namespace FunicularSwitch.Generators.Consumer -{ +{ public readonly partial record struct ResultEnumerable(global::FunicularSwitch.Generators.Consumer.Result> M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator ResultEnumerable(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultEnumerable ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultEnumerable.OkYield(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultEnumerable)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; - } - + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator ResultEnumerable(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultEnumerable ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultEnumerable.OkYield(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultEnumerable)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; + } + public static partial class ResultEnumerable - { - private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public B Cast() => (B)(object)M; - } - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable OkYield(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> OkYield(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> OkYield(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Map(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Select(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - } -} + { + private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public B Cast() => (B)(object)M; + } + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable OkYield(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> OkYield(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> OkYield(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Map(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Select(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs index 96dc4c3c..e40e642e 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs @@ -1,123 +1,123 @@ namespace FunicularSwitch.Generators.Consumer -{ +{ public partial record ResultOption(global::FunicularSwitch.Generators.Consumer.Result> M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator ResultOption(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultOption ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultOption.OkSome(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultOption)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; - } - + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator ResultOption(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultOption ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultOption.OkSome(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultOption)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; + } + public static partial class ResultOption - { - private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public B Cast() => (B)(object)M; - } - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption OkSome(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> OkSome(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> OkSome(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Map(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Select(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - } -} + { + private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public B Cast() => (B)(object)M; + } + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption OkSome(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> OkSome(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> OkSome(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Map(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Select(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs index 9f17847e..7f7431b6 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs @@ -1,82 +1,82 @@ namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class WriterResult - { - private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer M) : global::FunicularSwitch.Transformers.Monad - { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static implicit operator global::FunicularSwitch.Generators.Consumer.Writer(Impl__FunicularSwitch_Generators_Consumer_Writer ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Init(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Bind(M, a => (global::FunicularSwitch.Generators.Consumer.Writer)(Impl__FunicularSwitch_Generators_Consumer_Writer)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public B Cast() => (B)(object)M; - } - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Lift(global::FunicularSwitch.Generators.Consumer.Writer ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> InitOk(A a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a)); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> InitOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> InitOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Bind(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Map(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Select(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - } -} + { + private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer M) : global::FunicularSwitch.Transformers.Monad + { + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer ma) => new(ma); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static implicit operator global::FunicularSwitch.Generators.Consumer.Writer(Impl__FunicularSwitch_Generators_Consumer_Writer ma) => ma.M; + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Init(a); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Bind(M, a => (global::FunicularSwitch.Generators.Consumer.Writer)(Impl__FunicularSwitch_Generators_Consumer_Writer)fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public B Cast() => (B)(object)M; + } + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> Lift(global::FunicularSwitch.Generators.Consumer.Writer ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> InitOk(A a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a)); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> InitOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> InitOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> Bind(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> Map(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static global::FunicularSwitch.Generators.Consumer.Writer> Select(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + + [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs index c566832f..270984ae 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.TransformMonadAttribute.g.cs @@ -1,14 +1,14 @@ -using System; - -namespace FunicularSwitch.Generators -{ - /// - /// This generator is still considered experimental and might break. - /// Please open any issues you may find in the GitHub repo. - /// - [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] - internal class TransformMonadAttribute : Attribute - { - public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } - } -} +using System; + +namespace FunicularSwitch.Generators +{ + /// + /// This generator is still considered experimental and might break. + /// Please open any issues you may find in the GitHub repo. + /// + [AttributeUsage((AttributeTargets)12, AllowMultiple = false, Inherited = false)] + internal class TransformMonadAttribute : Attribute + { + public TransformMonadAttribute(System.Type monadType, System.Type transformerType, params System.Type[] extraTransformerTypes) { } + } +} diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerArgumentExceptionMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerArgumentExceptionMatchExtension.g.cs index b798cf29..e759b6bc 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerArgumentExceptionMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerArgumentExceptionMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class ArgumentExceptionMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func action, global::System.Func func) => - argumentException switch - { - FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1 => action(action1), - FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2 => func(func2), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func> action, global::System.Func> func) => - argumentException switch - { - FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1 => await action(action1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2 => await func(func2).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => - (await argumentException.ConfigureAwait(false)).Match(action, func); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func> action, global::System.Func> func) => - await (await argumentException.ConfigureAwait(false)).Match(action, func).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Action action, global::System.Action func) - { - switch (argumentException) - { - case FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1: - action(action1); - break; - case FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2: - func(func2); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func action, global::System.Func func) - { - switch (argumentException) - { - case FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1: - await action(action1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2: - await func(func2).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Action action, global::System.Action func) => - (await argumentException.ConfigureAwait(false)).Switch(action, func); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => - await (await argumentException.ConfigureAwait(false)).Switch(action, func).ConfigureAwait(false); - } - - public abstract partial record ArgumentException - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.ArgumentException Action() => new FunicularSwitch.Generators.Consumer.ArgumentException.Action_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.ArgumentException Func() => new FunicularSwitch.Generators.Consumer.ArgumentException.Func_(); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func action, global::System.Func func) => + argumentException switch + { + FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1 => action(action1), + FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2 => func(func2), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func> action, global::System.Func> func) => + argumentException switch + { + FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1 => await action(action1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2 => await func(func2).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => + (await argumentException.ConfigureAwait(false)).Match(action, func); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func> action, global::System.Func> func) => + await (await argumentException.ConfigureAwait(false)).Match(action, func).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Action action, global::System.Action func) + { + switch (argumentException) + { + case FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1: + action(action1); + break; + case FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2: + func(func2); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.ArgumentException argumentException, global::System.Func action, global::System.Func func) + { + switch (argumentException) + { + case FunicularSwitch.Generators.Consumer.ArgumentException.Action_ action1: + await action(action1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.ArgumentException.Func_ func2: + await func(func2).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.ArgumentException: {argumentException.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Action action, global::System.Action func) => + (await argumentException.ConfigureAwait(false)).Switch(action, func); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => + await (await argumentException.ConfigureAwait(false)).Switch(action, func).ConfigureAwait(false); + } + + public abstract partial record ArgumentException + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.ArgumentException Action() => new FunicularSwitch.Generators.Consumer.ArgumentException.Action_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.ArgumentException Func() => new FunicularSwitch.Generators.Consumer.ArgumentException.Func_(); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerCardTypeMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerCardTypeMatchExtension.g.cs index 0caf1f6b..aa2fc634 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerCardTypeMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerCardTypeMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ internal static partial class CardTypeMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func female, global::System.Func male) => - cardType switch - { - FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1 => female(female1), - FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2 => male(male2), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func> female, global::System.Func> male) => - cardType switch - { - FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1 => await female(female1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2 => await male(male2).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cardType, global::System.Func female, global::System.Func male) => - (await cardType.ConfigureAwait(false)).Match(female, male); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cardType, global::System.Func> female, global::System.Func> male) => - await (await cardType.ConfigureAwait(false)).Match(female, male).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Action female, global::System.Action male) - { - switch (cardType) - { - case FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1: - female(female1); - break; - case FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2: - male(male2); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func female, global::System.Func male) - { - switch (cardType) - { - case FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1: - await female(female1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2: - await male(male2).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cardType, global::System.Action female, global::System.Action male) => - (await cardType.ConfigureAwait(false)).Switch(female, male); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cardType, global::System.Func female, global::System.Func male) => - await (await cardType.ConfigureAwait(false)).Switch(female, male).ConfigureAwait(false); - } - - abstract partial record CardType - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.CardType Female() => new FunicularSwitch.Generators.Consumer.CardType.FemaleCardType(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.CardType Male(int Age) => new FunicularSwitch.Generators.Consumer.CardType.MaleCardType(Age); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func female, global::System.Func male) => + cardType switch + { + FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1 => female(female1), + FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2 => male(male2), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func> female, global::System.Func> male) => + cardType switch + { + FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1 => await female(female1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2 => await male(male2).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cardType, global::System.Func female, global::System.Func male) => + (await cardType.ConfigureAwait(false)).Match(female, male); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task cardType, global::System.Func> female, global::System.Func> male) => + await (await cardType.ConfigureAwait(false)).Match(female, male).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Action female, global::System.Action male) + { + switch (cardType) + { + case FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1: + female(female1); + break; + case FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2: + male(male2); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.CardType cardType, global::System.Func female, global::System.Func male) + { + switch (cardType) + { + case FunicularSwitch.Generators.Consumer.CardType.FemaleCardType female1: + await female(female1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.CardType.MaleCardType male2: + await male(male2).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.CardType: {cardType.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cardType, global::System.Action female, global::System.Action male) => + (await cardType.ConfigureAwait(false)).Switch(female, male); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task cardType, global::System.Func female, global::System.Func male) => + await (await cardType.ConfigureAwait(false)).Switch(female, male).ConfigureAwait(false); + } + + abstract partial record CardType + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.CardType Female() => new FunicularSwitch.Generators.Consumer.CardType.FemaleCardType(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.CardType Male(int Age) => new FunicularSwitch.Generators.Consumer.CardType.MaleCardType(Age); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerErrorMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerErrorMatchExtension.g.cs index 352b3be8..9051aae6 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerErrorMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerErrorMatchExtension.g.cs @@ -1,102 +1,102 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class ErrorMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - error switch - { - FunicularSwitch.Generators.Consumer.Error.Generic_ generic1 => generic(generic1), - FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2 => notFound(notFound2), - FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3 => notAuthorized(notAuthorized3), - FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4 => aggregated(aggregated4), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => - error switch - { - FunicularSwitch.Generators.Consumer.Error.Generic_ generic1 => await generic(generic1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2 => await notFound(notFound2).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3 => await notAuthorized(notAuthorized3).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4 => await aggregated(aggregated4).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - (await error.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task error, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => - await (await error.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) - { - switch (error) - { - case FunicularSwitch.Generators.Consumer.Error.Generic_ generic1: - generic(generic1); - break; - case FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2: - notFound(notFound2); - break; - case FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3: - notAuthorized(notAuthorized3); - break; - case FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4: - aggregated(aggregated4); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) - { - switch (error) - { - case FunicularSwitch.Generators.Consumer.Error.Generic_ generic1: - await generic(generic1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2: - await notFound(notFound2).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3: - await notAuthorized(notAuthorized3).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4: - await aggregated(aggregated4).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task error, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) => - (await error.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => - await (await error.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); - } - - public abstract partial class Error - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Error Generic(string message) => new FunicularSwitch.Generators.Consumer.Error.Generic_(message); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Error NotFound() => new FunicularSwitch.Generators.Consumer.Error.NotFound_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Error NotAuthorized() => new FunicularSwitch.Generators.Consumer.Error.NotAuthorized_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Error Aggregated(global::System.Collections.Immutable.ImmutableList errors) => new FunicularSwitch.Generators.Consumer.Error.Aggregated_(errors); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + error switch + { + FunicularSwitch.Generators.Consumer.Error.Generic_ generic1 => generic(generic1), + FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2 => notFound(notFound2), + FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3 => notAuthorized(notAuthorized3), + FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4 => aggregated(aggregated4), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => + error switch + { + FunicularSwitch.Generators.Consumer.Error.Generic_ generic1 => await generic(generic1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2 => await notFound(notFound2).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3 => await notAuthorized(notAuthorized3).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4 => await aggregated(aggregated4).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + (await error.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task error, global::System.Func> generic, global::System.Func> notFound, global::System.Func> notAuthorized, global::System.Func> aggregated) => + await (await error.ConfigureAwait(false)).Match(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) + { + switch (error) + { + case FunicularSwitch.Generators.Consumer.Error.Generic_ generic1: + generic(generic1); + break; + case FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2: + notFound(notFound2); + break; + case FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3: + notAuthorized(notAuthorized3); + break; + case FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4: + aggregated(aggregated4); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.Error error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) + { + switch (error) + { + case FunicularSwitch.Generators.Consumer.Error.Generic_ generic1: + await generic(generic1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.NotFound_ notFound2: + await notFound(notFound2).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.NotAuthorized_ notAuthorized3: + await notAuthorized(notAuthorized3).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Error.Aggregated_ aggregated4: + await aggregated(aggregated4).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Error: {error.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task error, global::System.Action generic, global::System.Action notFound, global::System.Action notAuthorized, global::System.Action aggregated) => + (await error.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task error, global::System.Func generic, global::System.Func notFound, global::System.Func notAuthorized, global::System.Func aggregated) => + await (await error.ConfigureAwait(false)).Switch(generic, notFound, notAuthorized, aggregated).ConfigureAwait(false); + } + + public abstract partial class Error + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Error Generic(string message) => new FunicularSwitch.Generators.Consumer.Error.Generic_(message); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Error NotFound() => new FunicularSwitch.Generators.Consumer.Error.NotFound_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Error NotAuthorized() => new FunicularSwitch.Generators.Consumer.Error.NotAuthorized_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Error Aggregated(global::System.Collections.Immutable.ImmutableList errors) => new FunicularSwitch.Generators.Consumer.Error.Aggregated_(errors); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerFailureMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerFailureMatchExtension.g.cs index 027285c8..d1d4badc 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerFailureMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerFailureMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class FailureMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func invalidInput, global::System.Func notFound) => - failure switch - { - FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1 => invalidInput(invalidInput1), - FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2 => notFound(notFound2), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func> invalidInput, global::System.Func> notFound) => - failure switch - { - FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1 => await invalidInput(invalidInput1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2 => await notFound(notFound2).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task failure, global::System.Func invalidInput, global::System.Func notFound) => - (await failure.ConfigureAwait(false)).Match(invalidInput, notFound); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task failure, global::System.Func> invalidInput, global::System.Func> notFound) => - await (await failure.ConfigureAwait(false)).Match(invalidInput, notFound).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Action invalidInput, global::System.Action notFound) - { - switch (failure) - { - case FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1: - invalidInput(invalidInput1); - break; - case FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2: - notFound(notFound2); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func invalidInput, global::System.Func notFound) - { - switch (failure) - { - case FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1: - await invalidInput(invalidInput1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2: - await notFound(notFound2).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task failure, global::System.Action invalidInput, global::System.Action notFound) => - (await failure.ConfigureAwait(false)).Switch(invalidInput, notFound); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task failure, global::System.Func invalidInput, global::System.Func notFound) => - await (await failure.ConfigureAwait(false)).Switch(invalidInput, notFound).ConfigureAwait(false); - } - - public abstract partial record Failure - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Failure InvalidInput(string Message) => new FunicularSwitch.Generators.Consumer.InvalidInputFailure(Message); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.Failure NotFound(int Id) => new FunicularSwitch.Generators.Consumer.Failure.NotFound_(Id); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func invalidInput, global::System.Func notFound) => + failure switch + { + FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1 => invalidInput(invalidInput1), + FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2 => notFound(notFound2), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func> invalidInput, global::System.Func> notFound) => + failure switch + { + FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1 => await invalidInput(invalidInput1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2 => await notFound(notFound2).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task failure, global::System.Func invalidInput, global::System.Func notFound) => + (await failure.ConfigureAwait(false)).Match(invalidInput, notFound); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task failure, global::System.Func> invalidInput, global::System.Func> notFound) => + await (await failure.ConfigureAwait(false)).Match(invalidInput, notFound).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Action invalidInput, global::System.Action notFound) + { + switch (failure) + { + case FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1: + invalidInput(invalidInput1); + break; + case FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2: + notFound(notFound2); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.Failure failure, global::System.Func invalidInput, global::System.Func notFound) + { + switch (failure) + { + case FunicularSwitch.Generators.Consumer.InvalidInputFailure invalidInput1: + await invalidInput(invalidInput1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.Failure.NotFound_ notFound2: + await notFound(notFound2).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.Failure: {failure.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task failure, global::System.Action invalidInput, global::System.Action notFound) => + (await failure.ConfigureAwait(false)).Switch(invalidInput, notFound); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task failure, global::System.Func invalidInput, global::System.Func notFound) => + await (await failure.ConfigureAwait(false)).Switch(invalidInput, notFound).ConfigureAwait(false); + } + + public abstract partial record Failure + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Failure InvalidInput(string Message) => new FunicularSwitch.Generators.Consumer.InvalidInputFailure(Message); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.Failure NotFound(int Id) => new FunicularSwitch.Generators.Consumer.Failure.NotFound_(Id); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerGenericResultOfT_TFailureMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerGenericResultOfT_TFailureMatchExtension.g.cs index ebd21cd2..0dba73dd 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerGenericResultOfT_TFailureMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerGenericResultOfT_TFailureMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class GenericResultMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static TMatchResult Match(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, TMatchResult> ok, global::System.Func.Error_, TMatchResult> error) => - genericResult switch - { - FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1 => ok(ok1), - FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2 => error(error2), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => - genericResult switch - { - FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1 => await ok(ok1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2 => await error(error2).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, TMatchResult> ok, global::System.Func.Error_, TMatchResult> error) => - (await genericResult.ConfigureAwait(false)).Match(ok, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => - await (await genericResult.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Action.Ok_> ok, global::System.Action.Error_> error) - { - switch (genericResult) - { - case FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1: - ok(ok1); - break; - case FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2: - error(error2); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) - { - switch (genericResult) - { - case FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1: - await ok(ok1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2: - await error(error2).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task> genericResult, global::System.Action.Ok_> ok, global::System.Action.Error_> error) => - (await genericResult.ConfigureAwait(false)).Switch(ok, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => - await (await genericResult.ConfigureAwait(false)).Switch(ok, error).ConfigureAwait(false); - } - - public abstract partial record GenericResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.GenericResult Ok(T Value) => new FunicularSwitch.Generators.Consumer.GenericResult.Ok_(Value); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.GenericResult Error(TFailure Failure) => new FunicularSwitch.Generators.Consumer.GenericResult.Error_(Failure); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static TMatchResult Match(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, TMatchResult> ok, global::System.Func.Error_, TMatchResult> error) => + genericResult switch + { + FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1 => ok(ok1), + FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2 => error(error2), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => + genericResult switch + { + FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1 => await ok(ok1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2 => await error(error2).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, TMatchResult> ok, global::System.Func.Error_, TMatchResult> error) => + (await genericResult.ConfigureAwait(false)).Match(ok, error); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => + await (await genericResult.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Action.Ok_> ok, global::System.Action.Error_> error) + { + switch (genericResult) + { + case FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1: + ok(ok1); + break; + case FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2: + error(error2); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.GenericResult genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) + { + switch (genericResult) + { + case FunicularSwitch.Generators.Consumer.GenericResult.Ok_ ok1: + await ok(ok1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.GenericResult.Error_ error2: + await error(error2).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.GenericResult: {genericResult.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task> genericResult, global::System.Action.Ok_> ok, global::System.Action.Error_> error) => + (await genericResult.ConfigureAwait(false)).Switch(ok, error); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task> genericResult, global::System.Func.Ok_, global::System.Threading.Tasks.Task> ok, global::System.Func.Error_, global::System.Threading.Tasks.Task> error) => + await (await genericResult.ConfigureAwait(false)).Switch(ok, error).ConfigureAwait(false); + } + + public abstract partial record GenericResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.GenericResult Ok(T Value) => new FunicularSwitch.Generators.Consumer.GenericResult.Ok_(Value); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.GenericResult Error(TFailure Failure) => new FunicularSwitch.Generators.Consumer.GenericResult.Error_(Failure); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerIUnionMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerIUnionMatchExtension.g.cs index 40ae8e3c..6a10ed51 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerIUnionMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerIUnionMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class IUnionMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func case1, global::System.Func case2) => - iUnion switch - { - FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11 => case1(case11), - FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22 => case2(case22), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func> case1, global::System.Func> case2) => - iUnion switch - { - FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11 => await case1(case11).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22 => await case2(case22).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task iUnion, global::System.Func case1, global::System.Func case2) => - (await iUnion.ConfigureAwait(false)).Match(case1, case2); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task iUnion, global::System.Func> case1, global::System.Func> case2) => - await (await iUnion.ConfigureAwait(false)).Match(case1, case2).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Action case1, global::System.Action case2) - { - switch (iUnion) - { - case FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11: - case1(case11); - break; - case FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22: - case2(case22); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func case1, global::System.Func case2) - { - switch (iUnion) - { - case FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11: - await case1(case11).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22: - await case2(case22).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task iUnion, global::System.Action case1, global::System.Action case2) => - (await iUnion.ConfigureAwait(false)).Switch(case1, case2); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task iUnion, global::System.Func case1, global::System.Func case2) => - await (await iUnion.ConfigureAwait(false)).Switch(case1, case2).ConfigureAwait(false); - } - - public partial interface IUnion - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.IUnion Case1() => new FunicularSwitch.Generators.Consumer.IUnion.Case1_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.IUnion Case2() => new FunicularSwitch.Generators.Consumer.IUnion.Case2_(); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func case1, global::System.Func case2) => + iUnion switch + { + FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11 => case1(case11), + FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22 => case2(case22), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func> case1, global::System.Func> case2) => + iUnion switch + { + FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11 => await case1(case11).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22 => await case2(case22).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task iUnion, global::System.Func case1, global::System.Func case2) => + (await iUnion.ConfigureAwait(false)).Match(case1, case2); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task iUnion, global::System.Func> case1, global::System.Func> case2) => + await (await iUnion.ConfigureAwait(false)).Match(case1, case2).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Action case1, global::System.Action case2) + { + switch (iUnion) + { + case FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11: + case1(case11); + break; + case FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22: + case2(case22); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.IUnion iUnion, global::System.Func case1, global::System.Func case2) + { + switch (iUnion) + { + case FunicularSwitch.Generators.Consumer.IUnion.Case1_ case11: + await case1(case11).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.IUnion.Case2_ case22: + await case2(case22).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.IUnion: {iUnion.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task iUnion, global::System.Action case1, global::System.Action case2) => + (await iUnion.ConfigureAwait(false)).Switch(case1, case2); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task iUnion, global::System.Func case1, global::System.Func case2) => + await (await iUnion.ConfigureAwait(false)).Switch(case1, case2).ConfigureAwait(false); + } + + public partial interface IUnion + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.IUnion Case1() => new FunicularSwitch.Generators.Consumer.IUnion.Case1_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.IUnion Case2() => new FunicularSwitch.Generators.Consumer.IUnion.Case2_(); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerSystemArgumentExceptionMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerSystemArgumentExceptionMatchExtension.g.cs index 6f051466..c18a15ee 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerSystemArgumentExceptionMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerSystemArgumentExceptionMatchExtension.g.cs @@ -1,82 +1,82 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer.System -{ +{ public static partial class ArgumentExceptionMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func action, global::System.Func func) => - argumentException switch - { - FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1 => action(action1), - FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2 => func(func2), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func> action, global::System.Func> func) => - argumentException switch - { - FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1 => await action(action1).ConfigureAwait(false), - FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2 => await func(func2).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => - (await argumentException.ConfigureAwait(false)).Match(action, func); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func> action, global::System.Func> func) => - await (await argumentException.ConfigureAwait(false)).Match(action, func).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Action action, global::System.Action func) - { - switch (argumentException) - { - case FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1: - action(action1); - break; - case FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2: - func(func2); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func action, global::System.Func func) - { - switch (argumentException) - { - case FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1: - await action(action1).ConfigureAwait(false); - break; - case FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2: - await func(func2).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Action action, global::System.Action func) => - (await argumentException.ConfigureAwait(false)).Switch(action, func); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => - await (await argumentException.ConfigureAwait(false)).Switch(action, func).ConfigureAwait(false); - } - - public abstract partial record ArgumentException - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.System.ArgumentException Action() => new FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_(); - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.System.ArgumentException Func() => new FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_(); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func action, global::System.Func func) => + argumentException switch + { + FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1 => action(action1), + FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2 => func(func2), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func> action, global::System.Func> func) => + argumentException switch + { + FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1 => await action(action1).ConfigureAwait(false), + FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2 => await func(func2).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => + (await argumentException.ConfigureAwait(false)).Match(action, func); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task argumentException, global::System.Func> action, global::System.Func> func) => + await (await argumentException.ConfigureAwait(false)).Match(action, func).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Action action, global::System.Action func) + { + switch (argumentException) + { + case FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1: + action(action1); + break; + case FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2: + func(func2); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.System.ArgumentException argumentException, global::System.Func action, global::System.Func func) + { + switch (argumentException) + { + case FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_ action1: + await action(action1).ConfigureAwait(false); + break; + case FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_ func2: + await func(func2).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.System.ArgumentException: {argumentException.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Action action, global::System.Action func) => + (await argumentException.ConfigureAwait(false)).Switch(action, func); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task argumentException, global::System.Func action, global::System.Func func) => + await (await argumentException.ConfigureAwait(false)).Switch(action, func).ConfigureAwait(false); + } + + public abstract partial record ArgumentException + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.System.ArgumentException Action() => new FunicularSwitch.Generators.Consumer.System.ArgumentException.Action_(); + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.System.ArgumentException Func() => new FunicularSwitch.Generators.Consumer.System.ArgumentException.Func_(); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerWithPrimaryConstructorMatchExtension.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerWithPrimaryConstructorMatchExtension.g.cs index 7a528f92..44989825 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerWithPrimaryConstructorMatchExtension.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.UnionTypeGenerator/FunicularSwitchGeneratorsConsumerWithPrimaryConstructorMatchExtension.g.cs @@ -1,72 +1,72 @@ -#pragma warning disable 1591 -#nullable enable +#pragma warning disable 1591 +#nullable enable namespace FunicularSwitch.Generators.Consumer -{ +{ public static partial class WithPrimaryConstructorMatchExtension - { - [global::System.Diagnostics.DebuggerStepThrough] - public static T Match(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func derived) => - withPrimaryConstructor switch - { - FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1 => derived(derived1), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func> derived) => - withPrimaryConstructor switch - { - FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1 => await derived(derived1).ConfigureAwait(false), - _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}") - }; - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func derived) => - (await withPrimaryConstructor.ConfigureAwait(false)).Match(derived); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func> derived) => - await (await withPrimaryConstructor.ConfigureAwait(false)).Match(derived).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static void Switch(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Action derived) - { - switch (withPrimaryConstructor) - { - case FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1: - derived(derived1); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func derived) - { - switch (withPrimaryConstructor) - { - case FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1: - await derived(derived1).ConfigureAwait(false); - break; - default: - throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Action derived) => - (await withPrimaryConstructor.ConfigureAwait(false)).Switch(derived); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func derived) => - await (await withPrimaryConstructor.ConfigureAwait(false)).Switch(derived).ConfigureAwait(false); - } - - public abstract partial class WithPrimaryConstructor - { - [global::System.Diagnostics.DebuggerStepThrough] - public static FunicularSwitch.Generators.Consumer.WithPrimaryConstructor Derived(string message, int test) => new FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor(message, test); - } -} -#pragma warning restore 1591 + { + [global::System.Diagnostics.DebuggerStepThrough] + public static T Match(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func derived) => + withPrimaryConstructor switch + { + FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1 => derived(derived1), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func> derived) => + withPrimaryConstructor switch + { + FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1 => await derived(derived1).ConfigureAwait(false), + _ => throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}") + }; + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func derived) => + (await withPrimaryConstructor.ConfigureAwait(false)).Match(derived); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func> derived) => + await (await withPrimaryConstructor.ConfigureAwait(false)).Match(derived).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + public static void Switch(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Action derived) + { + switch (withPrimaryConstructor) + { + case FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1: + derived(derived1); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::FunicularSwitch.Generators.Consumer.WithPrimaryConstructor withPrimaryConstructor, global::System.Func derived) + { + switch (withPrimaryConstructor) + { + case FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor derived1: + await derived(derived1).ConfigureAwait(false); + break; + default: + throw new global::System.ArgumentException($"Unknown type derived from FunicularSwitch.Generators.Consumer.WithPrimaryConstructor: {withPrimaryConstructor.GetType().Name}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Action derived) => + (await withPrimaryConstructor.ConfigureAwait(false)).Switch(derived); + + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task Switch(this global::System.Threading.Tasks.Task withPrimaryConstructor, global::System.Func derived) => + await (await withPrimaryConstructor.ConfigureAwait(false)).Switch(derived).ConfigureAwait(false); + } + + public abstract partial class WithPrimaryConstructor + { + [global::System.Diagnostics.DebuggerStepThrough] + public static FunicularSwitch.Generators.Consumer.WithPrimaryConstructor Derived(string message, int test) => new FunicularSwitch.Generators.Consumer.DerivedWithPrimaryConstructor(message, test); + } +} +#pragma warning restore 1591 diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs index 70724865..33e8ef2b 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs @@ -126,8 +126,8 @@ from z in Sqrt(y) // Assert using (new AssertionScope()) { - string.Join(Environment.NewLine, result.Log).Should().Be(expectedLog); - ((string) result.Value.ToString()).Should().Be(expectedResult); + string.Join("\n", result.Log).Should().Be(expectedLog); + result.Value.ToString().Should().Be(expectedResult); } static Writer> Sqrt(int a) => diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs index 16237eb1..a4999289 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(MyError details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(MyError details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static OperationResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(OperationResult result) => result.IsOk; + + public static bool operator false(OperationResult result) => result.IsError; + + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct OperationResultError : global::System.IEquatable - { - readonly MyError _details; - - internal OperationResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - public static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct OperationResultError : global::System.IEquatable + { + readonly MyError _details; + + internal OperationResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + public static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult MapError(this OperationResult result, global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class OperationResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this object? item, global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNull(this T? item, global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs index d6183dae..43d69623 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs @@ -9,90 +9,135 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { - public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => OperationResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => OperationResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class OperationResultExtension { - public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => results.Select(r => r.Map(map)).Aggregate(); - public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => results.Select(r => r.Bind(bind)).Aggregate(); - public static OperationResult> Bind(this OperationResult result, + + public static OperationResult> Bind(this OperationResult result, global::System.Func>> bindMany) => result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, OperationResult> bind) => results.Aggregate().Bind(bind); - - public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + + + public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; MyError aggregated = default!; @@ -114,26 +159,31 @@ public static OperationResult Bind(this global::System.Collections.Ge : OperationResult.Ok>(oks); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) .Aggregate(); - - public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => + + + public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2) @@ -146,18 +196,22 @@ public static OperationResult Aggregate(this Operation )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => + + public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3) @@ -170,18 +224,22 @@ public static OperationResult Aggregate(this Opera )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4) @@ -194,18 +252,22 @@ public static OperationResult Aggregate(this O )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5) @@ -218,18 +280,22 @@ public static OperationResult Aggregate(th )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6) @@ -242,18 +308,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7) @@ -266,18 +336,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8) @@ -290,18 +364,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8 && r9 is OperationResult.Ok_ ok9) @@ -314,16 +392,19 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -340,13 +421,15 @@ public static OperationResult FirstOk(this global::System.Collections.Gene return OperationResult.Error(MergeErrors(errors)); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -374,19 +457,23 @@ public static OperationResult FirstOk(this global::System.Collections.Gene } } - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) .Aggregate(); - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates .Bind(items => items.AllOk(validate)); - public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - public static OperationResult Validate(this T item, global::System.Func> validate) + + public static OperationResult Validate(this T item, global::System.Func> validate) { try { @@ -402,7 +489,8 @@ public static OperationResult Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs index fac8fc2b..0d06caa4 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class Result - { - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Error(String details) => new Result.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static ResultError Error(String details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Ok(T value) => new Result.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); - public bool IsOk => !IsError; - public abstract String? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new Result Error(String message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static Result Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(T value) => Result.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(Result result) => result.IsOk; - public static bool operator false(Result result) => result.IsError; - - public static bool operator !(Result result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(Result other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((Result)obj); - } - - public static bool operator ==(Result? left, Result? right) => Equals(left, right); - - public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okResult => ok(okResult.Value), - Error_ errorResult => error(errorResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), - Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class Result + { + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Error(String details) => new Result.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static ResultError Error(String details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static Result Ok(T value) => new Result.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); + public bool IsOk => !IsError; + public abstract String? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class Result : Result, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static Result Error(String message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static Result Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(T value) => Result.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(Result result) => result.IsOk; + + public static bool operator false(Result result) => result.IsError; + + public static bool operator !(Result result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(Result other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(Result)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((Result)obj); + } + + public static bool operator ==(Result? left, Result? right) => Equals(left, right); + + public static bool operator !=(Result? left, Result? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okResult => ok(okResult.Value), + Error_ errorResult => error(errorResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okResult => await ok(okResult.Value).ConfigureAwait(false), + Error_ errorResult => await error(errorResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okResult) await ok(okResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public Result Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public Result Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return Result.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return Result.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : Result - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : Result - { - public String Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(String details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public Result.Error_ Convert() => new Result.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct ResultError : global::System.IEquatable - { - readonly String _details; - - internal ResultError(String details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public Result WithOk() => Result.Error(_details); - - public bool Equals(ResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is ResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); - - public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); - } - - public static partial class ResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result MapError(this Result result, global::System.Func mapError) - { - if (result is Result.Error_ e) - return Result.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Flatten(this Result> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return Result.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this Result result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : Result + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : Result + { + public String Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(String details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public Result.Error_ Convert() => new Result.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct ResultError : global::System.IEquatable + { + readonly String _details; + + internal ResultError(String details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public Result WithOk() => Result.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(ResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is ResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(ResultError left, ResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(ResultError left, ResultError right) => !left.Equals(right); + } + + public static partial class ResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => Result.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result MapError(this Result result, global::System.Func mapError) + { + if (result is Result.Error_ e) + return Result.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static Result Flatten(this Result> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return Result.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this Result result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result Select(this Result result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result SelectMany(this Result result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this Result result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class ResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result As(this object? item, global::System.Func error) => - !(item is T t) ? Result.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNull(this T? item, global::System.Func error) => - item ?? Result.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; - - public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class ResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result As(this object? item, global::System.Func error) => + !(item is T t) ? Result.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNull(this T? item, global::System.Func error) => + item ?? Result.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? Result.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static Result NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? Result.Error(error()) : s!; + + + public static Result First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.ResultWithMerge.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.ResultWithMerge.g.verified.cs index 8e463ac5..977e7900 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.ResultWithMerge.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.ResultWithMerge.g.verified.cs @@ -9,90 +9,135 @@ namespace FunicularSwitch.Test public abstract partial class Result { - public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result<(T1, T2)> Aggregate(Result r1, Result r2) => ResultExtension.Aggregate(r1, r2); + + public static Result Aggregate(Result r1, Result r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => ResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, combine); - public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result<(T1, T2, T3)> Aggregate(Result r1, Result r2, Result r3) => ResultExtension.Aggregate(r1, r2, r3); + + public static Result Aggregate(Result r1, Result r2, Result r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => ResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, combine); - public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result<(T1, T2, T3, T4)> Aggregate(Result r1, Result r2, Result r3, Result r4) => ResultExtension.Aggregate(r1, r2, r3, r4); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => ResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => ResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static Result Aggregate(Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => ResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class ResultExtension { - public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => results.Select(r => r.Map(map)).Aggregate(); - public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => results.Select(r => r.Bind(bind)).Aggregate(); - public static Result> Bind(this Result result, + + public static Result> Bind(this Result result, global::System.Func>> bindMany) => result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static Result Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, Result> bind) => results.Aggregate().Bind(bind); - - public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + + + public static Result> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; String aggregated = default!; @@ -114,26 +159,31 @@ public static Result Bind(this global::System.Collections.Generic.IEn : Result.Ok>(oks); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) .Aggregate(); - - public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => + + + public static Result<(T1, T2)> Aggregate(this Result r1, Result r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static Result Aggregate(this Result r1, Result r2, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2) @@ -146,18 +196,22 @@ public static Result Aggregate(this Result r1, Res )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => + + public static Result<(T1, T2, T3)> Aggregate(this Result r1, Result r2, Result r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static Result Aggregate(this Result r1, Result r2, Result r3, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3) @@ -170,18 +224,22 @@ public static Result Aggregate(this Result r1, )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => + + public static Result<(T1, T2, T3, T4)> Aggregate(this Result r1, Result r2, Result r3, Result r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4) @@ -194,18 +252,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => + + public static Result<(T1, T2, T3, T4, T5)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5) @@ -218,18 +280,22 @@ public static Result Aggregate(this Result )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => + + public static Result<(T1, T2, T3, T4, T5, T6)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6) @@ -242,18 +308,22 @@ public static Result Aggregate(this Re )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7) @@ -266,18 +336,22 @@ public static Result Aggregate(thi )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8) @@ -290,18 +364,22 @@ public static Result Aggregate )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => + + public static Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static Result Aggregate(this Result r1, Result r2, Result r3, Result r4, Result r5, Result r6, Result r7, Result r8, Result r9, global::System.Func combine) { if (r1 is Result.Ok_ ok1 && r2 is Result.Ok_ ok2 && r3 is Result.Ok_ ok3 && r4 is Result.Ok_ ok4 && r5 is Result.Ok_ ok5 && r6 is Result.Ok_ ok6 && r7 is Result.Ok_ ok7 && r8 is Result.Ok_ ok8 && r9 is Result.Ok_ ok9) @@ -314,16 +392,19 @@ public static Result Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); } - public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -340,13 +421,15 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum return Result.Error(MergeErrors(errors)); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -374,19 +457,23 @@ public static Result FirstOk(this global::System.Collections.Generic.IEnum } } - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) .Aggregate(); - public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + + public static Result> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates .Bind(items => items.AllOk(validate)); - public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + public static Result Validate(this Result item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - public static Result Validate(this T item, global::System.Func> validate) + + public static Result Validate(this T item, global::System.Func> validate) { try { @@ -402,7 +489,8 @@ public static Result Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static Result FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs index eb3b8a7a..75158a23 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(MyError details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(MyError details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static OperationResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(OperationResult result) => result.IsOk; + + public static bool operator false(OperationResult result) => result.IsError; + + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct OperationResultError : global::System.IEquatable - { - readonly MyError _details; - - internal OperationResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - public static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct OperationResultError : global::System.IEquatable + { + readonly MyError _details; + + internal OperationResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + public static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult MapError(this OperationResult result, global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class OperationResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this object? item, global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNull(this T? item, global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs index c4a8040a..dacfd1ce 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs @@ -10,90 +10,135 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { - public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => OperationResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => OperationResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class OperationResultExtension { - public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => results.Select(r => r.Map(map)).Aggregate(); - public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => results.Select(r => r.Bind(bind)).Aggregate(); - public static OperationResult> Bind(this OperationResult result, + + public static OperationResult> Bind(this OperationResult result, global::System.Func>> bindMany) => result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, OperationResult> bind) => results.Aggregate().Bind(bind); - - public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + + + public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; MyError aggregated = default!; @@ -115,26 +160,31 @@ public static OperationResult Bind(this global::System.Collections.Ge : OperationResult.Ok>(oks); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) .Aggregate(); - - public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => + + + public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2) @@ -147,18 +197,22 @@ public static OperationResult Aggregate(this Operation )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => + + public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3) @@ -171,18 +225,22 @@ public static OperationResult Aggregate(this Opera )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4) @@ -195,18 +253,22 @@ public static OperationResult Aggregate(this O )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5) @@ -219,18 +281,22 @@ public static OperationResult Aggregate(th )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6) @@ -243,18 +309,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7) @@ -267,18 +337,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8) @@ -291,18 +365,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8 && r9 is OperationResult.Ok_ ok9) @@ -315,16 +393,19 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -341,13 +422,15 @@ public static OperationResult FirstOk(this global::System.Collections.Gene return OperationResult.Error(MergeErrors(errors)); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -375,19 +458,23 @@ public static OperationResult FirstOk(this global::System.Collections.Gene } } - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) .Aggregate(); - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates .Bind(items => items.AllOk(validate)); - public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - public static OperationResult Validate(this T item, global::System.Func> validate) + + public static OperationResult Validate(this T item, global::System.Func> validate) { try { @@ -403,7 +490,8 @@ public static OperationResult Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs index 1282cee0..e38ab24a 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(MyError details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try([global::JetBrains.Annotations.InstantHandle]global::System.Func action, [global::JetBrains.Annotations.InstantHandle]global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try([global::JetBrains.Annotations.InstantHandle]global::System.Func> action, [global::JetBrains.Annotations.InstantHandle]global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match([global::JetBrains.Annotations.InstantHandle]global::System.Action ok, [global::JetBrains.Annotations.InstantHandle]global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match([global::JetBrains.Annotations.InstantHandle]global::System.Func ok, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match([global::JetBrains.Annotations.InstantHandle]global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind([global::JetBrains.Annotations.InstantHandle]global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(MyError details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Try([global::JetBrains.Annotations.InstantHandle] global::System.Func action, [global::JetBrains.Annotations.InstantHandle] global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Try([global::JetBrains.Annotations.InstantHandle] global::System.Func> action, [global::JetBrains.Annotations.InstantHandle] global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Try([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> action, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + [global::JetBrains.Annotations.MustUseReturnValue] + public new static OperationResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator true(OperationResult result) => result.IsOk; + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator false(OperationResult result) => result.IsError; + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + [global::JetBrains.Annotations.MustUseReturnValue] + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match([global::JetBrains.Annotations.InstantHandle] global::System.Action ok, [global::JetBrains.Annotations.InstantHandle] global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T1 Match([global::JetBrains.Annotations.InstantHandle] global::System.Func ok, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T Match([global::JetBrains.Annotations.InstantHandle] global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public OperationResult Bind([global::JetBrains.Annotations.InstantHandle] global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task> Bind([global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map([global::JetBrains.Annotations.InstantHandle]global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public OperationResult Map([global::JetBrains.Annotations.InstantHandle] global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public async global::System.Threading.Tasks.Task> Map( + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault([global::JetBrains.Annotations.InstantHandle]global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct OperationResultError : global::System.IEquatable - { - readonly MyError _details; - - internal OperationResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - public static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func ok, - [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public T GetValueOrDefault([global::JetBrains.Annotations.InstantHandle] global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + [global::JetBrains.Annotations.MustUseReturnValue] + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + [global::JetBrains.Annotations.MustUseReturnValue] + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct OperationResultError : global::System.IEquatable + { + readonly MyError _details; + + internal OperationResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + public static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult MapError(this OperationResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func> ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func ok, + [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)] global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult As(this OperationResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult As(this OperationResult result, [global::JetBrains.Annotations.InstantHandle] global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, [global::JetBrains.Annotations.InstantHandle]global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func predicate, [global::JetBrains.Annotations.InstantHandle]global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class OperationResultExtension + { + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + [global::JetBrains.Annotations.MustUseReturnValue] + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult As(this object? item, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult NotNull(this T? item, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult NotNullOrEmpty(this string? s, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult NotNullOrWhiteSpace(this string? s, [global::JetBrains.Annotations.InstantHandle] global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle] global::System.Func predicate, [global::JetBrains.Annotations.InstantHandle] global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs index b1aaaa09..9e590558 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs @@ -9,90 +9,135 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { - public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => OperationResultExtension.Aggregate(r1, r2); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => OperationResultExtension.Aggregate(r1, r2, r3); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class OperationResultExtension { - public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func map) => results.Select(r => r.Map(map)).Aggregate(); - public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func> bind) => results.Select(r => r.Bind(bind)).Aggregate(); - public static OperationResult> Bind(this OperationResult result, + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> Bind(this OperationResult result, [global::JetBrains.Annotations.InstantHandle]global::System.Func>> bindMany) => result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func, OperationResult> bind) => results.Aggregate().Bind(bind); - - public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; MyError aggregated = default!; @@ -114,26 +159,31 @@ public static OperationResult Bind(this global::System.Collections.Ge : OperationResult.Ok>(oks); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) .Aggregate(); - - public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => + + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2) @@ -146,18 +196,22 @@ public static OperationResult Aggregate(this Operation )!); } + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3) @@ -170,18 +224,22 @@ public static OperationResult Aggregate(this Opera )!); } + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4) @@ -194,18 +252,22 @@ public static OperationResult Aggregate(this O )!); } + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5) @@ -218,18 +280,22 @@ public static OperationResult Aggregate(th )!); } + [global::JetBrains.Annotations.MustUseReturnValue] public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6) @@ -242,18 +308,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7) @@ -266,18 +336,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8) @@ -290,18 +364,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + [global::JetBrains.Annotations.MustUseReturnValue] public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8 && r9 is OperationResult.Ok_ ok9) @@ -314,16 +392,19 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -340,13 +421,15 @@ public static OperationResult FirstOk(this global::System.Collections.Gene return OperationResult.Error(MergeErrors(errors)); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + [global::JetBrains.Annotations.MustUseReturnValue] + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -374,19 +457,23 @@ public static OperationResult FirstOk(this global::System.Collections.Gene } } - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) .Aggregate(); - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => candidates .Bind(items => items.AllOk(validate)); - public static OperationResult Validate(this OperationResult item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Validate(this OperationResult item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - public static OperationResult Validate(this T item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult Validate(this T item, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate) { try { @@ -402,7 +489,8 @@ public static OperationResult Validate(this T item, [global::JetBrains.Ann } } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) => + [global::JetBrains.Annotations.MustUseReturnValue] + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, [global::JetBrains.Annotations.InstantHandle]global::System.Func> validate, [global::JetBrains.Annotations.InstantHandle]global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs index 7daaf0f8..4c92c818 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(MyError details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(MyError details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static OperationResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(OperationResult result) => result.IsOk; + + public static bool operator false(OperationResult result) => result.IsError; + + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct OperationResultError : global::System.IEquatable - { - readonly MyError _details; - - internal OperationResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - public static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + return OperationResult.Error(FunicularSwitch.Test.ErrorFactory.FromException(e)); + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct OperationResultError : global::System.IEquatable + { + readonly MyError _details; + + internal OperationResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + public static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult MapError(this OperationResult result, global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class OperationResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this object? item, global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNull(this T? item, global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs index 9c789574..8742a912 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResultWithMerge.g.verified.cs @@ -9,90 +9,135 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { - public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult<(T1, T2)> Aggregate(OperationResult r1, OperationResult r2) => OperationResultExtension.Aggregate(r1, r2); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => OperationResultExtension.Aggregate(r1, r2); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, combine); - public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult<(T1, T2, T3)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3) => OperationResultExtension.Aggregate(r1, r2, r3); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => OperationResultExtension.Aggregate(r1, r2, r3); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, combine); - public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => OperationResultExtension.Aggregate(r1, r2, r3, r4); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, combine); - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, combine); - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); + + public static OperationResult Aggregate(OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9); - + + public static global::System.Threading.Tasks.Task> Aggregate(global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) => OperationResultExtension.Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, combine); } public static partial class OperationResultExtension { - public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Map(this global::System.Collections.Generic.IEnumerable> results, global::System.Func map) => results.Select(r => r.Map(map)).Aggregate(); - public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult> Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func> bind) => results.Select(r => r.Bind(bind)).Aggregate(); - public static OperationResult> Bind(this OperationResult result, + + public static OperationResult> Bind(this OperationResult result, global::System.Func>> bindMany) => result.Map(ok => bindMany(ok).Aggregate()).Flatten(); - public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, + + public static OperationResult Bind(this global::System.Collections.Generic.IEnumerable> results, global::System.Func, OperationResult> bind) => results.Aggregate().Bind(bind); - - public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) + + + public static OperationResult> Aggregate(this global::System.Collections.Generic.IEnumerable> results) { var isError = false; MyError aggregated = default!; @@ -114,26 +159,31 @@ public static OperationResult Bind(this global::System.Collections.Ge : OperationResult.Ok>(oks); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Threading.Tasks.Task>> results) => (await results.ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results) => (await global::System.Threading.Tasks.Task.WhenAll(results.Select(e => e)).ConfigureAwait(false)) .SelectMany(e => e) .Aggregate(); - - public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => + + + public static OperationResult<(T1, T2)> Aggregate(this OperationResult r1, OperationResult r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2) @@ -146,18 +196,22 @@ public static OperationResult Aggregate(this Operation )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2) => Aggregate(r1, r2, (v1, v2) => (v1, v2)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2); return Aggregate(r1.Result, r2.Result, combine); } - public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => + + public static OperationResult<(T1, T2, T3)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3) @@ -170,18 +224,22 @@ public static OperationResult Aggregate(this Opera )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3) => Aggregate(r1, r2, r3, (v1, v2, v3) => (v1, v2, v3)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3); return Aggregate(r1.Result, r2.Result, r3.Result, combine); } - public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => + + public static OperationResult<(T1, T2, T3, T4)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4) @@ -194,18 +252,22 @@ public static OperationResult Aggregate(this O )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4) => Aggregate(r1, r2, r3, r4, (v1, v2, v3, v4) => (v1, v2, v3, v4)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => + + public static OperationResult<(T1, T2, T3, T4, T5)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5) @@ -218,18 +280,22 @@ public static OperationResult Aggregate(th )!); } + public static global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5) => Aggregate(r1, r2, r3, r4, r5, (v1, v2, v3, v4, v5) => (v1, v2, v3, v4, v5)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6) @@ -242,18 +308,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6) => Aggregate(r1, r2, r3, r4, r5, r6, (v1, v2, v3, v4, v5, v6) => (v1, v2, v3, v4, v5, v6)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7) @@ -266,18 +336,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7) => Aggregate(r1, r2, r3, r4, r5, r6, r7, (v1, v2, v3, v4, v5, v6, v7) => (v1, v2, v3, v4, v5, v6, v7)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8) @@ -290,18 +364,22 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, (v1, v2, v3, v4, v5, v6, v7, v8) => (v1, v2, v3, v4, v5, v6, v7, v8)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, combine); } - public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => + + public static OperationResult<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); + public static OperationResult Aggregate(this OperationResult r1, OperationResult r2, OperationResult r3, OperationResult r4, OperationResult r5, OperationResult r6, OperationResult r7, OperationResult r8, OperationResult r9, global::System.Func combine) { if (r1 is OperationResult.Ok_ ok1 && r2 is OperationResult.Ok_ ok2 && r3 is OperationResult.Ok_ ok3 && r4 is OperationResult.Ok_ ok4 && r5 is OperationResult.Ok_ ok5 && r6 is OperationResult.Ok_ ok6 && r7 is OperationResult.Ok_ ok7 && r8 is OperationResult.Ok_ ok8 && r9 is OperationResult.Ok_ ok9) @@ -314,16 +392,19 @@ public static OperationResult Aggregate> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9) => Aggregate(r1, r2, r3, r4, r5, r6, r7, r8, r9, (v1, v2, v3, v4, v5, v6, v7, v8, v9) => (v1, v2, v3, v4, v5, v6, v7, v8, v9)); - + + public static async global::System.Threading.Tasks.Task> Aggregate(this global::System.Threading.Tasks.Task> r1, global::System.Threading.Tasks.Task> r2, global::System.Threading.Tasks.Task> r3, global::System.Threading.Tasks.Task> r4, global::System.Threading.Tasks.Task> r5, global::System.Threading.Tasks.Task> r6, global::System.Threading.Tasks.Task> r7, global::System.Threading.Tasks.Task> r8, global::System.Threading.Tasks.Task> r9, global::System.Func combine) { await global::System.Threading.Tasks.Task.WhenAll(r1, r2, r3, r4, r5, r6, r7, r8, r9); return Aggregate(r1.Result, r2.Result, r3.Result, r4.Result, r5.Result, r6.Result, r7.Result, r8.Result, r9.Result, combine); } - public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable> results, global::System.Func onEmpty) { var errors = new global::System.Collections.Generic.List(); foreach (var result in results) @@ -340,13 +421,15 @@ public static OperationResult FirstOk(this global::System.Collections.Gene return OperationResult.Error(MergeErrors(errors)); } - public static async global::System.Threading.Tasks.Task>> Aggregate( + + public static async global::System.Threading.Tasks.Task>> Aggregate( this global::System.Collections.Generic.IEnumerable>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) .Aggregate(); - public static async global::System.Threading.Tasks.Task>> AggregateMany( + + public static async global::System.Threading.Tasks.Task>> AggregateMany( this global::System.Collections.Generic.IEnumerable>>> results, int maxDegreeOfParallelism) => (await results.SelectAsync(e => e, maxDegreeOfParallelism).ConfigureAwait(false)) @@ -374,19 +457,23 @@ public static OperationResult FirstOk(this global::System.Collections.Gene } } - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate) => candidates .Select(c => c.Validate(validate)) .Aggregate(); - public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, + + public static OperationResult> AllOk(this global::System.Collections.Generic.IEnumerable> candidates, global::System.Func> validate) => candidates .Bind(items => items.AllOk(validate)); - public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); + + public static OperationResult Validate(this OperationResult item, global::System.Func> validate) => item.Bind(i => i.Validate(validate)); - public static OperationResult Validate(this T item, global::System.Func> validate) + + public static OperationResult Validate(this T item, global::System.Func> validate) { try { @@ -402,7 +489,8 @@ public static OperationResult Validate(this T item, global::System.Func FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => + + public static OperationResult FirstOk(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func> validate, global::System.Func onEmpty) => candidates .Select(r => r.Validate(validate)) .FirstOk(onEmpty); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs index 753e38cd..64915e1d 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - abstract partial class OperationResult - { - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Error(MyError details) => new OperationResult.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResultError Error(MyError details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Ok(T value) => new OperationResult.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); - public bool IsOk => !IsError; - public abstract MyError? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new OperationResult Error(MyError message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static OperationResult Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(T value) => OperationResult.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - - public static bool operator true(OperationResult result) => result.IsOk; - public static bool operator false(OperationResult result) => result.IsError; - - public static bool operator !(OperationResult result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(OperationResult other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((OperationResult)obj); - } - - public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - - public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okOperationResult => ok(okOperationResult.Value), - Error_ errorOperationResult => error(errorOperationResult.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), - Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + abstract partial class OperationResult + { + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Error(MyError details) => new OperationResult.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResultError Error(MyError details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static OperationResult Ok(T value) => new OperationResult.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); + public bool IsOk => !IsError; + public abstract MyError? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + abstract partial class OperationResult : OperationResult, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static OperationResult Error(MyError message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static OperationResult Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(T value) => OperationResult.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); + + + public static bool operator true(OperationResult result) => result.IsOk; + + public static bool operator false(OperationResult result) => result.IsError; + + public static bool operator !(OperationResult result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(OperationResult other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(OperationResult)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((OperationResult)obj); + } + + public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); + + public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okOperationResult => ok(okOperationResult.Value), + Error_ errorOperationResult => error(errorOperationResult.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okOperationResult => await ok(okOperationResult.Value).ConfigureAwait(false), + Error_ errorOperationResult => await error(errorOperationResult.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okOperationResult) await ok(okOperationResult.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public OperationResult Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return OperationResult.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : OperationResult - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : OperationResult - { - public MyError Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(MyError details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override MyError? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - readonly partial struct OperationResultError : global::System.IEquatable - { - readonly MyError _details; - - internal OperationResultError(MyError details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public OperationResult WithOk() => OperationResult.Error(_details); - - public bool Equals(OperationResultError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); - - public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); - } - - static partial class OperationResultExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult MapError(this OperationResult result, global::System.Func mapError) - { - if (result is OperationResult.Error_ e) - return OperationResult.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return OperationResult.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : OperationResult + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : OperationResult + { + public MyError Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(MyError details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public OperationResult.Error_ Convert() => new OperationResult.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override MyError? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + readonly partial struct OperationResultError : global::System.IEquatable + { + readonly MyError _details; + + internal OperationResultError(MyError details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public OperationResult WithOk() => OperationResult.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(OperationResultError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is OperationResultError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(OperationResultError left, OperationResultError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(OperationResultError left, OperationResultError right) => !left.Equals(right); + } + + static partial class OperationResultExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => OperationResult.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult MapError(this OperationResult result, global::System.Func mapError) + { + if (result is OperationResult.Error_ e) + return OperationResult.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static OperationResult Flatten(this OperationResult> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return OperationResult.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this OperationResult result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult Select(this OperationResult result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult SelectMany(this OperationResult result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this OperationResult result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - static partial class OperationResultExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult As(this object? item, global::System.Func error) => - !(item is T t) ? OperationResult.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNull(this T? item, global::System.Func error) => - item ?? OperationResult.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; - - public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + static partial class OperationResultExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult As(this object? item, global::System.Func error) => + !(item is T t) ? OperationResult.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNull(this T? item, global::System.Func error) => + item ?? OperationResult.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? OperationResult.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static OperationResult NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? OperationResult.Error(error()) : s!; + + + public static OperationResult First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_union_type_generator.ForUnionType_WhenReferencingJetBrainsAnnotationsPackage_AddsInstantHandleAttributes#BaseTypeMatchExtension.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_union_type_generator.ForUnionType_WhenReferencingJetBrainsAnnotationsPackage_AddsInstantHandleAttributes#BaseTypeMatchExtension.g.verified.cs index e0e0334d..e1bafd82 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_union_type_generator.ForUnionType_WhenReferencingJetBrainsAnnotationsPackage_AddsInstantHandleAttributes#BaseTypeMatchExtension.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_union_type_generator.ForUnionType_WhenReferencingJetBrainsAnnotationsPackage_AddsInstantHandleAttributes#BaseTypeMatchExtension.g.verified.cs @@ -4,6 +4,7 @@ public static partial class BaseTypeMatchExtension { [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] public static T Match(this global::BaseType baseType, [global::JetBrains.Annotations.InstantHandle]global::System.Func derived) => baseType switch { @@ -12,6 +13,7 @@ public static T Match(this global::BaseType baseType, [global::JetBrains.Anno }; [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task Match(this global::BaseType baseType, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> derived) => baseType switch { @@ -20,10 +22,12 @@ public static T Match(this global::BaseType baseType, [global::JetBrains.Anno }; [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task baseType, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func derived) => (await baseType.ConfigureAwait(false)).Match(derived); [global::System.Diagnostics.DebuggerStepThrough] + [global::JetBrains.Annotations.MustUseReturnValue] public static async global::System.Threading.Tasks.Task Match(this global::System.Threading.Tasks.Task baseType, [global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]global::System.Func> derived) => await (await baseType.ConfigureAwait(false)).Match(derived).ConfigureAwait(false); diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs index 8f488a39..15442900 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class MonadA - { - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Error(String details) => new MonadA.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadAError Error(String details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Ok(T value) => new MonadA.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadA<>.Error_); - public bool IsOk => !IsError; - public abstract String? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class MonadA : MonadA, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new MonadA Error(String message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static MonadA Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MonadA(T value) => MonadA.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MonadA(MonadAError myResultError) => myResultError.WithOk(); - - public static bool operator true(MonadA result) => result.IsOk; - public static bool operator false(MonadA result) => result.IsError; - - public static bool operator !(MonadA result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(MonadA other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadA)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadA)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((MonadA)obj); - } - - public static bool operator ==(MonadA? left, MonadA? right) => Equals(left, right); - - public static bool operator !=(MonadA? left, MonadA? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okMonadA => ok(okMonadA.Value), - Error_ errorMonadA => error(errorMonadA.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okMonadA => await ok(okMonadA.Value).ConfigureAwait(false), - Error_ errorMonadA => await error(errorMonadA.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okMonadA) await ok(okMonadA.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadA Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class MonadA + { + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadA Error(String details) => new MonadA.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadAError Error(String details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadA Ok(T value) => new MonadA.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadA<>.Error_); + public bool IsOk => !IsError; + public abstract String? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class MonadA : MonadA, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static MonadA Error(String message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static MonadA Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator MonadA(T value) => MonadA.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator MonadA(MonadAError myResultError) => myResultError.WithOk(); + + + public static bool operator true(MonadA result) => result.IsOk; + + public static bool operator false(MonadA result) => result.IsError; + + public static bool operator !(MonadA result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(MonadA other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadA)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadA)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((MonadA)obj); + } + + public static bool operator ==(MonadA? left, MonadA? right) => Equals(left, right); + + public static bool operator !=(MonadA? left, MonadA? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okMonadA => ok(okMonadA.Value), + Error_ errorMonadA => error(errorMonadA.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okMonadA => await ok(okMonadA.Value).ConfigureAwait(false), + Error_ errorMonadA => await error(errorMonadA.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okMonadA) await ok(okMonadA.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public MonadA Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadA Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return MonadA.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public MonadA Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return MonadA.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return MonadA.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return MonadA.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : MonadA - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : MonadA - { - public String Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(String details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadA.Error_ Convert() => new MonadA.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override String? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct MonadAError : global::System.IEquatable - { - readonly String _details; - - internal MonadAError(String details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public MonadA WithOk() => MonadA.Error(_details); - - public bool Equals(MonadAError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is MonadAError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(MonadAError left, MonadAError right) => left.Equals(right); - - public static bool operator !=(MonadAError left, MonadAError right) => !left.Equals(right); - } - - public static partial class MonadAExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => MonadA.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA MapError(this MonadA result, global::System.Func mapError) - { - if (result is MonadA.Error_ e) - return MonadA.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Flatten(this MonadA> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA As(this MonadA result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return MonadA.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA As(this MonadA result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA Select(this MonadA result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA SelectMany(this MonadA result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this MonadA result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : MonadA + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : MonadA + { + public String Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(String details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public MonadA.Error_ Convert() => new MonadA.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override String? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct MonadAError : global::System.IEquatable + { + readonly String _details; + + internal MonadAError(String details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public MonadA WithOk() => MonadA.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(MonadAError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is MonadAError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(MonadAError left, MonadAError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(MonadAError left, MonadAError right) => !left.Equals(right); + } + + public static partial class MonadAExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => MonadA.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA MapError(this MonadA result, global::System.Func mapError) + { + if (result is MonadA.Error_ e) + return MonadA.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static MonadA Flatten(this MonadA> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA As(this MonadA result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return MonadA.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA As(this MonadA result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA Select(this MonadA result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA SelectMany(this MonadA result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this MonadA result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class MonadAExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA As(this object? item, global::System.Func error) => - !(item is T t) ? MonadA.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA NotNull(this T? item, global::System.Func error) => - item ?? MonadA.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? MonadA.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadA NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? MonadA.Error(error()) : s!; - - public static MonadA First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class MonadAExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA As(this object? item, global::System.Func error) => + !(item is T t) ? MonadA.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA NotNull(this T? item, global::System.Func error) => + item ?? MonadA.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? MonadA.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadA NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? MonadA.Error(error()) : s!; + + + public static MonadA First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs index 56833a07..80a2fcde 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs @@ -7,535 +7,601 @@ namespace FunicularSwitch.Test { #pragma warning disable 1591 - public abstract partial class MonadB - { - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Error(Int32 details) => new MonadB.Error_(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadBError Error(Int32 details) => new(details); - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Ok(T value) => new MonadB.Ok_(value); - public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadB<>.Error_); - public bool IsOk => !IsError; - public abstract Int32? GetErrorOrDefault(); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Try(global::System.Func action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Try(global::System.Func> action, global::System.Func formatError) - { - try - { - return action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Try(global::System.Func>> action, global::System.Func formatError) - { - try - { - return await action(); - } - catch (global::System.Exception e) - { - return Error(formatError(e)); - } - } - } - - public abstract partial class MonadB : MonadB, global::System.Collections.Generic.IEnumerable - { - - [global::System.Diagnostics.DebuggerNonUserCode] - public static new MonadB Error(Int32 message) => Error(message); - - [global::System.Diagnostics.DebuggerNonUserCode] - public static MonadB Ok(T value) => Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MonadB(T value) => MonadB.Ok(value); - - [global::System.Diagnostics.DebuggerStepThrough] - public static implicit operator MonadB(MonadBError myResultError) => myResultError.WithOk(); - - public static bool operator true(MonadB result) => result.IsOk; - public static bool operator false(MonadB result) => result.IsError; - - public static bool operator !(MonadB result) => result.IsError; - - //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode - bool Equals(MonadB other) => this switch - { - Ok_ ok => ok.Equals((object)other), - Error_ error => error.Equals((object)other), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadB)}") - }; - - public override int GetHashCode() => this switch - { - Ok_ ok => ok.GetHashCode(), - Error_ error => error.GetHashCode(), - _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadB)}") - }; - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((MonadB)obj); - } - - public static bool operator ==(MonadB? left, MonadB? right) => Equals(left, right); - - public static bool operator !=(MonadB? left, MonadB? right) => !Equals(left, right); - - [global::System.Diagnostics.DebuggerStepThrough] - public void Match(global::System.Action ok, global::System.Action? error = null) => Match( - v => - { - ok.Invoke(v); - return 42; - }, - err => - { - error?.Invoke(err); - return 42; - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public T1 Match(global::System.Func ok, global::System.Func error) - { - return this switch - { - Ok_ okMonadB => ok(okMonadB.Value), - Error_ errorMonadB => error(errorMonadB.Details), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func> error) - { - return this switch - { - Ok_ okMonadB => await ok(okMonadB.Value).ConfigureAwait(false), - Error_ errorMonadB => await error(errorMonadB.Details).ConfigureAwait(false), - _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") - }; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public global::System.Threading.Tasks.Task Match(global::System.Func> ok, global::System.Func error) => - Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task Match(global::System.Func ok) - { - if (this is Ok_ okMonadB) await ok(okMonadB.Value).ConfigureAwait(false); - } - - [global::System.Diagnostics.DebuggerStepThrough] - public T Match(global::System.Func error) => Match(v => v, error); - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadB Bind(global::System.Func> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return bind(ok.Value); - } - // ReSharper disable once RedundantCatchClause + public abstract partial class MonadB + { + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadB Error(Int32 details) => new MonadB.Error_(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadBError Error(Int32 details) => new(details); + [global::System.Diagnostics.DebuggerStepThrough] + public static MonadB Ok(T value) => new MonadB.Ok_(value); + public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadB<>.Error_); + public bool IsOk => !IsError; + public abstract Int32? GetErrorOrDefault(); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB Try( global::System.Func action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB Try( global::System.Func> action, global::System.Func formatError) + { + try + { + return action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Try( global::System.Func>> action, global::System.Func formatError) + { + try + { + return await action(); + } + catch (global::System.Exception e) + { + return Error(formatError(e)); + } + } + } + + public abstract partial class MonadB : MonadB, global::System.Collections.Generic.IEnumerable + { + + [global::System.Diagnostics.DebuggerNonUserCode] + + public new static MonadB Error(Int32 message) => Error(message); + + [global::System.Diagnostics.DebuggerNonUserCode] + + public static MonadB Ok(T value) => Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator MonadB(T value) => MonadB.Ok(value); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static implicit operator MonadB(MonadBError myResultError) => myResultError.WithOk(); + + + public static bool operator true(MonadB result) => result.IsOk; + + public static bool operator false(MonadB result) => result.IsError; + + public static bool operator !(MonadB result) => result.IsError; + + //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode + bool Equals(MonadB other) => this switch + { + Ok_ ok => ok.Equals((object)other), + Error_ error => error.Equals((object)other), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadB)}") + }; + + public override int GetHashCode() => this switch + { + Ok_ ok => ok.GetHashCode(), + Error_ error => error.GetHashCode(), + _ => throw new global::System.InvalidOperationException($"Unexpected type derived from {nameof(MonadB)}") + }; + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((MonadB)obj); + } + + public static bool operator ==(MonadB? left, MonadB? right) => Equals(left, right); + + public static bool operator !=(MonadB? left, MonadB? right) => !Equals(left, right); + + [global::System.Diagnostics.DebuggerStepThrough] + public void Match( global::System.Action ok, global::System.Action? error = null) => Match( + v => + { + ok.Invoke(v); + return 42; + }, + err => + { + error?.Invoke(err); + return 42; + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T1 Match( global::System.Func ok, global::System.Func error) + { + return this switch + { + Ok_ okMonadB => ok(okMonadB.Value), + Error_ errorMonadB => error(errorMonadB.Details), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func> error) + { + return this switch + { + Ok_ okMonadB => await ok(okMonadB.Value).ConfigureAwait(false), + Error_ errorMonadB => await error(errorMonadB.Details).ConfigureAwait(false), + _ => throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}") + }; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public global::System.Threading.Tasks.Task Match( global::System.Func> ok, global::System.Func error) => + Match(ok, e => global::System.Threading.Tasks.Task.FromResult(error(e))); + + [global::System.Diagnostics.DebuggerStepThrough] + public async global::System.Threading.Tasks.Task Match( global::System.Func ok) + { + if (this is Ok_ okMonadB) await ok(okMonadB.Value).ConfigureAwait(false); + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public T Match( global::System.Func error) => Match(v => v, error); + + [global::System.Diagnostics.DebuggerStepThrough] + + public MonadB Bind( global::System.Func> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return bind(ok.Value); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Bind(global::System.Func>> bind) - { - switch (this) - { - case Ok_ ok: - try - { - return await bind(ok.Value).ConfigureAwait(false); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Bind( global::System.Func>> bind) + { + switch (this) + { + case Ok_ ok: + try + { + return await bind(ok.Value).ConfigureAwait(false); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadB Map(global::System.Func map) - { - switch (this) - { - case Ok_ ok: - try - { - return MonadB.Ok(map(ok.Value)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public MonadB Map( global::System.Func map) + { + switch (this) + { + case Ok_ ok: + try + { + return MonadB.Ok(map(ok.Value)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - [global::System.Diagnostics.DebuggerStepThrough] - public async global::System.Threading.Tasks.Task> Map( - global::System.Func> map) - { - switch (this) - { - case Ok_ ok: - try - { - return MonadB.Ok(await map(ok.Value).ConfigureAwait(false)); - } - // ReSharper disable once RedundantCatchClause + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public async global::System.Threading.Tasks.Task> Map( + global::System.Func> map) + { + switch (this) + { + case Ok_ ok: + try + { + return MonadB.Ok(await map(ok.Value).ConfigureAwait(false)); + } + // ReSharper disable once RedundantCatchClause #pragma warning disable CS0168 // Variable is declared but never used - catch (global::System.Exception e) + catch (global::System.Exception e) #pragma warning restore CS0168 // Variable is declared but never used - { - throw; //createGenericErrorResult - } - case Error_ error: - return error.Convert(); - default: - throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); - } - } - - //createGenericResultConversions - - [global::System.Diagnostics.DebuggerStepThrough] - public T? GetValueOrDefault() - => Match( - v => (T?)v, - _ => default - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(global::System.Func defaultValue) - => Match( - v => v, - _ => defaultValue() - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrDefault(T defaultValue) - => Match( - v => v, - _ => defaultValue - ); - - [global::System.Diagnostics.DebuggerStepThrough] - public T GetValueOrThrow() - => Match( - v => v, - details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); - - public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); - - public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); - global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); - - public sealed partial class Ok_ : MonadB - { - public T Value { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Ok_(T value) => Value = value; - - [global::System.Diagnostics.DebuggerStepThrough] - public override Int32? GetErrorOrDefault() => null; - - public bool Equals(Ok_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Ok_ other && Equals(other); - } - - public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); - - public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); - - public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); - } - - public sealed partial class Error_ : MonadB - { - public Int32 Details { get; } - - [global::System.Diagnostics.DebuggerStepThrough] - public Error_(Int32 details) => Details = details; - - [global::System.Diagnostics.DebuggerStepThrough] - public MonadB.Error_ Convert() => new MonadB.Error_(Details); - - [global::System.Diagnostics.DebuggerStepThrough] - public override Int32? GetErrorOrDefault() => Details; - - public bool Equals(Error_? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - return Equals(Details, other.Details); - } - - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is Error_ other && Equals(other); - } - - public override int GetHashCode() => Details.GetHashCode(); - - public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); - - public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); - } - } - - public readonly partial struct MonadBError : global::System.IEquatable - { - readonly Int32 _details; - - internal MonadBError(Int32 details) => _details = details; - - [global::System.Diagnostics.Contracts.Pure] - public MonadB WithOk() => MonadB.Error(_details); - - public bool Equals(MonadBError other) => _details.Equals(other._details); - - public override bool Equals(object? obj) => obj is MonadBError other && Equals(other); - - public override int GetHashCode() => _details.GetHashCode(); - - public static bool operator ==(MonadBError left, MonadBError right) => left.Equals(right); - - public static bool operator !=(MonadBError left, MonadBError right) => !left.Equals(right); - } - - public static partial class MonadBExtension - { - #region bind - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => (await result.ConfigureAwait(false)).Bind(bind); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Bind( - this global::System.Threading.Tasks.Task> result, - global::System.Func>> bind) - => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); - - #endregion - - #region map - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func map) - => (await result.ConfigureAwait(false)).Map(map); - - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Map( - this global::System.Threading.Tasks.Task> result, - global::System.Func> bind) - => Bind(result, async v => MonadB.Ok(await bind(v).ConfigureAwait(false))); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB MapError(this MonadB result, global::System.Func mapError) - { - if (result is MonadB.Error_ e) - return MonadB.Error(mapError(e.Details)); - return result; - } - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); - - #endregion - - #region match - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func> error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func> ok, - global::System.Func error) - => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); - - [global::System.Diagnostics.DebuggerStepThrough] - public static async global::System.Threading.Tasks.Task Match( - this global::System.Threading.Tasks.Task> result, - global::System.Func ok, - global::System.Func error) - => (await result.ConfigureAwait(false)).Match(ok, error); - - #endregion - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Flatten(this MonadB> result) => result.Bind(r => r); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB As(this MonadB result, global::System.Func errorTIsNotT1) => - result.Bind(r => - { - if (r is T1 converted) - return converted; - return MonadB.Error(errorTIsNotT1()); - }); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB As(this MonadB result, global::System.Func errorIsNotT1) => - result.As(errorIsNotT1); - - #region query-expression pattern - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB Select(this MonadB result, global::System.Func selector) => result.Map(selector); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB SelectMany(this MonadB result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - [global::System.Diagnostics.DebuggerStepThrough] - public static global::System.Threading.Tasks.Task> SelectMany(this MonadB result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); - - #endregion - - //createGenericResultConversionExtensions - } + { + throw; //createGenericErrorResult + } + case Error_ error: + return error.Convert(); + default: + throw new global::System.InvalidOperationException($"Unexpected derived result type: {GetType()}"); + } + } + + //createGenericResultConversions + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T? GetValueOrDefault() + => Match( + v => (T?)v, + _ => default + ); + + [global::System.Diagnostics.DebuggerStepThrough] + + public T GetValueOrDefault( global::System.Func defaultValue) + => Match( + v => v, + _ => defaultValue() + ); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public T GetValueOrDefault(T defaultValue) + => Match( + v => v, + _ => defaultValue + ); + + [global::System.Diagnostics.DebuggerStepThrough] + public T GetValueOrThrow() + => Match( + v => v, + details => throw new global::System.InvalidOperationException($"Cannot access error result value. Error: {details}")); + + + public global::System.Collections.Generic.IEnumerator GetEnumerator() => Match(ok => new[] { ok }, _ => Enumerable.Empty()).GetEnumerator(); + + + public override string ToString() => Match(ok => $"Ok {ok?.ToString()}", error => $"Error {error}"); + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); + + public sealed partial class Ok_ : MonadB + { + public T Value { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Ok_(T value) => Value = value; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Int32? GetErrorOrDefault() => null; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Ok_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return global::System.Collections.Generic.EqualityComparer.Default.Equals(Value, other.Value); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Ok_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Value == null ? 0 : global::System.Collections.Generic.EqualityComparer.Default.GetHashCode(Value); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Ok_ left, Ok_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Ok_ left, Ok_ right) => !Equals(left, right); + } + + public sealed partial class Error_ : MonadB + { + public Int32 Details { get; } + + [global::System.Diagnostics.DebuggerStepThrough] + public Error_(Int32 details) => Details = details; + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public MonadB.Error_ Convert() => new MonadB.Error_(Details); + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public override Int32? GetErrorOrDefault() => Details; + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(Error_? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return Equals(Details, other.Details); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj is Error_ other && Equals(other); + } + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => Details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(Error_ left, Error_ right) => Equals(left, right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(Error_ left, Error_ right) => !Equals(left, right); + } + } + + public readonly partial struct MonadBError : global::System.IEquatable + { + readonly Int32 _details; + + internal MonadBError(Int32 details) => _details = details; + + [global::System.Diagnostics.Contracts.Pure] + public MonadB WithOk() => MonadB.Error(_details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public bool Equals(MonadBError other) => _details.Equals(other._details); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override bool Equals(object? obj) => obj is MonadBError other && Equals(other); + + [global::System.Diagnostics.Contracts.PureAttribute] + public override int GetHashCode() => _details.GetHashCode(); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator ==(MonadBError left, MonadBError right) => left.Equals(right); + + [global::System.Diagnostics.Contracts.PureAttribute] + public static bool operator !=(MonadBError left, MonadBError right) => !left.Equals(right); + } + + public static partial class MonadBExtension + { + #region bind + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => (await result.ConfigureAwait(false)).Bind(bind); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Bind( + this global::System.Threading.Tasks.Task> result, + global::System.Func>> bind) + => await (await result.ConfigureAwait(false)).Bind(bind).ConfigureAwait(false); + + #endregion + + #region map + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func map) + => (await result.ConfigureAwait(false)).Map(map); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Map( + this global::System.Threading.Tasks.Task> result, + global::System.Func> bind) + => Bind(result, async v => MonadB.Ok(await bind(v).ConfigureAwait(false))); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB MapError(this MonadB result, global::System.Func mapError) + { + if (result is MonadB.Error_ e) + return MonadB.Error(mapError(e.Details)); + return result; + } + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task> MapError(this global::System.Threading.Tasks.Task> result, global::System.Func mapError) => (await result.ConfigureAwait(false)).MapError(mapError); + + #endregion + + #region match + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func> error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func> ok, + global::System.Func error) + => await (await result.ConfigureAwait(false)).Match(ok, error).ConfigureAwait(false); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static async global::System.Threading.Tasks.Task Match( + this global::System.Threading.Tasks.Task> result, + global::System.Func ok, + global::System.Func error) + => (await result.ConfigureAwait(false)).Match(ok, error); + + #endregion + + [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] + public static MonadB Flatten(this MonadB> result) => result.Bind(r => r); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB As(this MonadB result, global::System.Func errorTIsNotT1) => + result.Bind(r => + { + if (r is T1 converted) + return converted; + return MonadB.Error(errorTIsNotT1()); + }); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB As(this MonadB result, global::System.Func errorIsNotT1) => + result.As(errorIsNotT1); + + #region query-expression pattern + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB Select(this MonadB result, global::System.Func selector) => result.Map(selector); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> result, global::System.Func selector) => result.Map(selector); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB SelectMany(this MonadB result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> result, global::System.Func> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + [global::System.Diagnostics.DebuggerStepThrough] + + public static global::System.Threading.Tasks.Task> SelectMany(this MonadB result, global::System.Func>> selector, global::System.Func resultSelector) => result.Bind(t => selector(t).Map(t1 => resultSelector(t, t1))); + + #endregion + + //createGenericResultConversionExtensions + } } namespace FunicularSwitch.Test.Extensions { - public static partial class MonadBExtension - { - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable items, - global::System.Func> choose, - global::System.Action onError) - => items - .Select(i => choose(i)) - .Choose(onError); - - public static global::System.Collections.Generic.IEnumerable Choose( - this global::System.Collections.Generic.IEnumerable> results, - global::System.Action onError) - => results - .Where(r => - r.Match(_ => true, error => - { - onError(error); - return false; - })) - .Select(r => r.GetValueOrThrow()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB As(this object? item, global::System.Func error) => - !(item is T t) ? MonadB.Error(error()) : t; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB NotNull(this T? item, global::System.Func error) => - item ?? MonadB.Error(error()); - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB NotNullOrEmpty(this string? s, global::System.Func error) - => string.IsNullOrEmpty(s) ? MonadB.Error(error()) : s!; - - [global::System.Diagnostics.DebuggerStepThrough] - public static MonadB NotNullOrWhiteSpace(this string? s, global::System.Func error) - => string.IsNullOrWhiteSpace(s) ? MonadB.Error(error()) : s!; - - public static MonadB First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => - candidates - .FirstOrDefault(i => predicate(i)) - .NotNull(noMatch); - } + public static partial class MonadBExtension + { + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable items, + global::System.Func> choose, + global::System.Action onError) + => items + .Select(i => choose(i)) + .Choose(onError); + + + public static global::System.Collections.Generic.IEnumerable Choose( + this global::System.Collections.Generic.IEnumerable> results, + global::System.Action onError) + => results + .Where(r => + r.Match(_ => true, error => + { + onError(error); + return false; + })) + .Select(r => r.GetValueOrThrow()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB As(this object? item, global::System.Func error) => + !(item is T t) ? MonadB.Error(error()) : t; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB NotNull(this T? item, global::System.Func error) => + item ?? MonadB.Error(error()); + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB NotNullOrEmpty(this string? s, global::System.Func error) + => string.IsNullOrEmpty(s) ? MonadB.Error(error()) : s!; + + [global::System.Diagnostics.DebuggerStepThrough] + + public static MonadB NotNullOrWhiteSpace(this string? s, global::System.Func error) + => string.IsNullOrWhiteSpace(s) ? MonadB.Error(error()) : s!; + + + public static MonadB First(this global::System.Collections.Generic.IEnumerable candidates, global::System.Func predicate, global::System.Func noMatch) => + candidates + .FirstOrDefault(i => predicate(i)) + .NotNull(noMatch); + } #pragma warning restore 1591 } From af31f84b582d48ac94ae8683642b9f221fde22c1 Mon Sep 17 00:00:00 2001 From: Alexander Wiedemann Date: Tue, 9 Dec 2025 20:09:13 +0100 Subject: [PATCH 2/5] - version of FunicularSwtich.Generator to 4.6.0 --- .../FunicularSwitch.Generators.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/FunicularSwitch.Generators/FunicularSwitch.Generators.csproj b/Source/FunicularSwitch.Generators/FunicularSwitch.Generators.csproj index 5097657b..bf8e2a09 100644 --- a/Source/FunicularSwitch.Generators/FunicularSwitch.Generators.csproj +++ b/Source/FunicularSwitch.Generators/FunicularSwitch.Generators.csproj @@ -17,7 +17,7 @@ 4 - 5.2 + 6.0 From 12982e2e3840cd7d817570806f72eec14d4c7c68 Mon Sep 17 00:00:00 2001 From: Alexander Wiedemann Date: Wed, 10 Dec 2025 22:35:25 +0100 Subject: [PATCH 3/5] - mustusereturnvalue instead of pure for some operators --- .../ResultType.cs | 14 +++++++++----- .../FunicularSwitch.Result.g.cs | 14 +++++++++----- .../StandardMinLangVersion.Result.g.cs | 14 +++++++++----- ...Switch.Generators.Consumer.OperationResult.g.cs | 14 +++++++++----- ...FunicularSwitch.Generators.Consumer.Result.g.cs | 14 +++++++++----- ...arSwitch.Generators.Consumer.System.Result.g.cs | 14 +++++++++----- .../MyNamespace.Result.g.cs | 14 +++++++++----- ...icularSwitch.Test.OperationResult.g.verified.cs | 14 +++++++++----- ..._type#FunicularSwitch.Test.Result.g.verified.cs | 14 +++++++++----- ...icularSwitch.Test.OperationResult.g.verified.cs | 14 +++++++++----- ...icularSwitch.Test.OperationResult.g.verified.cs | 14 +++++++++----- ...icularSwitch.Test.OperationResult.g.verified.cs | 14 +++++++++----- ...icularSwitch.Test.OperationResult.g.verified.cs | 14 +++++++++----- ...tType#FunicularSwitch.Test.MonadA.g.verified.cs | 14 +++++++++----- ...tType#FunicularSwitch.Test.MonadB.g.verified.cs | 14 +++++++++----- 15 files changed, 135 insertions(+), 75 deletions(-) diff --git a/Source/FunicularSwitch.Generators.Templates/ResultType.cs b/Source/FunicularSwitch.Generators.Templates/ResultType.cs index 9c5923f8..c8920575 100644 --- a/Source/FunicularSwitch.Generators.Templates/ResultType.cs +++ b/Source/FunicularSwitch.Generators.Templates/ResultType.cs @@ -9,13 +9,17 @@ namespace FunicularSwitch.Generators.Templates public abstract partial class MyResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MyResult Error(MyError details) => new MyResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MyResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MyResult Ok(T value) => new MyResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MyResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -94,11 +98,11 @@ public abstract partial class MyResult : MyResult, global::System.Collections [global::JetBrains.Annotations.MustUseReturnValue] public static implicit operator MyResult(MyResultError myResultError) => myResultError.WithOk(); - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(MyResult result) => result.IsOk; - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(MyResult result) => result.IsError; - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(MyResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -123,9 +127,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((MyResult)obj); } - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(MyResult? left, MyResult? right) => Equals(left, right); - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(MyResult? left, MyResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs index db67e134..4d8102bb 100644 --- a/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs +++ b/Source/FunicularSwitch/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Result.g.cs @@ -9,13 +9,17 @@ namespace FunicularSwitch public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(String details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(String details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract String? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -94,11 +98,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -123,9 +127,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs index b8f08246..35b06547 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer.StandardMinLangVersion/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/StandardMinLangVersion.Result.g.cs @@ -9,13 +9,17 @@ namespace StandardMinLangVersion public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(String details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(String details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract String? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -94,11 +98,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -123,9 +127,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs index 592fe83e..dffaeb07 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.OperationResult.g.cs @@ -9,13 +9,17 @@ namespace FunicularSwitch.Generators.Consumer abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(Error details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(Error details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract Error? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -94,11 +98,11 @@ abstract partial class OperationResult : OperationResult, global::System.Coll public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -123,9 +127,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs index 9a23784f..0f1b9708 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.Result.g.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Generators.Consumer public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(String details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(String details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract String? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs index a9176c9f..329f1842 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/FunicularSwitch.Generators.Consumer.System.Result.g.cs @@ -9,13 +9,17 @@ namespace FunicularSwitch.Generators.Consumer.System public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(Action details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(Action details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract Action? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -94,11 +98,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -123,9 +127,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs index 534afadb..b9507b30 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ResultTypeGenerator/MyNamespace.Result.g.cs @@ -10,13 +10,17 @@ namespace MyNamespace public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(ErrorInNamespaceWithDifferentResult details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(ErrorInNamespaceWithDifferentResult details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract ErrorInNamespaceWithDifferentResult? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs index a4999289..9464bee2 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(MyError details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class OperationResult : OperationResult, global::Syst public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs index 0d06caa4..b39cf5f4 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_enum_error_type#FunicularSwitch.Test.Result.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class Result { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Error(String details) => new Result.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static ResultError Error(String details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static Result Ok(T value) => new Result.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(Result<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract String? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class Result : Result, global::System.Collections.Gen public static implicit operator Result(ResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(Result result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(Result result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(Result result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((Result)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(Result? left, Result? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(Result? left, Result? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs index 75158a23..424c61ca 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_in_different_namespace#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(MyError details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class OperationResult : OperationResult, global::Syst public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs index e38ab24a..892ce468 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_when_jetbrains_annotations_is_referenced#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(MyError details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class OperationResult : OperationResult, global::Syst [global::JetBrains.Annotations.MustUseReturnValue] public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - [global::JetBrains.Annotations.MustUseReturnValue] + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs index 4c92c818..6feb6de6 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_error_type_with_merge#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(MyError details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class OperationResult : OperationResult, global::Syst public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs index 64915e1d..a7c15725 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/Run_result_type_generator.For_internal_result_type#FunicularSwitch.Test.OperationResult.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test abstract partial class OperationResult { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Error(MyError details) => new OperationResult.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResultError Error(MyError details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static OperationResult Ok(T value) => new OperationResult.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(OperationResult<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract MyError? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ abstract partial class OperationResult : OperationResult, global::System.Coll public static implicit operator OperationResult(OperationResultError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(OperationResult result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(OperationResult result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(OperationResult result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((OperationResult)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(OperationResult? left, OperationResult? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(OperationResult? left, OperationResult? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs index 15442900..d15a2d57 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadA.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class MonadA { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadA Error(String details) => new MonadA.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadAError Error(String details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadA Ok(T value) => new MonadA.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadA<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract String? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class MonadA : MonadA, global::System.Collections.Gen public static implicit operator MonadA(MonadAError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(MonadA result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(MonadA result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(MonadA result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((MonadA)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(MonadA? left, MonadA? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(MonadA? left, MonadA? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs index 80a2fcde..910ac438 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadB.g.verified.cs @@ -10,13 +10,17 @@ namespace FunicularSwitch.Test public abstract partial class MonadB { [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadB Error(Int32 details) => new MonadB.Error_(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadBError Error(Int32 details) => new(details); [global::System.Diagnostics.DebuggerStepThrough] + [global::System.Diagnostics.Contracts.PureAttribute] public static MonadB Ok(T value) => new MonadB.Ok_(value); public bool IsError => GetType().GetGenericTypeDefinition() == typeof(MonadB<>.Error_); public bool IsOk => !IsError; + [global::System.Diagnostics.Contracts.PureAttribute] public abstract Int32? GetErrorOrDefault(); [global::System.Diagnostics.DebuggerStepThrough] @@ -95,11 +99,11 @@ public abstract partial class MonadB : MonadB, global::System.Collections.Gen public static implicit operator MonadB(MonadBError myResultError) => myResultError.WithOk(); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator true(MonadB result) => result.IsOk; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator false(MonadB result) => result.IsError; - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !(MonadB result) => result.IsError; //just here to suppress warning, never called because all subtypes (Ok_, Error_) implement Equals and GetHashCode @@ -124,9 +128,9 @@ public override bool Equals(object? obj) if (obj.GetType() != this.GetType()) return false; return Equals((MonadB)obj); } - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator ==(MonadB? left, MonadB? right) => Equals(left, right); - + [global::System.Diagnostics.Contracts.PureAttribute] public static bool operator !=(MonadB? left, MonadB? right) => !Equals(left, right); [global::System.Diagnostics.DebuggerStepThrough] From 13143aa1866594fb074f8140c086adfb9b757b94 Mon Sep 17 00:00:00 2001 From: Alexander Wiedemann Date: Wed, 10 Dec 2025 23:29:32 +0100 Subject: [PATCH 4/5] - stabilize unit test --- .../TransformerSpecs.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs index 33e8ef2b..126fcfa2 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/TransformerSpecs.cs @@ -103,16 +103,8 @@ public void ResultOption_Return() } [TestMethod] - [DataRow(1, 1, "Ok 0", """ - 1/1 = 1 - 1-1 = 0 - sqrt(0) = 0 - """)] - [DataRow(2, 2, "Error sqrt(-1) -> Cannot get square root of negative number", """ - 2/2 = 1 - 1-2 = -1 - sqrt(-1) -> Cannot get square root of negative number - """)] + [DataRow(1, 1, "Ok 0", "1/1 = 1\n1-1 = 0\nsqrt(0) = 0")] + [DataRow(2, 2, "Error sqrt(-1) -> Cannot get square root of negative number", "2/2 = 1\n1-2 = -1\nsqrt(-1) -> Cannot get square root of negative number")] [DataRow(2, 0, "Error 2/0 -> Cannot divide by 0", "2/0 -> Cannot divide by 0")] public void WriterResult_UseCase(int a, int b, string expectedResult, string expectedLog) { From 654e6501d57448189313d9ebf245e8b9c0313837 Mon Sep 17 00:00:00 2001 From: Alexander Wiedemann Date: Thu, 11 Dec 2025 11:24:53 +0100 Subject: [PATCH 5/5] - attribute constants --- .../FunicularSwitch.Generators/Attributes.cs | 2 + .../EnumType/Generator.cs | 11 +- .../Generation/Constants.cs | 15 +- .../Generation/GeneralGenerator.cs | 7 +- .../Generation/Indent.cs | 4 - .../Generation/MonadMethods.cs | 8 +- .../ResultType/Generator.cs | 12 +- .../Transformer/Parser.cs | 2 +- .../UnionType/Generator.cs | 16 +- ...ularSwitch.Generators.Consumer.Writer.g.cs | 76 ++++--- ...itch.Generators.Consumer.OptionResult.g.cs | 174 ++++++++++------ ....Generators.Consumer.ResultEnumerable.g.cs | 174 ++++++++++------ ...itch.Generators.Consumer.ResultOption.g.cs | 174 ++++++++++------ ...itch.Generators.Consumer.WriterResult.g.cs | 114 +++++++---- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...#FunicularSwitch.Test.MonadA.g.verified.cs | 76 ++++--- ...FunicularSwitch.Test.MonadAB.g.verified.cs | 174 ++++++++++------ ...FunicularSwitch.Test.MonadAB.g.verified.cs | 174 ++++++++++------ ...FunicularSwitch.Test.MonadAB.g.verified.cs | 174 ++++++++++------ ...FunicularSwitch.Test.MonadAB.g.verified.cs | 174 ++++++++++------ ...unicularSwitch.Test.MonadABA.g.verified.cs | 191 +++++++++++------- ...FunicularSwitch.Test.MonadAB.g.verified.cs | 114 +++++++---- ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...ularSwitch.Test.MonadAMonadB.g.verified.cs | 174 ++++++++++------ ...FunicularSwitch.Test.MonadAB.g.verified.cs | 159 +++++++++------ ...FunicularSwitch.Test.MonadAB.g.verified.cs | 174 ++++++++++------ ...unicularSwitch.Test.MonadABC.g.verified.cs | 159 +++++++++------ 42 files changed, 2694 insertions(+), 1718 deletions(-) create mode 100644 Source/FunicularSwitch.Generators/Attributes.cs diff --git a/Source/FunicularSwitch.Generators/Attributes.cs b/Source/FunicularSwitch.Generators/Attributes.cs new file mode 100644 index 00000000..0e1cb006 --- /dev/null +++ b/Source/FunicularSwitch.Generators/Attributes.cs @@ -0,0 +1,2 @@ +namespace FunicularSwitch.Generators; + diff --git a/Source/FunicularSwitch.Generators/EnumType/Generator.cs b/Source/FunicularSwitch.Generators/EnumType/Generator.cs index 4512f875..cc147e36 100644 --- a/Source/FunicularSwitch.Generators/EnumType/Generator.cs +++ b/Source/FunicularSwitch.Generators/EnumType/Generator.cs @@ -9,9 +9,6 @@ static class Generator { private const string VoidMatchMethodName = "Switch"; private const string MatchMethodName = "Match"; - private const string InstantHandleAttribute = "[global::JetBrains.Annotations.InstantHandle]"; - private const string InstantHandleRequireAwaitAttribute = "[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]"; - private const string DebuggerStepThroughAttribute = "global::System.Diagnostics.DebuggerStepThrough"; public static (string filename, string source) Emit( EnumTypeSchema enumTypeSchema, @@ -134,7 +131,7 @@ static void WriteMatchSignature( string? handlerReturnType = null) { var instantHandle = hasJetBrainsAnnotationsReference ? - isAsync ? InstantHandleRequireAwaitAttribute : InstantHandleAttribute + isAsync ? Constants.Attributes.InstantHandleRequireAwait : Constants.Attributes.InstantHandle : ""; var modifiers = "public static"; if (isAsync) @@ -146,7 +143,7 @@ static void WriteMatchSignature( var handlerParameters = enumTypeSchema.Cases .Select(c => new Parameter($"{instantHandle}global::System.Func<{handlerReturnType}>", c.ParameterName)); - builder.WriteAttribute(DebuggerStepThroughAttribute); + builder.WriteLine(Constants.Attributes.DebuggerStepThrough); builder.WriteMethodSignature( modifiers: modifiers, returnType: returnType, @@ -165,13 +162,13 @@ static void WriteSwitchSignature( bool lambda = false) { var instantHandle = hasJetBrainsAnnotationsReference ? - isAsync ? InstantHandleRequireAwaitAttribute : InstantHandleAttribute + isAsync ? Constants.Attributes.InstantHandleRequireAwait : Constants.Attributes.InstantHandle : ""; var returnType = asyncReturn ?? isAsync ? "async global::System.Threading.Tasks.Task" : "void"; var handlerParameters = enumTypeSchema.Cases .Select(c => new Parameter(isAsync ? $"{instantHandle}global::System.Func" : $"{instantHandle}global::System.Action", c.ParameterName)); - builder.WriteAttribute(DebuggerStepThroughAttribute); + builder.WriteLine(Constants.Attributes.DebuggerStepThrough); builder.WriteMethodSignature( modifiers: "public static", returnType: returnType, diff --git a/Source/FunicularSwitch.Generators/Generation/Constants.cs b/Source/FunicularSwitch.Generators/Generation/Constants.cs index a059fc3a..c3958762 100644 --- a/Source/FunicularSwitch.Generators/Generation/Constants.cs +++ b/Source/FunicularSwitch.Generators/Generation/Constants.cs @@ -2,12 +2,19 @@ namespace FunicularSwitch.Generators.Generation; internal static class Constants { - public const string DebuggerStepThroughAttribute = "global::System.Diagnostics.DebuggerStepThroughAttribute"; - - public const string ExperimentalGeneratorDocs = """ + public const string ExperimentalGeneratorDocs = """ This generator is still considered experimental and might break. Please open any issues you may find in the GitHub repo. - """; + """; + + public static class Attributes + { + public const string InstantHandle = "[global::JetBrains.Annotations.InstantHandle]"; + public const string InstantHandleRequireAwait = "[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]"; + public const string MustUseReturnValue = "[global::JetBrains.Annotations.MustUseReturnValue]"; + public const string DebuggerStepThrough = "[global::System.Diagnostics.DebuggerStepThrough]"; + public const string Pure = "[global::System.Diagnostics.Contracts.PureAttribute]"; + } } diff --git a/Source/FunicularSwitch.Generators/Generation/GeneralGenerator.cs b/Source/FunicularSwitch.Generators/Generation/GeneralGenerator.cs index 3a7ab984..94a10953 100644 --- a/Source/FunicularSwitch.Generators/Generation/GeneralGenerator.cs +++ b/Source/FunicularSwitch.Generators/Generation/GeneralGenerator.cs @@ -6,8 +6,11 @@ internal static class GeneralGenerator { public static void BlankLine(CSharpBuilder cs) => cs.Content.AppendLine(); - public static void WriteCommonMethodAttributes(CSharpBuilder cs) => - cs.WriteLine($"[global::System.Diagnostics.Contracts.PureAttribute, {Constants.DebuggerStepThroughAttribute}]"); + public static void WriteCommonMethodAttributes(CSharpBuilder cs) + { + cs.WriteLine(Constants.Attributes.Pure); + cs.WriteLine(Constants.Attributes.DebuggerStepThrough); + } public static void WriteStaticMonad(StaticMonadGenerationInfo data, CSharpBuilder cs, CancellationToken cancellationToken) { diff --git a/Source/FunicularSwitch.Generators/Generation/Indent.cs b/Source/FunicularSwitch.Generators/Generation/Indent.cs index f4bec84f..90d354b9 100644 --- a/Source/FunicularSwitch.Generators/Generation/Indent.cs +++ b/Source/FunicularSwitch.Generators/Generation/Indent.cs @@ -181,10 +181,6 @@ public static void WriteUsings(this CSharpBuilder tt, params string[] usings) } tt.NewLine(); } - public static void WriteAttribute(this CSharpBuilder tt, string attributeName) - { - tt.WriteLine("[{0}]", attributeName); - } public static void WriteAutoProperty(this CSharpBuilder tt, string returnType, string propertyName) { diff --git a/Source/FunicularSwitch.Generators/Generation/MonadMethods.cs b/Source/FunicularSwitch.Generators/Generation/MonadMethods.cs index 4a8993fe..d1ac4b1a 100644 --- a/Source/FunicularSwitch.Generators/Generation/MonadMethods.cs +++ b/Source/FunicularSwitch.Generators/Generation/MonadMethods.cs @@ -117,7 +117,7 @@ IEnumerable ForFnType(Func, TypeIn new ParameterGenerationInfo(Types.Func("A", fnReturnType(t)), "fn"), ], name, - t => $"{chainedMonad.BindMethod.Invoke([..t, "A", "B"], [$"(({chainedMonad.GenericTypeName([..t, "A"])}){p})", $"[{Constants.DebuggerStepThroughAttribute}](a) => fn(a)"])}" + t => $"{chainedMonad.BindMethod.Invoke([..t, "A", "B"], [$"(({chainedMonad.GenericTypeName([..t, "A"])}){p})", $"{Constants.Attributes.DebuggerStepThrough}(a) => fn(a)"])}" )); } @@ -142,7 +142,7 @@ IEnumerable ForFnType(Func, TypeIn new ParameterGenerationInfo(Types.Func("A", "B", "C"), "selector"), ], name, - t => $"{p}.SelectMany([{Constants.DebuggerStepThroughAttribute}](a) => (({genericTypeName([..t, "B"])})fn(a)).Map([{Constants.DebuggerStepThroughAttribute}](b) => selector(a, b)))" + t => $"{p}.SelectMany({Constants.Attributes.DebuggerStepThrough}(a) => (({genericTypeName([..t, "B"])})fn(a)).Map({Constants.Attributes.DebuggerStepThrough}(b) => selector(a, b)))" )); } @@ -152,7 +152,7 @@ private static IEnumerable Lift(ConstructType genericTypeN ["A"], [new ParameterGenerationInfo(outerMonad.GenericTypeName(["A"]), "ma")], "Lift", - $"{outerMonad.BindMethod.Invoke(["A", $"{innerMonad.GenericTypeName(["A"])}"], [p, $"[{Constants.DebuggerStepThroughAttribute}](a) => {chainedMonad.ReturnMethod.Invoke(["A"], ["a"])}"])}" + $"{outerMonad.BindMethod.Invoke(["A", $"{innerMonad.GenericTypeName(["A"])}"], [p, $"{Constants.Attributes.DebuggerStepThrough}(a) => {chainedMonad.ReturnMethod.Invoke(["A"], ["a"])}"])}" )); private static IEnumerable Map(string name, ConstructType genericTypeName, MonadInfo monad) => @@ -167,7 +167,7 @@ private static IEnumerable Map(string name, ConstructType new ParameterGenerationInfo(Types.Func("A", "B"), "fn"), ], name, - t => $"{p}.{monad.BindMethod.Name}([{Constants.DebuggerStepThroughAttribute}](a) => {monad.ReturnMethod.Invoke([..t, "B"], ["fn(a)"])})" + t => $"{p}.{monad.BindMethod.Name}({Constants.Attributes.DebuggerStepThrough}(a) => {monad.ReturnMethod.Invoke([..t, "B"], ["fn(a)"])})" )); private static IEnumerable Return(ConstructType genericTypeName, MonadInfo chainedMonad) => diff --git a/Source/FunicularSwitch.Generators/ResultType/Generator.cs b/Source/FunicularSwitch.Generators/ResultType/Generator.cs index 1b228872..28af345c 100644 --- a/Source/FunicularSwitch.Generators/ResultType/Generator.cs +++ b/Source/FunicularSwitch.Generators/ResultType/Generator.cs @@ -1,5 +1,6 @@ using System.Collections.Immutable; using FunicularSwitch.Generators.Common; +using FunicularSwitch.Generators.Generation; using Microsoft.CodeAnalysis; namespace FunicularSwitch.Generators.ResultType; @@ -9,7 +10,6 @@ static class Generator const string TemplateNamespace = "FunicularSwitch.Generators.Templates"; const string TemplateResultTypeName = "MyResult"; const string TemplateErrorTypeName = "MyError"; - const string MustUseReturnValueAttribute = "[global::JetBrains.Annotations.MustUseReturnValue]"; public static IEnumerable<(string filename, string source)> Emit(ResultTypeSchema resultTypeSchema, SymbolWrapper defaultErrorType, @@ -39,9 +39,9 @@ string Replace(string code, IReadOnlyCollection additionalNamespaces, st if (!referencesJetBrainsAnnotations) { code = code - .Replace("[global::JetBrains.Annotations.InstantHandle]", "") - .Replace("[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]", "") - .Replace(MustUseReturnValueAttribute, ""); + .Replace(Constants.Attributes.InstantHandle, "") + .Replace(Constants.Attributes.InstantHandleRequireAwait, "") + .Replace(Constants.Attributes.MustUseReturnValue, ""); } code = code .Replace($"namespace {TemplateNamespace}", $"namespace {resultTypeNamespace}") @@ -175,7 +175,7 @@ static string MakeAggregateExtensionMethod(int typeParameterCount, bool isValueT var taskResultArrayElements = Expand(i => $"r{i}.Result"); var tupleArguments = Expand(i => $"v{i}"); - var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? MustUseReturnValueAttribute : ""; + var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? Constants.Attributes.MustUseReturnValue : ""; return $@" {mustUseReturnValueAttribute} public static MyResult<({typeArguments})> Aggregate<{typeArguments}>(this {parameterDeclarations}) => @@ -216,7 +216,7 @@ public static string GenerateAggregateMethod(int typeParameterCount, bool refere var taskParameterDeclarations = Expand(i => $"global::System.Threading.Tasks.Task> r{i}"); var parameters = Expand(i => $"r{i}"); - var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? MustUseReturnValueAttribute : ""; + var mustUseReturnValueAttribute = referencesJetBrainsAnnotations ? Constants.Attributes.MustUseReturnValue : ""; return $@" {mustUseReturnValueAttribute} diff --git a/Source/FunicularSwitch.Generators/Transformer/Parser.cs b/Source/FunicularSwitch.Generators/Transformer/Parser.cs index a1de1afa..a41619af 100644 --- a/Source/FunicularSwitch.Generators/Transformer/Parser.cs +++ b/Source/FunicularSwitch.Generators/Transformer/Parser.cs @@ -73,7 +73,7 @@ static MethodInfo TransformBind(MonadInfo outer, MonadInfo inner, string transfo (t, p) => { var ma = $"({outerInterfaceImplName([inner.GenericTypeName([t[0]])])}){p[0]}"; - var fn = $"[{Constants.DebuggerStepThroughAttribute}](a) => ({outerInterfaceImplName([inner.GenericTypeName([t[1]])])})(new global::System.Func<{t[0]}, {chainedGenericType([t[1]])}>({p[1]}).Invoke(a))"; // A -> Monad> + var fn = $"{Constants.Attributes.DebuggerStepThrough}(a) => ({outerInterfaceImplName([inner.GenericTypeName([t[1]])])})(new global::System.Func<{t[0]}, {chainedGenericType([t[1]])}>({p[1]}).Invoke(a))"; // A -> Monad> var call = $"{transformerTypeName}.BindT<{t[0]}, {t[1]}>({ma}, {fn}).Cast<{chainedGenericType([t[1]])}>()"; return call; diff --git a/Source/FunicularSwitch.Generators/UnionType/Generator.cs b/Source/FunicularSwitch.Generators/UnionType/Generator.cs index b1feb309..0ed6d5c4 100644 --- a/Source/FunicularSwitch.Generators/UnionType/Generator.cs +++ b/Source/FunicularSwitch.Generators/UnionType/Generator.cs @@ -10,10 +10,6 @@ public static class Generator { private const string VoidMatchMethodName = "Switch"; private const string MatchMethodName = "Match"; - private const string InstantHandleAttribute = "[global::JetBrains.Annotations.InstantHandle]"; - private const string InstantHandleRequireAwaitAttribute = "[global::JetBrains.Annotations.InstantHandle(RequireAwait = true)]"; - private const string MustUseReturnValueAttribute = "global::JetBrains.Annotations.MustUseReturnValue"; - private const string DebuggerStepThroughAttribute = "global::System.Diagnostics.DebuggerStepThrough"; public static (string filename, string source) Emit( UnionTypeSchema unionTypeSchema, @@ -154,7 +150,7 @@ static void WritePartialWithStaticFactories(UnionTypeSchema unionTypeSchema, CSh .Select(p => new ParameterInfo(p.parameterName, ImmutableArray.Empty, p.requiredProperty.Type, null)) ).ToSeparatedString(); var constructorInvocation = $"new {derivedType.FullTypeName}({(constructor.Parameters.Select(p => p.Name).ToSeparatedString())})"; - builder.WriteAttribute(DebuggerStepThroughAttribute); + builder.WriteLine(Constants.Attributes.DebuggerStepThrough); builder.Write($"{(isInternal ? "internal" : "public")} static {unionTypeSchema.FullTypeName}{typeParameters} {methodName}({arguments}) => {constructorInvocation}"); if (requiredParametersToAdd.Count > 0) @@ -288,7 +284,7 @@ static void WriteMatchSignature( string t = "T") { var instantHandle = hasJetBrainsAnnotationsReference - ? isAsync ? InstantHandleRequireAwaitAttribute : InstantHandleAttribute + ? isAsync ? Constants.Attributes.InstantHandleRequireAwait : Constants.Attributes.InstantHandle : ""; var modifiers = "public static"; if (isAsync) @@ -304,8 +300,8 @@ static void WriteMatchSignature( var typeParameterList = unionTypeSchema.TypeParameters.Concat([t]).ToSeparatedString(); - builder.WriteAttribute(DebuggerStepThroughAttribute); - if (hasJetBrainsAnnotationsReference) builder.WriteAttribute(MustUseReturnValueAttribute); + builder.WriteLine(Constants.Attributes.DebuggerStepThrough); + if (hasJetBrainsAnnotationsReference) builder.WriteLine(Constants.Attributes.MustUseReturnValue); builder.WriteMethodSignature( modifiers: modifiers, returnType: returnType, @@ -325,7 +321,7 @@ static void WriteSwitchSignature( bool lambda = false) { var instantHandle = hasJetBrainsAnnotationsReference - ? isAsync ? InstantHandleRequireAwaitAttribute : InstantHandleAttribute + ? isAsync ? Constants.Attributes.InstantHandleRequireAwait : Constants.Attributes.InstantHandle : ""; var returnType = asyncReturn ?? isAsync ? "async global::System.Threading.Tasks.Task" : "void"; var handlerParameters = unionTypeSchema.Cases @@ -345,7 +341,7 @@ static void WriteSwitchSignature( var typeParameters = RoslynExtensions.FormatTypeParameters(unionTypeSchema.TypeParameters); - builder.WriteAttribute(DebuggerStepThroughAttribute); + builder.WriteLine(Constants.Attributes.DebuggerStepThrough); builder.WriteMethodSignature( modifiers: "public static", returnType: returnType, diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs index 5f4a1341..c06bff0d 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.ExtendMonadGenerator/FunicularSwitch.Generators.Consumer.Writer.g.cs @@ -2,52 +2,68 @@ { public static partial class Writer { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Init(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Init(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(((global::FunicularSwitch.Generators.Consumer.Writer)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer Map(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer Map(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer Select(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer Select(this global::FunicularSwitch.Generators.Consumer.Writer ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs index c6659c80..e8b9b0bd 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.OptionResult.g.cs @@ -2,15 +2,20 @@ { public partial record OptionResult(global::FunicularSwitch.Option> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator OptionResult(global::FunicularSwitch.Option> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Option>(OptionResult ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => OptionResult.SomeOk(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (OptionResult)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -18,106 +23,141 @@ public static partial class OptionResult { private readonly record struct Impl__FunicularSwitch_Option(global::FunicularSwitch.Option M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Option(global::FunicularSwitch.Option ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Option(Impl__FunicularSwitch_Option ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Option)global::FunicularSwitch.Option.Some(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Option)M.Bind(a => (global::FunicularSwitch.Option)(Impl__FunicularSwitch_Option)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Lift(global::FunicularSwitch.Option ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Lift(global::FunicularSwitch.Option ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Generators.Consumer.OptionResult SomeOk(A a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> SomeOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> SomeOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Bind(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Option>)((global::FunicularSwitch.Option>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Option>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult SelectMany(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.OptionResult)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Map(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Map(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.OptionResult Select(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.OptionResult Select(this global::FunicularSwitch.Generators.Consumer.OptionResult ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Option>.Some(global::FunicularSwitch.Result.Ok(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs index 4d7808bc..a14ff2a8 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultEnumerable.g.cs @@ -2,15 +2,20 @@ { public readonly partial record struct ResultEnumerable(global::FunicularSwitch.Generators.Consumer.Result> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator ResultEnumerable(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultEnumerable ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultEnumerable.OkYield(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultEnumerable)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -18,106 +23,141 @@ public static partial class ResultEnumerable { private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable OkYield(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> OkYield(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> OkYield(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Bind(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.EnumerableT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultEnumerable)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Map(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Map(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Select(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultEnumerable Select(this global::FunicularSwitch.Generators.Consumer.ResultEnumerable ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Transformers.EnumerableT.Yield(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs index e40e642e..3cc5850e 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.ResultOption.g.cs @@ -2,15 +2,20 @@ { public partial record ResultOption(global::FunicularSwitch.Generators.Consumer.Result> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator ResultOption(global::FunicularSwitch.Generators.Consumer.Result> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Generators.Consumer.Result>(ResultOption ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => ResultOption.OkSome(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (ResultOption)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -18,106 +23,141 @@ public static partial class ResultOption { private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Result(global::FunicularSwitch.Generators.Consumer.Result ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Generators.Consumer.Result(Impl__FunicularSwitch_Generators_Consumer_Result ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Result)global::FunicularSwitch.Generators.Consumer.Result.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Result)M.Bind(a => (global::FunicularSwitch.Generators.Consumer.Result)(Impl__FunicularSwitch_Generators_Consumer_Result)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Lift(global::FunicularSwitch.Generators.Consumer.Result ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Generators.Consumer.ResultOption OkSome(A a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> OkSome(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> OkSome(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Bind(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.OptionT.BindT((Impl__FunicularSwitch_Generators_Consumer_Result>)((global::FunicularSwitch.Generators.Consumer.Result>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Result>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption SelectMany(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.ResultOption)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Map(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Map(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.ResultOption Select(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.ResultOption Select(this global::FunicularSwitch.Generators.Consumer.ResultOption ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Result>.Ok(global::FunicularSwitch.Option.Some(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs index 7f7431b6..5914106a 100644 --- a/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs +++ b/Source/Tests/FunicularSwitch.Generators.Consumer/Generated/FunicularSwitch.Generators/FunicularSwitch.Generators.TransformerGenerator/FunicularSwitch.Generators.Consumer.WriterResult.g.cs @@ -4,79 +4,105 @@ public static partial class WriterResult { private readonly record struct Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Generators_Consumer_Writer(global::FunicularSwitch.Generators.Consumer.Writer ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Generators.Consumer.Writer(Impl__FunicularSwitch_Generators_Consumer_Writer ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Init(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Generators_Consumer_Writer)global::FunicularSwitch.Generators.Consumer.Writer.Bind(M, a => (global::FunicularSwitch.Generators.Consumer.Writer)(Impl__FunicularSwitch_Generators_Consumer_Writer)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Lift(global::FunicularSwitch.Generators.Consumer.Writer ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> Lift(global::FunicularSwitch.Generators.Consumer.Writer ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Generators.Consumer.Writer.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Generators.Consumer.Writer> InitOk(A a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task>> InitOk(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask>> InitOk(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Bind(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> Bind(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Transformers.ResultT.BindT((Impl__FunicularSwitch_Generators_Consumer_Writer>)((global::FunicularSwitch.Generators.Consumer.Writer>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Generators_Consumer_Writer>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> SelectMany(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Generators.Consumer.Writer>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Map(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> Map(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Generators.Consumer.Writer> Select(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Generators.Consumer.Writer> Select(this global::FunicularSwitch.Generators.Consumer.Writer> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Generators.Consumer.Writer.Init>(global::FunicularSwitch.Result.Ok(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonad#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonad#FunicularSwitch.Test.MonadA.g.verified.cs index 1e74052d..47b40038 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonad#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonad#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs index 47b64415..fe3ed438 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs index 04a25f28..2e2012a4 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs index f1b75d25..b593c604 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs index b4f10fb5..7ea1ec6d 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs index 9b093288..7cf51f0b 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.GenericMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => ((global::FunicularSwitch.Test.MonadA)(await ma)).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonad#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonad#FunicularSwitch.Test.MonadA.g.verified.cs index f6866b0a..cc688810 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonad#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonad#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs index 7a346f7a..0750c6a6 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs index f8791c4c..37eef549 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs index 2f931262..81caaa20 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs index e011c1ba..e792b7b0 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs index e4d909e1..bf67d117 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/ExtendMonadGeneratorTest.StaticMonadMultipleParameters_typeArguments=T, U, V, W, X#FunicularSwitch.Test.MonadA.g.verified.cs @@ -3,52 +3,68 @@ namespace FunicularSwitch.Test { public static partial class MonadA { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return((await a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadA.Bind(((global::FunicularSwitch.Test.MonadA)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA SelectMany(this global::FunicularSwitch.Test.MonadA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Map(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA Select(this global::FunicularSwitch.Test.MonadA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return(fn(a))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadAB.g.verified.cs index 8b831fae..d0a6ccdf 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorInteropTest.TransformResultType#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Ok(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)M.Bind(a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB Ok(A a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Ok(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Ok(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Ok(global::FunicularSwitch.Test.MonadB.Ok(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethods#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethods#FunicularSwitch.Test.MonadAB.g.verified.cs index bd0b8831..a952763f 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethods#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethods#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.ReturnAReturnB(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.BindABindB(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.ReturnA(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.BindA(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.BindA(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.BindA(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.BindA((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.BindA((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.BindA((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.BindA((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB ReturnAReturnB(A a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> ReturnAReturnB(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> ReturnAReturnB(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB BindABindB(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB BindABindB(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> BindABindB(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> BindABindB(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> BindABindB(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> BindABindB(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB BindABindB(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB BindABindB(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> BindABindB(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> BindABindB(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> BindABindB(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> BindABindB(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).BindABindB([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.ReturnA>(global::FunicularSwitch.Test.MonadB.ReturnB(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethodsFromGeneric#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethodsFromGeneric#FunicularSwitch.Test.MonadAB.g.verified.cs index c69861fa..8a7bce0c 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethodsFromGeneric#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadMethodsFromGeneric#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)M.Bind(a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB Return(A a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadTypes#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadTypes#FunicularSwitch.Test.MonadAB.g.verified.cs index 9212b1de..e0c27f06 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadTypes#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.ImplicitMonadTypes#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.MultipleTransformers#FunicularSwitch.Test.MonadABA.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.MultipleTransformers#FunicularSwitch.Test.MonadABA.g.verified.cs index de932e2a..6ef88531 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.MultipleTransformers#FunicularSwitch.Test.MonadABA.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.MultipleTransformers#FunicularSwitch.Test.MonadABA.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadABA(global::FunicularSwitch.Test.MonadA>> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadABA(global::FunicularSwitch.Test.MonadA>> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>>(MonadABA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadABA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadABA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,120 +24,160 @@ public static partial class MonadABA { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)M.Bind(a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } private readonly record struct Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB)global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB)global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)M, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>(a => (global::FunicularSwitch.Test.MonadA>)(Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB)fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB)global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)M, [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>(a => (global::FunicularSwitch.Test.MonadA>)(Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB)fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadABA Return(A a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return((await a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return((await a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA Bind(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA Bind(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA Bind(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA Bind(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn) => global::FunicularSwitch.Test.MonadAT.BindT((Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)((global::FunicularSwitch.Test.MonadA>>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA_global__FunicularSwitch_Test_MonadB>)(new global::System.Func>>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA SelectMany(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func>>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABA)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA Map(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA Map(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABA Select(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABA Select(this global::FunicularSwitch.Test.MonadABA ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>>.Return(global::FunicularSwitch.Test.MonadB>.Return(global::FunicularSwitch.Test.MonadA.Return(fn(a))))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.StaticTransformedMonad#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.StaticTransformedMonad#FunicularSwitch.Test.MonadAB.g.verified.cs index 40d3797f..98ddaeb5 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.StaticTransformedMonad#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.StaticTransformedMonad#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -5,79 +5,105 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadA> Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task>> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask>> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> Bind(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> Bind(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Bind(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Bind(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> SelectMany(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> SelectMany(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> SelectMany(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> SelectMany(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> SelectMany(this global::System.Threading.Tasks.Task>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> SelectMany(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadA>)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> Map(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> Map(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Map(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Map(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadA> Select(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadA> Select(this global::FunicularSwitch.Test.MonadA> ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task>> Select(this global::System.Threading.Tasks.Task>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask>> Select(this global::System.Threading.Tasks.ValueTask>> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=internal partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=internal partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index 95f1799d..c352790e 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=internal partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=internal partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -4,15 +4,20 @@ namespace FunicularSwitch.Test internal partial class MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { public global::FunicularSwitch.Test.MonadA> M { get; } = M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -20,106 +25,141 @@ internal static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index 0d6afa57..e168cfbe 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial class#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -4,15 +4,20 @@ namespace FunicularSwitch.Test public partial class MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { public global::FunicularSwitch.Test.MonadA> M { get; } = M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -20,106 +25,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index 8237c206..438b8328 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public partial record struct MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index cc9b30ba..1968b754 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial record#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public partial record MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index ebd725bc..26f717f0 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -4,15 +4,20 @@ namespace FunicularSwitch.Test public partial struct MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { public global::FunicularSwitch.Test.MonadA> M { get; } = M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -20,106 +25,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index d4e40f92..69842ea1 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial record struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs index 2d12c900..6a2187e8 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.TypeModifiers_modifier=public readonly partial struct#FunicularSwitch.Test.MonadAMonadB.g.verified.cs @@ -4,15 +4,20 @@ namespace FunicularSwitch.Test public readonly partial struct MonadAMonadB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { public global::FunicularSwitch.Test.MonadA> M { get; } = M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAMonadB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAMonadB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAMonadB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAMonadB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -20,106 +25,141 @@ public static partial class MonadAMonadB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Bind(M, a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Lift(global::FunicularSwitch.Test.MonadA ma) => global::FunicularSwitch.Test.MonadA.Bind(ma, [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => global::FunicularSwitch.Test.MonadA.Bind((await ma), [global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAMonadB Return(A a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Bind(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB SelectMany(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAMonadB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Map(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAMonadB Select(this global::FunicularSwitch.Test.MonadAMonadB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA.Return>(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithMonadImplementingInterface#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithMonadImplementingInterface#FunicularSwitch.Test.MonadAB.g.verified.cs index 839b9b9f..61046320 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithMonadImplementingInterface#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithMonadImplementingInterface#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,108 +3,143 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } public static partial class MonadAB { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB Return(A a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((global::FunicularSwitch.Test.MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadAB.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadAB.g.verified.cs index c69861fa..8a7bce0c 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadAB.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadAB.g.verified.cs @@ -3,15 +3,20 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadAB(global::FunicularSwitch.Test.MonadA> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadAB(global::FunicularSwitch.Test.MonadA> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA>(MonadAB ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadAB.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadAB)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } @@ -19,106 +24,141 @@ public static partial class MonadAB { private readonly record struct Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator Impl__FunicularSwitch_Test_MonadA(global::FunicularSwitch.Test.MonadA ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadA(Impl__FunicularSwitch_Test_MonadA ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Return(B a) => (Impl__FunicularSwitch_Test_MonadA)global::FunicularSwitch.Test.MonadA.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public global::FunicularSwitch.Transformers.Monad Bind(global::System.Func> fn) => (Impl__FunicularSwitch_Test_MonadA)M.Bind(a => (global::FunicularSwitch.Test.MonadA)(Impl__FunicularSwitch_Test_MonadA)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public B Cast() => (B)(object)M; } - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Lift(global::FunicularSwitch.Test.MonadA ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadAB Return(A a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Bind(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadBT.BindT((Impl__FunicularSwitch_Test_MonadA>)((global::FunicularSwitch.Test.MonadA>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (Impl__FunicularSwitch_Test_MonadA>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB SelectMany(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadAB)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Map(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadAB Select(this global::FunicularSwitch.Test.MonadAB ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadA>.Return(global::FunicularSwitch.Test.MonadB.Return(fn(a)))); } } diff --git a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadABC.g.verified.cs b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadABC.g.verified.cs index 0ad7b6c6..b919eb47 100644 --- a/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadABC.g.verified.cs +++ b/Source/Tests/FunicularSwitch.Generators.Test/Snapshots/TransformerGeneratorTest.WithTransformedMonads#FunicularSwitch.Test.MonadABC.g.verified.cs @@ -3,108 +3,143 @@ namespace FunicularSwitch.Test { public readonly partial record struct MonadABC(global::FunicularSwitch.Test.MonadAB> M) : global::FunicularSwitch.Transformers.Monad { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator MonadABC(global::FunicularSwitch.Test.MonadAB> ma) => new(ma); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static implicit operator global::FunicularSwitch.Test.MonadAB>(MonadABC ma) => ma.M; - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Return(A_ a) => MonadABC.Return(a); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] global::FunicularSwitch.Transformers.Monad global::FunicularSwitch.Transformers.Monad.Bind(global::System.Func> fn) => this.Bind(a => (MonadABC)fn(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] A_ global::FunicularSwitch.Transformers.Monad.Cast() => (A_)(object)M; } public static partial class MonadABC { - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC Lift(global::FunicularSwitch.Test.MonadAB ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC Lift(global::FunicularSwitch.Test.MonadAB ma) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Lift(global::System.Threading.Tasks.Task> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Lift(global::System.Threading.Tasks.ValueTask> ma) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static global::FunicularSwitch.Test.MonadABC Return(A a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(a)); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.Task> Return(global::System.Threading.Tasks.Task a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] public static async global::System.Threading.Tasks.ValueTask> Return(global::System.Threading.Tasks.ValueTask a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return((await a))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC Bind(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC Bind(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC Bind(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC Bind(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Bind(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Bind(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)ma), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThroughAttribute](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => fn(a)).Invoke(a))).Cast>>(); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn) => global::FunicularSwitch.Test.MonadCT.BindT((global::FunicularSwitch.Test.MonadAB>)((global::FunicularSwitch.Test.MonadAB>)(await ma)), [global::System.Diagnostics.DebuggerStepThrough](a) => (global::FunicularSwitch.Test.MonadAB>)(new global::System.Func>>([global::System.Diagnostics.DebuggerStepThrough](a) => fn(a)).Invoke(a))).Cast>>(); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC SelectMany(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func>> fn, global::System.Func selector) => ma.SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> SelectMany(this global::System.Threading.Tasks.Task> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThroughAttribute](b) => selector(a, b))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> SelectMany(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func>> fn, global::System.Func selector) => (await ma).SelectMany([global::System.Diagnostics.DebuggerStepThrough](a) => ((global::FunicularSwitch.Test.MonadABC)fn(a)).Map([global::System.Diagnostics.DebuggerStepThrough](b) => selector(a, b))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC Map(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC Map(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Map(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Map(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static global::FunicularSwitch.Test.MonadABC Select(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static global::FunicularSwitch.Test.MonadABC Select(this global::FunicularSwitch.Test.MonadABC ma, global::System.Func fn) => ma.Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.Task> Select(this global::System.Threading.Tasks.Task> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); - [global::System.Diagnostics.Contracts.PureAttribute, global::System.Diagnostics.DebuggerStepThroughAttribute] - public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThroughAttribute](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); + [global::System.Diagnostics.Contracts.PureAttribute] + [global::System.Diagnostics.DebuggerStepThrough] + public static async global::System.Threading.Tasks.ValueTask> Select(this global::System.Threading.Tasks.ValueTask> ma, global::System.Func fn) => (await ma).Bind([global::System.Diagnostics.DebuggerStepThrough](a) => global::FunicularSwitch.Test.MonadAB.Return(global::FunicularSwitch.Test.MonadC.Return(fn(a)))); } }