Resulver 2.0.1
See the version list below for details.
dotnet add package Resulver --version 2.0.1
NuGet\Install-Package Resulver -Version 2.0.1
<PackageReference Include="Resulver" Version="2.0.1" />
paket add Resulver --version 2.0.1
#r "nuget: Resulver, 2.0.1"
// Install Resulver as a Cake Addin #addin nuget:?package=Resulver&version=2.0.1 // Install Resulver as a Cake Tool #tool nuget:?package=Resulver&version=2.0.1
Table of Contents
Overview
Resulver
is a lightweight .NET library designed to simplify result handling in your application. It provides a clean,
structured way to return success results, messages, and errors without relying on exceptions for control flow. This
approach enhances code readability and improves performance by avoiding exception overhead.
Installation
To install Resulver
, use the following command in your terminal:
dotnet add package Resulver
Ensure that you have the required .NET SDK installed.
Usage
Here’s a simple example of how to use Resulver
to return and handle a result:
public Result<int> Sum(int a, int b)
{
// Perform the addition
var sum = a + b;
// Return the result wrapped in a Result object
return new Result<int>(sum);
}
public void Writer()
{
var result = Sum(3, 5);
// Access and display the result content
Console.WriteLine(result.Content);
}
Result Message
You can include custom messages in your results to provide additional context:
public Result<User> AddUser(User user)
{
// Implementation logic
return new Result<User>(user, message: "User Created");
}
public void Writer()
{
var user = new User();
var result = AddUser(user);
// Display the custom message
Console.WriteLine(result.Message);
}
Result Errors
Handle errors elegantly by using ResultError
classes:
public class UserNotFoundError : ResultError
{
public UserNotFoundError() : base("User not found") { }
}
public class UserIdIsNotValidError : ResultError
{
public UserIdIsNotValidError() : base("User ID is not valid") { }
}
public Result RemoveUser(int userId)
{
// Implementation logic
// Return a single error
return new UserNotFoundError();
// Or return multiple errors
return new Result(new UserNotFoundError(), new UserIdIsNotValidError());
}
public void Writer()
{
var result = RemoveUser(1);
// Check if the result is a failure
if (result.IsFailure)
{
foreach (var error in result.Errors)
{
// Display each error message
Console.WriteLine(error.Message);
}
}
}
Real-World Example
Handling user authentication:
public Result<User> Authenticate(string username, string password)
{
var user = _userRepository.Find(username, password);
if (user == null) return new UserNotFoundError();
return new Result<User>(user, message: "Authentication successful");
}
Best Practices
Here are some tips for working effectively with Resulver
:
Always Check
IsSuccess
orIsFailure
: Ensure you validate the state of the result before accessing its content or errors.Use Meaningful Messages and Errors: Provide clear and specific messages to make debugging easier.
Avoid Mixing Exceptions and Results: Stick to the
Result
pattern for predictable and consistent flow control.Combine Multiple Errors When Needed: Utilize the flexibility of
Result
to handle and return multiple errors when necessary.
By following these practices, you can make the most out of Resulver
and write cleaner, more maintainable code.
Product | Versions 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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Resulver:
Package | Downloads |
---|---|
Valobtify
A package for implementing the 'Value Object' pattern. |
|
Resulver.AspNetCore.WebApi
Clean implementation of Result Pattern and error handling for Asp Core Web API applications |
|
Valobtify.AspNetCore.WebApi
A package for handling value objects in ASP.NET Core Web API with automatic mapping. |
|
Resulver.AspNetCore.Core
this is core of Resulver.AspNetCore packages |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 53 | 1/16/2025 |
2.0.1 | 91 | 12/5/2024 |
2.0.0 | 217 | 11/6/2024 |
1.2.5 | 383 | 10/3/2024 |
1.2.4 | 172 | 8/20/2024 |
1.2.3 | 125 | 8/20/2024 |
1.2.2 | 126 | 8/19/2024 |
1.2.1 | 122 | 7/13/2024 |
1.2.0 | 113 | 7/13/2024 |
1.1.7 | 132 | 6/28/2024 |
1.1.6 | 127 | 6/13/2024 |
1.1.5 | 116 | 6/12/2024 |
1.1.4 | 119 | 6/12/2024 |
1.1.3 | 124 | 6/11/2024 |
1.1.2 | 104 | 6/11/2024 |
1.1.1 | 106 | 6/11/2024 |
1.1.0 | 102 | 6/11/2024 |
1.0.6 | 104 | 6/10/2024 |
1.0.5 | 154 | 5/17/2024 |
1.0.4 | 177 | 5/17/2024 |
1.0.3 | 136 | 5/17/2024 |
1.0.2 | 141 | 5/17/2024 |
1.0.1 | 126 | 5/16/2024 |
1.0.0 | 160 | 5/4/2024 |