ZeroAlloc.Results 1.4.5

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

ZeroAlloc.Results

NuGet Build codecov License: MIT AOT GitHub Sponsors

Railway-style Result<T, E> for .NET 8, 9 and 10: errors as values instead of exceptions, 0 B allocated on success and failure alike, NativeAOT-ready.

Why ZeroAlloc.Results

  • 0 B per call, on both paths. Every type is a readonly struct. Allocation tests assert 0 B for Map, Bind, Match, Tap, Ensure, Combine and LINQ query syntax, for success and failure, and for the ValueTask combinators when they complete synchronously.
  • Faster when things fail. On a hot loop where one call in three fails, it runs 4.1× faster than ErrorOr and 41× faster than FluentResults in the same benchmark run, at parity with OneOf, and allocates nothing.
  • Works under NativeAOT and trimming. No reflection. The package is marked AOT-compatible, and CI publishes and runs a NativeAOT sample with trim and AOT warnings promoted to errors.
  • A familiar API. Map, Bind, Match, Tap and Ensure, LINQ query syntax and ValueTask async variants. Coming from CSharpFunctionalExtensions, most code moves over by swapping the using.

Install

dotnet add package ZeroAlloc.Results

Quick start

using ZeroAlloc.Results;
using ZeroAlloc.Results.Extensions;

Console.WriteLine(Describe("42"));  // Welcome, age 42
Console.WriteLine(Describe("12"));  // Rejected: too young
Console.WriteLine(Describe("abc")); // Rejected: not a number

static string Describe(string input) =>
    ParseAge(input)
        .Ensure(static age => age >= 18, "too young")
        .Map(static age => $"Welcome, age {age}")
        .Match(static text => text, static error => $"Rejected: {error}");

// A value converts to success, an error converts to failure.
static Result<int, string> ParseAge(string input) =>
    int.TryParse(input, out var age) ? age : "not a number";

No exception is thrown: the first failure skips the remaining steps and lands in Match.

What you get

  • Five result shapes: pass/fail, a value or a string error, a value or a typed error, a typed error with no value, and an optional value (Maybe<T>).
  • Railway-style combinators: transform, chain, validate, inspect and unwrap a result without if checks.
  • Batch checks: combine many results into one that reports the first failure.
  • LINQ query syntax: chain dependent steps with from … in … select.
  • Async pipelines: ValueTask-based variants, plus Map and Bind that continue straight onto a ValueTask<Result<T, E>>.
  • Typed errors: use your own error structs or enums, so failures carry data rather than strings.
  • Generic failure construction: pipeline code can build a failed result for a response type it only knows as a type parameter, without reflection.

Performance

.NET 10.0.13, BenchmarkDotNet v0.15.8, all libraries in the same run. Allocations are exact; time is the ratio against ZeroAlloc.Results.

Scenario ZeroAlloc.Results OneOf ErrorOr FluentResults
Failure construct 0 B 0 B 88 B 272 B
Failure consume 0 B 0 B 0 B 240 B
Hot loop (100 iter, 1-in-3 fail), time 1.00 1.02 4.14 41.4
Hot loop, allocated 0 B 0 B 2,992 B 25,968 B

The performance page has every scenario, a comparison with CSharpFunctionalExtensions, a Result versus throw/catch benchmark and how to run them yourself.

Learn more

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  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 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.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (30)

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

Package Downloads
ZeroAlloc.Resilience

Source-generated, zero-allocation resilience policies for .NET. Add [Retry], [Timeout], [RateLimit], and [CircuitBreaker] to an interface; the generator emits a proxy composing all policies in declaration order. AOT-safe.

ZeroAlloc.Authorization

Authorization primitives for .NET — ISecurityContext, IAuthorizationPolicy, [Policy] / [RequirePolicy] attributes with a source generator that emits DI registrations and per-request AuthorizerFor<T> dispatchers. Shared by AI.Sentinel and ZeroAlloc.Mediator.Authorization.

ZeroAlloc.Rest

Source-generated, AOT-compatible REST client for .NET

ZeroAlloc.Mediator.Validation

Pipeline behavior that validates IRequest<T> via ZeroAlloc.Validation before dispatch. Validation failures surface as Result<T, ValidationError> or UnitResult<ValidationError> — no exceptions on the hot path.

ZeroAlloc.Mapping

Source-generated, zero-allocation Command→Domain→DTO mapper for .NET. [Map<,>]/[TryMap<,>] on a static partial class — generator emits direct property assignments at compile time. Result<T, MappingError> on the [TryMap] path; ValueObjects smart constructors honoured automatically. AOT-safe.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.5 14,271 10/21/2026
1.4.4 6,722 10/16/2026
1.4.3 1,188 10/16/2026
1.4.2 2,735 10/15/2026
1.4.1 8,599 10/11/2026
1.4.0 3,332 10/10/2026
1.3.0 1,093 10/10/2026
1.2.4 11,399 9/28/2026
1.2.3 10,452 9/20/2026
1.2.2 62,411 9/19/2026
1.2.0 11,335 5/13/2026
1.1.2 3,188 5/12/2026
1.1.1 1,032 5/3/2026
1.1.0 259 5/1/2026
1.0.1 300 4/29/2026
1.0.0 425 4/28/2026
0.1.6 3,333 4/28/2026
0.1.4 18,068 3/20/2026
0.1.3 144 3/19/2026
Loading failed