ResultKit 9.0.2

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

<div align="center"> <img src="../../assets/logo-1250x1250.png" width="120" alt="ResultKit logo" /> <h1>ResultKit</h1> <b>Strongly-Typed, Unified Result Pattern for .NET APIs and Applications</b> </div>


Overview

ResultKit brings a simple but powerful pattern for representing the outcome of any operation in .NET. By wrapping your logic with Result or Result<T>, you can handle success, errors, validation failures, or exceptions—always in a type-safe and explicit way.
ResultKit is especially valuable in modern APIs: it encourages unified responses, making error handling and frontend integration easier than ever.


Installation

dotnet add package ResultKit

Core Usage

Service Layer Example
using ResultKit;

// Basic success or failure
Result ok = Result.Success();
Result fail = Result.Failure(new Error(ErrorCodes.Validation, "Validation failed"));

// Validation failure
var validation = Result.ValidationFailure(new[]
{
    new ValidationError("Field", "Invalid value")
});

// Strongly-typed success
Result<string> value = Result<string>.Success("foo");

// Implicit conversion
Result<string> implicitOk = "hello"; // treated as Success

Functional Helpers

  • Map: Transform the value if success
  • Bind: Chain operations that each return a Result
  • Match: Handle both success and error cases in a single expression
var upper = value.Map(x => x.ToUpper());
var chained = value.Bind(s => Result<int>.Success(s.Length));
var resultText = value.Match(
    onSuccess: s => $"OK: {s}",
    onFailure: error => $"Failed: {error.Message}"
);

ASP.NET Core API Integration

ResultKit makes returning consistent HTTP responses trivial:

[HttpPost]
public ActionResult<Result<UserDto>> CreateUser(UserDto dto)
{
    if (string.IsNullOrWhiteSpace(dto.Name))
    {
        return Result<UserDto>.ValidationFailure(new[]
        {
            new ValidationError(nameof(dto.Name), "Name is required")
        }).ToActionResult();
    }

    // Simulate user creation
    var created = new UserDto { Name = dto.Name };
    return Result<UserDto>.Success(created).ToActionResult();
}
  • 200 OK for success
  • 400 Bad Request for validation errors
  • 404 Not Found for not found errors
  • 401 Unauthorized, 409 Conflict, etc. (mapped automatically)
  • The client/frontend always receives a uniform JSON shape—making client code simpler and more reliable

Core Components

  • Result / Result<T>: Wraps success or failure, and (on success) carries a value.
  • Error: Standard error with code and message.
  • ValidationError: Field-specific validation error info.
  • Functional Extensions: Map, Bind, Match, and more.

Why Standardized Responses Matter

ResultKit makes it easy to build APIs that always return the same response shape—regardless of success or error. This means your frontend or client apps can handle results with confidence and less boilerplate:

// Success response (with value)
{
  "isSuccess": true,
  "value": {
    "id": 42,
    "name": "Jane Doe",
    "email": "jane@example.com"
  }
}

// Success response
{
  "isSuccess": true,
  "value": 123
}

// Error response (not found)
{
  "isSuccess": false,
  "error": { "code": "NOT_FOUND", "message": "User not found" }
}

📜 License

MIT © Ataberk Kaya

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.

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
9.0.2 157 6/4/2025
9.0.1 154 6/1/2025

Initial v9.0.1 public release. Typed Result, error/validation, extension methods, implicit support, WebAPI helper.