-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff7eac7
commit bc1c2f1
Showing
6 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#if !NET8_0_OR_GREATER | ||
namespace System.Runtime.CompilerServices; | ||
|
||
internal sealed class CollectionBuilderAttribute : Attribute | ||
{ | ||
public CollectionBuilderAttribute(Type builderType, string methodName) | ||
{ | ||
BuilderType = builderType; | ||
MethodName = methodName; | ||
} | ||
|
||
public Type BuilderType { get; } | ||
public string MethodName { get; } | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace ErrorOr; | ||
|
||
/// <summary> | ||
/// Contains methods supporting collection expressions. | ||
/// </summary> | ||
public static class CollectionExpression | ||
{ | ||
/// <summary> | ||
/// Creates <see cref="ErrorOr{TValue}"/> from read-only span of errors. | ||
/// </summary> | ||
/// <typeparam name="TValue">Type of value.</typeparam> | ||
/// <param name="errors">Read-only span of errors.</param> | ||
/// <returns>Error or vale.</returns> | ||
/// <remarks>Enables support for collection expressions.</remarks> | ||
public static ErrorOr<TValue> CreateErrorOr<TValue>(ReadOnlySpan<Error> errors) | ||
{ | ||
return errors.ToArray(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates <see cref="IErrorOr{TValue}"/> from read-only span of errors. | ||
/// </summary> | ||
/// <typeparam name="TValue">Type of value.</typeparam> | ||
/// <param name="errors">Read-only span of errors.</param> | ||
/// <returns>Error or vale.</returns> | ||
/// <remarks>Enables support for collection expressions.</remarks> | ||
public static IErrorOr<TValue> CreateIErrorOrValue<TValue>(ReadOnlySpan<Error> errors) | ||
{ | ||
return CreateErrorOr<TValue>(errors); | ||
} | ||
|
||
/// <summary> | ||
/// Creates <see cref="IErrorOr"/> from read-only span of errors. | ||
/// </summary> | ||
/// <param name="errors">Read-only span of errors.</param> | ||
/// <returns>Error or vale.</returns> | ||
/// <remarks>Enables support for collection expressions.</remarks> | ||
public static IErrorOr CreateIErrorOr(ReadOnlySpan<Error> errors) | ||
{ | ||
return CreateErrorOr<object>(errors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters