-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Alan Barber edited this page Jan 3, 2026
·
5 revisions
Welcome to the ResultR wiki! This documentation covers everything you need to know to use ResultR effectively in your .NET applications.
ResultR is a lightweight request/response dispatcher for .NET. It routes requests to handlers and wraps all responses in a Result<T> type for consistent success/failure handling.
Request → Dispatcher → Handler → Result<T>
| Concept | Description |
|---|---|
| Request | A simple class/record implementing IRequest<TResponse> (or IRequest for void operations) that carries data to a handler |
| Handler | A class implementing IRequestHandler<TRequest, TResponse> (or IRequestHandler<TRequest> for void operations) that processes requests |
| Dispatcher | Routes requests to their corresponding handlers via dependency injection |
| Result | A wrapper type that represents either success (with a value) or failure (with an error) |
Every request flows through a predictable pipeline:
Validate → BeforeHandle → Handle → AfterHandle
↓ ↓ ↓ ↓
(optional) (optional) (required) (optional)
-
ValidateAsync - Return
Result.Failure()to short-circuit before handling - BeforeHandleAsync - Run setup logic (logging, etc.)
- HandleAsync - Your core business logic
- AfterHandleAsync - Run cleanup logic (logging, metrics, etc.)
// 1. Define a request
public record GetUserRequest(int Id) : IRequest<User>;
// 2. Create a handler
public class GetUserHandler : IRequestHandler<GetUserRequest, User>
{
public async ValueTask<Result<User>> HandleAsync(
GetUserRequest request,
CancellationToken cancellationToken)
{
var user = await _repository.GetByIdAsync(request.Id, cancellationToken);
return user is not null
? Result<User>.Success(user)
: Result<User>.Failure("User not found");
}
}
// 3. Dispatch the request
var result = await _dispatcher.Dispatch(new GetUserRequest(123));
if (result.IsSuccess)
Console.WriteLine($"Found: {result.Value.Name}");
else
Console.WriteLine($"Error: {result.Error}");- Getting Started - Installation and basic setup
- Requests and Handlers - Creating requests and handlers
- The Result Type - Working with success and failure states
- Pipeline Hooks - Validation, before/after handling
- Dependency Injection - Registering with DI containers
- Error Handling - Exception handling and failure patterns
- Best Practices - Recommended patterns and conventions
- ResultR.Validation - Inline validation with fluent API
- ResultR.VSToolkit - Visual Studio extension for navigation and scaffolding
- ResultR.VSCodeToolkit - VS Code extension for navigation and scaffolding
- .NET 10.0 or later
- C# 14.0 or later
Built with ❤️ for the C# / DotNet community.