Tolitech.Results 1.0.0-preview.6

This is a prerelease version of Tolitech.Results.
dotnet add package Tolitech.Results --version 1.0.0-preview.6
                    
NuGet\Install-Package Tolitech.Results -Version 1.0.0-preview.6
                    
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="Tolitech.Results" Version="1.0.0-preview.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.Results" Version="1.0.0-preview.6" />
                    
Directory.Packages.props
<PackageReference Include="Tolitech.Results" />
                    
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 Tolitech.Results --version 1.0.0-preview.6
                    
#r "nuget: Tolitech.Results, 1.0.0-preview.6"
                    
#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 Tolitech.Results@1.0.0-preview.6
                    
#: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=Tolitech.Results&version=1.0.0-preview.6&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tolitech.Results&version=1.0.0-preview.6&prerelease
                    
Install as a Cake Tool

Tolitech.Results

Tolitech.Results is the core Results pattern library for .NET, enabling you to encapsulate operation outcomes, errors, messages, and metadata in a structured and predictable way.

Features

  • Encapsulates success, failure, and error in operations.
  • Rich metadata: title, detail, type, status code, messages.
  • Factory methods for all major HTTP statuses and business scenarios.
  • Fluent API for adding messages, titles, details, and errors.
  • Support for generic results (Result<T>).

Usage Examples

Success Result

var result = Result.OK();
var resultWithValue = Result.OK<int>(42);

Error Result with Details

var result = Result.BadRequest()
    .WithTitle("Validation Error")
    .WithDetail("The 'Name' field is required.")
    .AddError("Name not provided");

Available Factory Methods

  • OK(), OK<T>(T value)
  • Created(), Created<T>(T value)
  • Accepted(), Accepted<T>(T value)
  • NoContent(), NoContent<T>()
  • Found(), Found<T>(T value)
  • NotModified(), NotModified<T>(T value)
  • BadRequest(), BadRequest(string detail), BadRequest(string title, string detail)
  • Unauthorized(), Unauthorized(string detail), Unauthorized(string title, string detail)
  • Forbidden(), Forbidden(string detail), Forbidden(string title, string detail)
  • NotFound(), NotFound(string detail), NotFound(string title, string detail)
  • MethodNotAllowed(), MethodNotAllowed(string detail), MethodNotAllowed(string title, string detail)
  • RequestTimeout(), RequestTimeout(string detail), RequestTimeout(string title, string detail)
  • Conflict(), Conflict(string detail), Conflict(string title, string detail)
  • TooManyRequests(), TooManyRequests(string detail), TooManyRequests(string title, string detail)
  • InternalServerError(), InternalServerError(string detail), InternalServerError(string title, string detail)
  • BadGateway(), BadGateway(string detail), BadGateway(string title, string detail)
  • ServiceUnavailable(), ServiceUnavailable(string detail), ServiceUnavailable(string title, string detail)
  • GatewayTimeout(), GatewayTimeout(string detail), GatewayTimeout(string title, string detail)

Message Handling

result.AddInformation("Processing completed successfully.");
result.AddWarning("Warning: optional field not filled.");
result.AddError("Unexpected error.", StatusCode.InternalServerError);

Important Properties

  • IsSuccess, IsFailure
  • StatusCode, Title, Detail, Type
  • Messages (collection of messages associated with the result)

Complete Example

public class MathOperation
{
    public Result<int> Divide(int dividend, int divisor)
    {
        if (divisor == 0)
            return Result.BadRequest<int>()
                .WithTitle("Division by zero not allowed")
                .AddError("The divisor cannot be zero.");

        return Result.OK(dividend / divisor);
    }
}

For HTTP integration and fluent validations, see the Tolitech.Results.Http and Tolitech.Results.Guards projects.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Tolitech.Results:

Package Downloads
Tolitech.Results.Guards

Tolitech.Results.Guards is a utility library that provides fluent and expressive guard clauses for result-oriented programming.

Tolitech.Results.Http

This package provides extension methods for handling HTTP responses in .NET applications, facilitating the extraction and mapping of relevant data from HttpResponseMessage objects into Result objects.

Tolitech.Application

The Application repository provides the Unit of Work interface within the Clean Architecture context.

Tolitech.Domain

The Domain layer is the heart of your application, encompassing essential business logic and entities.

Tolitech.Application.Validation

The ValidationBehavior class represents a behavior in the pipeline responsible for validating requests using the provided validators before passing them to the next handler. It is designed to be used within applications built on the MediatR library in .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.6 284 7/25/2025
1.0.0-preview.5 107 7/17/2025
1.0.0-preview.4 157 7/1/2025
1.0.0-preview.3 132 1/7/2025
1.0.0-preview.2 63 1/7/2025
1.0.0-preview.1 146 12/6/2024