Intelsoft.Platform.Common.Result 1.0.0-beta-1

This is a prerelease version of Intelsoft.Platform.Common.Result.
dotnet add package Intelsoft.Platform.Common.Result --version 1.0.0-beta-1
NuGet\Install-Package Intelsoft.Platform.Common.Result -Version 1.0.0-beta-1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Intelsoft.Platform.Common.Result" Version="1.0.0-beta-1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Intelsoft.Platform.Common.Result --version 1.0.0-beta-1
#r "nuget: Intelsoft.Platform.Common.Result, 1.0.0-beta-1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Intelsoft.Platform.Common.Result as a Cake Addin
#addin nuget:?package=Intelsoft.Platform.Common.Result&version=1.0.0-beta-1&prerelease

// Install Intelsoft.Platform.Common.Result as a Cake Tool
#tool nuget:?package=Intelsoft.Platform.Common.Result&version=1.0.0-beta-1&prerelease

Result Library

Overview

The Result and Result<T> classes are designed to represent the outcome of operations within an application. They encapsulate the success or failure of an operation, with Result<T> optionally containing a return value if the operation is successful, or errors if it fails.

This library also includes the ResultExtensions class which provides utility methods for working with Result and Result<T> objects, allowing for clean and expressive handling of operation results without the need to manually check flags and error lists.

Installation

Using NuGet Package Manager

If the library is packaged as a NuGet package, you can install it using the NuGet Package Manager with the following command:

Install-Package Intelsoft.Platform.Common.Intelsoft

Manual Installation

If you are including the library manually:

  1. Clone the repository or download the latest release.
  2. Include the project or compiled DLL in your solution.
  3. Add a reference to the project or the DLL in your application.

Usage

Quick Start

Here is a simple example of how to use the Result and Result<T> classes:

using Intelsoft.Platform.Common.Result;

// Example of a successful result without data
Result successResult = Result.Ok();

// Example of a successful result with data
Result<int> successResultWithValue = Result.Ok(42);

// Example of a failure result
Result failureResult = Result.Fail(new Error("ERR001", "Invalid operation", ErrorType.Validation));

// Using ResultExtensions to handle results
string message = successResultWithValue.Match(
    onSuccess: value => $"Operation succeeded with value: {value}",
    onError: errors => $"Operation failed with error: {errors.First().Description}"
);

Handling Asynchronous Results

You can handle asynchronous results using the async extensions:

Task<Result<int>> resultTask = GetResultAsync();
int processedValue = await resultTask.Match(
    onSuccess: value => ProcessValue(value),
    onError: errors => HandleErrors(errors)
);

Running Tests

Ensure you have a testing framework like xUnit installed and configure your test environment:

  1. Navigate to the test directory.
  2. Run the tests using a test runner compatible with your setup (e.g., Visual Studio, Rider, or command line).
dotnet test

Contributing

Contributions are welcome! Please fork the repository and submit pull requests with any enhancements, bug fixes, or improvements you have made.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Intelsoft.Platform.Common.Result:

Package Downloads
Intelsoft.Platform.Domain.Core

Core domain library containing essential building blocks for domain-driven design such as AggregateRoot, Entity, ValueObject, DomainEvent, Repository, and Specification.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta-1 50 4/12/2024