Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMatthewLayton committed Jun 11, 2024
2 parents d5f67e5 + 7fc743a commit 06dc639
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
4 changes: 2 additions & 2 deletions OnixLabs.Core/OnixLabs.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<Title>OnixLabs.Core</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Core API for .NET</Description>
<AssemblyVersion>8.9.0</AssemblyVersion>
<AssemblyVersion>8.10.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.9.0</PackageVersion>
<PackageVersion>8.10.0</PackageVersion>
</PropertyGroup>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand Down
46 changes: 46 additions & 0 deletions OnixLabs.Core/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

using System;
using System.Threading;
using System.Threading.Tasks;

namespace OnixLabs.Core;
Expand Down Expand Up @@ -83,6 +84,29 @@ public static async Task<Result> OfAsync(Func<Task> func)
}
}

/// <summary>
/// Creates a new instance of the <see cref="Result"/> class, where the underlying value is the result of a successful invocation
/// of the specified function; otherwise, the underlying value is the exception thrown by a failed invocation of the specified function.
/// </summary>
/// <param name="func">The function to invoke to obtain a successful or failed result.</param>
/// <param name="token">The cancellation token to pass to the invoked function.</param>
/// <returns>
/// Returns a new instance of the <see cref="Result"/> class, where the underlying value is the result of a successful invocation
/// of the specified function; otherwise, the underlying value is the exception thrown by a failed invocation of the specified function.
/// </returns>
public static async Task<Result> OfAsync(Func<CancellationToken, Task> func, CancellationToken token = default)
{
try
{
await func(token);
return Success();
}
catch (Exception exception)
{
return exception;
}
}

/// <summary>
/// Creates a new instance of the <see cref="Result"/> class, where the underlying value represents a successful result.
/// </summary>
Expand Down Expand Up @@ -291,6 +315,28 @@ public static async Task<Result<T>> OfAsync(Func<Task<T>> func)
}
}

/// <summary>
/// Creates a new instance of the <see cref="Result{T}"/> class, where the underlying value is the result of a successful invocation
/// of the specified function; otherwise, the underlying value is the exception thrown by a failed invocation of the specified function.
/// </summary>
/// <param name="func">The function to invoke to obtain a successful or failed result.</param>
/// <param name="token">The cancellation token to pass to the invoked function.</param>
/// <returns>
/// Returns a new instance of the <see cref="Result{T}"/> class, where the underlying value is the result of a successful invocation
/// of the specified function; otherwise, the underlying value is the exception thrown by a failed invocation of the specified function.
/// </returns>
public static async Task<Result<T>> OfAsync(Func<CancellationToken, Task<T>> func, CancellationToken token = default)
{
try
{
return await func(token);
}
catch (Exception exception)
{
return exception;
}
}

/// <summary>
/// Creates a new instance of the <see cref="Result{T}"/> class, where the underlying value represents a successful result.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions OnixLabs.Numerics/OnixLabs.Numerics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Numerics</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Numerics API for .NET</Description>
<AssemblyVersion>8.9.0</AssemblyVersion>
<AssemblyVersion>8.10.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.9.0</PackageVersion>
<PackageVersion>8.10.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Security.Cryptography</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Cryptography API for .NET</Description>
<AssemblyVersion>8.9.0</AssemblyVersion>
<AssemblyVersion>8.10.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.9.0</PackageVersion>
<PackageVersion>8.10.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions OnixLabs.Security/OnixLabs.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<Title>OnixLabs.Security</Title>
<Authors>ONIXLabs</Authors>
<Description>ONIXLabs Security API for .NET</Description>
<AssemblyVersion>8.9.0</AssemblyVersion>
<AssemblyVersion>8.10.0</AssemblyVersion>
<NeutralLanguage>en</NeutralLanguage>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Copyright © ONIXLabs 2020</Copyright>
<RepositoryUrl>https://github.com/onix-labs/onixlabs-dotnet</RepositoryUrl>
<PackageVersion>8.9.0</PackageVersion>
<PackageVersion>8.10.0</PackageVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down

0 comments on commit 06dc639

Please sign in to comment.