ImanSoftware.Outcome 1.0.3

dotnet add package ImanSoftware.Outcome --version 1.0.3
                    
NuGet\Install-Package ImanSoftware.Outcome -Version 1.0.3
                    
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="ImanSoftware.Outcome" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ImanSoftware.Outcome" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="ImanSoftware.Outcome" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ImanSoftware.Outcome --version 1.0.3
                    
#r "nuget: ImanSoftware.Outcome, 1.0.3"
                    
#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.
#:package ImanSoftware.Outcome@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ImanSoftware.Outcome&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=ImanSoftware.Outcome&version=1.0.3
                    
Install as a Cake Tool

ImanSoftware.Outcome

Version: 1.0.0 | Last Updated: August 2026

A lightweight and extensible Result/Outcome implementation for .NET that helps you manage application flow without relying on exceptions.

ImanSoftware.Outcome provides a clean implementation of the Result Pattern, allowing methods to return success or failure states with meaningful error information instead of throwing exceptions for expected scenarios.


Installation

Install the package using the .NET CLI:

dotnet add package ImanSoftware.Outcome

Why Outcome?

Using exceptions for expected business scenarios often makes code harder to read, test, and maintain.

Instead of this:

try
{
    var product = service.Get(id);
}
catch (NotFoundException)
{
    // Handle error
}

You can write:

var result = service.Get(id);

if (!result.IsSuccess)
{
    // Handle error
}

This approach provides:

  • Better readability
  • Explicit success/failure flow
  • Easier testing
  • Better performance by avoiding unnecessary exceptions
  • Consistent error handling across projects

Features

  • Outcome and Outcome<T> types
  • ✅ Success and Failure states
  • ✅ Rich OutcomeError object
  • ✅ Predefined error types
  • ✅ Implicit conversion from T to Outcome<T>
  • ✅ Common application exceptions
  • ✅ Convert exceptions to Outcome using ToResult()
  • ✅ Lightweight and dependency-free

Outcome Types

Outcome

Represents an operation without a return value.

Outcome.Successful();

Outcome.Failure(
    new OutcomeError(
        "Something went wrong",
        "GENERAL_ERROR",
        OutcomeErrorType.Failure));

Outcome<T>

Represents an operation that returns data.

Outcome<Product>.Successful(product);

or simply:

Product product = GetProduct();

Outcome<Product> result = product;

OutcomeError

Each failure contains an OutcomeError.

new OutcomeError(
    message: "Product not found",
    code: "NOT_FOUND",
    type: OutcomeErrorType.NotFound);

Properties:

Property Description
Message Human-readable error message
Code Application-specific error code
Type Error category

Error Types

The package includes predefined error categories:

Type Description
None No error
Failure General failure
Validation Validation error
Problem Unexpected problem
NotFound Resource not found
Conflict Conflict with current state
InquiryError Business inquiry error

Built-in Exceptions

The package includes common exceptions used in business applications.

  • NotFoundException
  • ValidationException
  • BusinessRuleException
  • UnauthorizedException
  • ForbiddenException
  • ConflictException
  • BadRequestException

These exceptions can easily be converted into an Outcome.


Exception to Outcome

try
{
    // code
}
catch (Exception ex)
{
    return ex.ToResult();
}

Example

using ImanSoftware.Outcome;

public Outcome<Product> GetProduct(int id)
{
    var product = _repository.GetById(id);

    if (product is null)
    {
        return Outcome<Product>.Failure(
            new OutcomeError(
                "Product not found",
                "NOT_FOUND",
                OutcomeErrorType.NotFound));
    }

    return Outcome<Product>.Successful(product);
}

Working with Results

var result = GetProduct(id);

if (result.IsSuccess)
{
    Console.WriteLine(result.Value.Name);
}
else
{
    Console.WriteLine(result.Error.Message);
}

Design Goals

  • Simple API
  • High performance
  • Minimal allocations
  • Framework independent
  • Easy integration with ASP.NET Core
  • Suitable for Clean Architecture
  • Suitable for DDD
  • Suitable for CQRS
  • Consistent error handling

Requirements

  • .NET Standard 2.0+
  • .NET 6+
  • .NET 7+
  • .NET 8+
  • .NET 9+
  • .NET 10.0+

Author

Iman Estiri

📧 contact.imanestiri@gmail.com

📧 dev.imanestiri@gmail.com

GitHub:

https://github.com/ImanEstiri


License

This project is licensed under the MIT License.

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

    • No dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on ImanSoftware.Outcome:

Package Downloads
ImanSoftware.Domain

Base DDD building blocks: Entity, ValueObject, AggregateRoot, Guard clauses, and domain event abstractions.

ImanSoftware.RateLimiter

Rate limiting abstraction with in-memory and distributed support.

ImanSoftware.Framework

Umbrella package that bundles all ImanSoftware modules for a unified development experience.

ImanSoftware.DataAccess.Dapper

Dapper implementation of ImanSoftware.DataAccess for high-performance SQL operations.

ImanSoftware.DataAccess

Database-agnostic data access abstractions (connection factory, transaction scope, query executor).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 293 8/3/2026