MaksIT.Results 2.0.1

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

MaksIT.Results

Line Coverage Branch Coverage Method Coverage

MaksIT.Results is a .NET library for modeling operation outcomes as HTTP-aware result objects and converting them to IActionResult in ASP.NET Core.

Features

  • Result and Result<T> models with status code, success flag, and messages.
  • Static factory methods for common and extended HTTP status codes (1xx, 2xx, 3xx, 4xx, 5xx).
  • Built-in conversion to IActionResult via ToActionResult().
  • RFC 7807-style error payloads for failures (application/problem+json).
  • Camel-case JSON serialization for response bodies; respects app-configured JsonSerializerOptions (e.g. AddJsonOptions with DefaultIgnoreCondition.WhenWritingNull).

Installation

Package Manager:

Install-Package MaksIT.Results

dotnet CLI:

dotnet add package MaksIT.Results

Target Framework

  • .NET 10 (net10.0)

Quick Start

Create results

using MaksIT.Results;

Result ok = Result.Ok("Operation completed");
Result failed = Result.BadRequest("Validation failed");

Result<int> okWithValue = Result<int>.Ok(42, "Answer generated");
Result<string?> notFound = Result<string?>.NotFound(null, "Entity not found");

Convert between result types

using MaksIT.Results;

Result<int> source = Result<int>.Ok(42, "Value loaded");

// Result<T> -> Result<U>
Result<string?> mapped = source.ToResultOfType(v => v?.ToString());

// Result<T> -> Result
Result nonGeneric = source.ToResult();

Use in an ASP.NET Core controller

using MaksIT.Results;
using Microsoft.AspNetCore.Mvc;

public sealed class UsersController : ControllerBase {
  [HttpGet("{id:guid}")]
  public IActionResult GetUser(Guid id) {
    Result<UserDto?> result = id == Guid.Empty
      ? Result<UserDto?>.BadRequest(null, "Invalid id")
      : Result<UserDto?>.Ok(new UserDto(id, "maks"), "User loaded");

    return result.ToActionResult();
  }
}

public sealed record UserDto(Guid Id, string Name);

ToActionResult() Behavior

  • Result success: returns status-code-only response.
  • Result<T> success with non-null Value: returns JSON body + status code.
  • Any failure: returns RFC 7807-style ProblemDetails JSON with:
    • status = result status code
    • title = "An error occurred"
    • detail = joined Messages
    • content type application/problem+json

JSON options

ObjectResult uses the same JsonSerializerOptions as your app when you configure them with AddJsonOptions:

builder.Services.AddControllers()
  .AddJsonOptions(options => {
    options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
  });

If no options are registered, a default (camel-case) serializer is used.

Status Code Factories

  • Informational: Result.Continue(...), Result.SwitchingProtocols(...), Result.Processing(...), etc.
  • Success: Result.Ok(...), Result.Created(...), Result.NoContent(...), etc.
  • Redirection: Result.Found(...), Result.PermanentRedirect(...), etc.
  • Client error: Result.BadRequest(...), Result.NotFound(...), Result.TooManyRequests(...), etc.
  • Server error: Result.InternalServerError(...), Result.ServiceUnavailable(...), etc.

Generic equivalents are available via Result<T>, for example Result<MyDto>.Ok(value, "message").

Contributing

See CONTRIBUTING.md.

Contact

If you have any questions or need further assistance, feel free to reach out:

License

See LICENSE.md.

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 (2)

Showing the top 2 NuGet packages that depend on MaksIT.Results:

Package Downloads
MaksIT.MongoDB.Linq

MaksIT.MongoDB.Linq is a .NET library designed to facilitate working with MongoDB using LINQ queries, providing a seamless and intuitive interface for developers to interact with MongoDB databases. The library abstracts common data access patterns, allowing for more efficient and readable code when performing CRUD operations, managing sessions, and handling transactions.

MaksIT.Dapr

MaksIT.Dapr is a facade library for Dapr.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 105 3/8/2026
2.0.0 110 2/22/2026
1.1.1 213 11/3/2025
1.1.0 189 11/2/2025
1.0.9 139 10/31/2025
1.0.8 134 10/31/2025
1.0.7 199 10/29/2025
1.0.6 371 5/5/2025
1.0.5 300 9/28/2024
1.0.4 169 9/28/2024
1.0.3 169 9/28/2024
1.0.2 159 9/28/2024
1.0.1 171 9/28/2024
1.0.0 249 8/30/2024