diff --git a/OnixLabs.Core/OnixLabs.Core.csproj b/OnixLabs.Core/OnixLabs.Core.csproj index 4c53a9e..88028d0 100644 --- a/OnixLabs.Core/OnixLabs.Core.csproj +++ b/OnixLabs.Core/OnixLabs.Core.csproj @@ -7,11 +7,11 @@ OnixLabs.Core ONIXLabs ONIXLabs Core API for .NET - 8.11.0 + 8.12.0 en Copyright © ONIXLabs 2020 https://github.com/onix-labs/onixlabs-dotnet - 8.11.0 + 8.12.0 $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/OnixLabs.Core/Result.Failure.cs b/OnixLabs.Core/Result.Failure.cs index 41bea29..f0a1d70 100644 --- a/OnixLabs.Core/Result.Failure.cs +++ b/OnixLabs.Core/Result.Failure.cs @@ -13,6 +13,7 @@ // limitations under the License. using System; +using System.Threading.Tasks; namespace OnixLabs.Core; @@ -288,4 +289,22 @@ public sealed class Failure : Result, IValueEquatable> /// /// Returns a that represents the current object. public override string ToString() => Exception.ToString(); + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() + { + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. + /// + /// + /// Returns a task that represents the asynchronous dispose operation. + /// + public override async ValueTask DisposeAsync() + { + await ValueTask.CompletedTask; + } } diff --git a/OnixLabs.Core/Result.Success.cs b/OnixLabs.Core/Result.Success.cs index f582bf6..d5db2ff 100644 --- a/OnixLabs.Core/Result.Success.cs +++ b/OnixLabs.Core/Result.Success.cs @@ -13,6 +13,7 @@ // limitations under the License. using System; +using System.Threading.Tasks; namespace OnixLabs.Core; @@ -294,4 +295,25 @@ public override void Throw() /// /// Returns a that represents the current object. public override string ToString() => Value?.ToString() ?? string.Empty; + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public override void Dispose() + { + if (Value is IDisposable disposable) + disposable.Dispose(); + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. + /// + /// + /// Returns a task that represents the asynchronous dispose operation. + /// + public override async ValueTask DisposeAsync() + { + if (Value is IAsyncDisposable disposable) + await disposable.DisposeAsync(); + } } diff --git a/OnixLabs.Core/Result.cs b/OnixLabs.Core/Result.cs index f02b1a1..890ec91 100644 --- a/OnixLabs.Core/Result.cs +++ b/OnixLabs.Core/Result.cs @@ -254,7 +254,7 @@ public static async Task OfAsync(Func func, Can /// Represents a result value, which signifies the presence of a value or an exception. /// /// The type of the underlying result value. -public abstract class Result : IValueEquatable> +public abstract class Result : IValueEquatable>, IDisposable, IAsyncDisposable { /// /// Initializes a new instance of the class. @@ -528,4 +528,17 @@ public static async Task> OfAsync(Func> fun Failure failure => failure.ToString(), _ => base.ToString() ?? GetType().FullName ?? nameof(Result) }; + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public abstract void Dispose(); + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. + /// + /// + /// Returns a task that represents the asynchronous dispose operation. + /// + public abstract ValueTask DisposeAsync(); } diff --git a/OnixLabs.Numerics/OnixLabs.Numerics.csproj b/OnixLabs.Numerics/OnixLabs.Numerics.csproj index fc46920..3c2fb9c 100644 --- a/OnixLabs.Numerics/OnixLabs.Numerics.csproj +++ b/OnixLabs.Numerics/OnixLabs.Numerics.csproj @@ -4,13 +4,13 @@ OnixLabs.Numerics ONIXLabs ONIXLabs Numerics API for .NET - 8.11.0 + 8.12.0 en enable true Copyright © ONIXLabs 2020 https://github.com/onix-labs/onixlabs-dotnet - 8.11.0 + 8.12.0 12 diff --git a/OnixLabs.Security.Cryptography/OnixLabs.Security.Cryptography.csproj b/OnixLabs.Security.Cryptography/OnixLabs.Security.Cryptography.csproj index 753cde9..c8b1f63 100644 --- a/OnixLabs.Security.Cryptography/OnixLabs.Security.Cryptography.csproj +++ b/OnixLabs.Security.Cryptography/OnixLabs.Security.Cryptography.csproj @@ -4,13 +4,13 @@ OnixLabs.Security.Cryptography ONIXLabs ONIXLabs Cryptography API for .NET - 8.11.0 + 8.12.0 en enable true Copyright © ONIXLabs 2020 https://github.com/onix-labs/onixlabs-dotnet - 8.11.0 + 8.12.0 12 diff --git a/OnixLabs.Security/OnixLabs.Security.csproj b/OnixLabs.Security/OnixLabs.Security.csproj index 07256b9..3642410 100644 --- a/OnixLabs.Security/OnixLabs.Security.csproj +++ b/OnixLabs.Security/OnixLabs.Security.csproj @@ -4,13 +4,13 @@ OnixLabs.Security ONIXLabs ONIXLabs Security API for .NET - 8.11.0 + 8.12.0 en enable true Copyright © ONIXLabs 2020 https://github.com/onix-labs/onixlabs-dotnet - 8.11.0 + 8.12.0 12