ErrorApi.CSharpFunctionalExtensions 1.0.1

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

ErrorApi

ErrorApi.CSharpFunctionalExtensions

Maps CSharpFunctionalExtensions onto Minimal API results and ErrorApi's documented error catalog: every endpoint's OpenAPI document lists the failures it can actually return, and the wire response carries a stable machine-readable code — resolved at compile time by the ErrorApi source generator, with no reflection at runtime.

dotnet add package ErrorApi.CSharpFunctionalExtensions

The package brings the generator with it (PrivateAssets="none"), so referencing the adapter is the whole setup.

Before

A Result<T, E> maps to a response at runtime, in a mapper you wrote yourself — and the OpenAPI document never learns about it:

public Result<Order, OrderError> GetById(Guid id) =>
    _orders.TryGetValue(id, out var order) ? order : new OrderNotFound(id);

app.MapGet("/orders/{id:guid}", (Guid id, IOrderService s) =>
    s.GetById(id).Match(Results.Ok, e => Results.NotFound()));   // hand-rolled, per endpoint
// Document: 200 OK. The 404 exists — the frontend meets it in production.

After

Result<T, E> is the sweet spot for ErrorApi, because the failure already is a type of your own — that is exactly where the catalog entry goes:

public abstract record OrderError;

[ErrorApi.Error("Orders.NotFound", 404, Title = "Order not found")]
public sealed record OrderNotFound(Guid Id) : OrderError;

public Result<Order, OrderError> GetById(Guid id) =>
    _orders.TryGetValue(out var order) ? order : new OrderNotFound(id);

builder.Services.AddErrorApi();
app.MapGet("/orders/{id:guid}", (Guid id, IOrderService s) => s.GetById(id).ToHttpResult());
// Document: 200 + 404 with code "Orders.NotFound", title, and an example body.
// Wire:     { "title": "Order not found", "status": 404, "code": "Orders.NotFound" }

The generator documents the endpoint wherever it sees a case constructed; at runtime the instance resolves through a generated pattern switch — no reflection, native-AOT clean.

The whole surface

shape success failure
Result<T, E>.ToHttpResult() 200 with the value ProblemDetails from E
Result<T, E>.ToCreated(...) / ToCreatedAtUri(...) 201 ProblemDetails
Result<T, E>.ToNoContentResult() 204 ProblemDetails
UnitResult<E>.ToHttpResult() 204 ProblemDetails
Result.ToHttpResult() / Result<T>.ToHttpResult() 204 / 200 see below

A string-error Result<T> resolves only when the string is a known catalog code; anything else answers as a 500 carrying the message — deliberately unhelpful as a contract, because a message is not one. Prefer Result<T, E>.

Versions

Pinned to the CSharpFunctionalExtensions version in this repository's Directory.Packages.props; the test suite also runs against older releases in CI (-p:CfeTestVersion=x.y.z).

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 96 8/31/2026
1.0.0 91 8/30/2026