Tolitech.Results
1.0.0-preview.10
dotnet add package Tolitech.Results --version 1.0.0-preview.10
NuGet\Install-Package Tolitech.Results -Version 1.0.0-preview.10
<PackageReference Include="Tolitech.Results" Version="1.0.0-preview.10" />
<PackageVersion Include="Tolitech.Results" Version="1.0.0-preview.10" />
<PackageReference Include="Tolitech.Results" />
paket add Tolitech.Results --version 1.0.0-preview.10
#r "nuget: Tolitech.Results, 1.0.0-preview.10"
#:package Tolitech.Results@1.0.0-preview.10
#addin nuget:?package=Tolitech.Results&version=1.0.0-preview.10&prerelease
#tool nuget:?package=Tolitech.Results&version=1.0.0-preview.10&prerelease
Tolitech.Results
Tolitech.Results is the core Results pattern library for .NET, enabling you to encapsulate operation outcomes, errors, messages, and metadata in a structured and predictable way.
Features
- Encapsulates success, failure, and error in operations.
- Rich metadata: title, detail, type, status code, messages.
- Factory methods for all major HTTP statuses and business scenarios.
- Fluent API for adding messages, titles, details, and errors.
- Support for generic results (
Result<T>).
Usage Examples
Success Result
IResult result = Result.OK();
IResult resultWithValue = Result<int>.OK(42);
Error Result with Details
var result = Result.BadRequest(
"Validation Error",
"The 'Name' field is required.")
.AddError("Name not provided");
Available Factory Methods
OK(),OK<T>(T value)Created(),Created<T>(T value)Accepted(),Accepted<T>(T value)NoContent(),NoContent<T>()Found(),Found<T>(T value)NotModified(),NotModified<T>(T value)BadRequest(),BadRequest(string detail),BadRequest(string title, string detail)Unauthorized(),Unauthorized(string detail),Unauthorized(string title, string detail)Forbidden(),Forbidden(string detail),Forbidden(string title, string detail)NotFound(),NotFound(string detail),NotFound(string title, string detail)Conflict(),Conflict(string detail),Conflict(string title, string detail)InternalServerError(),InternalServerError(string detail),InternalServerError(string title, string detail)
Message Handling
result.AddError("Unexpected error.", StatusCode.InternalServerError);
Important Properties
IsSuccess,IsFailureStatusCode,Title,Detail,TypeMessages(collection of messages associated with the result)
Complete Example
public class MathOperation
{
public IResult<int> Divide(int dividend, int divisor)
{
if (divisor == 0)
return Result.BadRequest<int>()
.WithTitle("Division by zero not allowed")
.AddError("The divisor cannot be zero.");
return Result.OK(dividend / divisor);
}
}
For HTTP integration and fluent validations, see the Tolitech.Results.Http and Tolitech.Results.Guards projects.
| Product | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Tolitech.Results:
| Package | Downloads |
|---|---|
|
Tolitech.Results.Guards
Tolitech.Results.Guards is a utility library that provides fluent and expressive guard clauses for result-oriented programming. |
|
|
Tolitech.Application
The Application repository provides the Unit of Work interface within the Clean Architecture context. |
|
|
Tolitech.Results.Http
This package provides extension methods for handling HTTP responses in .NET applications, facilitating the extraction and mapping of relevant data from HttpResponseMessage objects into Result objects. |
|
|
Tolitech.Domain
The Domain layer is the heart of your application, encompassing essential business logic and entities. |
|
|
Tolitech.HttpClients
Generic HTTP client implementation for .NET, based on Tolitech.HttpClients.Abstractions, with full support for JSON and custom headers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.10 | 138 | 10/30/2025 |
| 1.0.0-preview.9 | 151 | 9/22/2025 |
| 1.0.0-preview.8 | 144 | 9/20/2025 |
| 1.0.0-preview.7 | 175 | 9/19/2025 |
| 1.0.0-preview.6 | 344 | 7/25/2025 |
| 1.0.0-preview.5 | 130 | 7/17/2025 |
| 1.0.0-preview.4 | 175 | 7/1/2025 |
| 1.0.0-preview.3 | 169 | 1/7/2025 |
| 1.0.0-preview.2 | 76 | 1/7/2025 |
| 1.0.0-preview.1 | 165 | 12/6/2024 |