Desfecho.AspNetCore 1.1.0

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

Desfecho

CI CD NuGet NuGet License

A simple and lightweight Result pattern implementation for .NET.

dotnet add package Desfecho
dotnet add package Desfecho.AspNetCore

Why

Stop throwing exceptions for expected failures. Return a Result<TValue> instead — it's either a value or one or more Errors.

public Result<TodoItem> CompleteTodoItem(Guid id)
{
    var todoItem = _todoItems.Find(id);

    if (todoItem is null)
    {
        return Error.NotFound("TodoItem.NotFound", $"Todo item '{id}' was not found.");
    }

    todoItem.Complete();
    return todoItem;
}

var result = CompleteTodoItem(id);

var message = result.Match(
    todoItem => $"Completed '{todoItem.Title}'.",
    errors => errors[0].Description);

Result<TValue> converts implicitly from TValue, Error and List<Error>, so returning one is all you need — no wrapping, no new.

Errors

An Error is a Code, a Description, and a Type:

Error.Validation("TodoItem.Title", "Title is required.");
Error.Unauthorized("TodoItem.Unauthorized", "Authentication is required.");
Error.Forbidden("TodoItem.Forbidden", "You do not have access to this todo item.");
Error.NotFound("TodoItem.NotFound", "Todo item was not found.");
Error.Conflict("TodoItem.Conflict", "Todo item already exists.");

Type is one of Validation, Unauthorized, Forbidden, NotFound or Conflict — used by Desfecho.AspNetCore to pick an HTTP status code.

ASP.NET Core

Desfecho.AspNetCore turns a Result<TValue> into a minimal API IResult, mapping errors to ProblemDetails (Validation → 400, Unauthorized → 401, Forbidden → 403, NotFound → 404, Conflict → 409).

app.MapPost("/todo-items", async (CreateTodoItemRequest request, ISender sender, CancellationToken ct) =>
{
    var result = await sender.Send(new CreateTodoItemCommand(request.TodoListId, request.Title), ct);
    return result.ToCreated(value => $"/todo-items/{value.Id}");
});

ToOk(), ToCreated(location) and ToNoContent() cover the common cases; errors.ToProblem() is available directly for anything else.

Packages

Package Contents
Desfecho Result<TValue>, Error, ErrorType
Desfecho.AspNetCore Result<TValue> → minimal API IResult

License

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.

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.1.0 102 9/7/2026
1.0.0 92 8/31/2026