Relevox
GitHub · Docs · Changelog · Moving from MediatR
A mediator for .NET whose dispatch is written by a source generator at build time, with the same handler signatures as MediatR 12. MIT licensed, no licence key, no telemetry.
dotnet add package Relevox # the application, which calls AddRelevox
dotnet add package Relevox.Contracts # libraries that only declare requests and handlers
dotnet add package Relevox.Testing # test projects: a fake mediator and a notification recorder
dotnet add package Relevox.FluentValidation # a validation behaviour, only for requests with a validator
dotnet add package Relevox.MediatRBridge # MediatR and Relevox side by side while a solution moves

- Same signatures as MediatR 12. Requests, notifications, streams, pipeline behaviours, pre and post
processors, exception handlers and actions. Moving over changes packages,
usingdirectives and the registration call. - Dispatch decided at build time. No assembly scanning. A request with no handler, or with two, is reported by the compiler.
- NativeAOT and trimming without annotations.
- Faster than MediatR 12.5: a send takes under half the time through
ISenderand a quarter through the generated mediator; startup takes a twenty-fifth. Every number is measured and published with the hardware named.
Packages
| Package | Reference it from |
|---|---|
Relevox | The application, the project that calls AddRelevox. It brings the source generator. |
Relevox.Contracts | Projects that only declare requests and handlers: domain, application, feature libraries. |
Relevox.Testing | Test projects: a fake IMediator and a recorder for published notifications (testing.md). |
Relevox.FluentValidation | The application, for FluentValidation validators: the build gives the behaviour only to the requests that have one (validation.md). |
Relevox.MediatRBridge | The application, while it moves from MediatR one feature at a time: MediatR's interfaces send each message to the library that has its handler (migration.md). |
Quick start
using Relevox;
builder.Services.AddRelevox();
public sealed record GetOrder(int Id) : IRequest<Order>;
public sealed class GetOrderHandler(OrderStore store) : IRequestHandler<GetOrder, Order>
{
public Task<Order> Handle(GetOrder request, CancellationToken cancellationToken) =>
store.FindAsync(request.Id, cancellationToken);
}
// Anywhere ISender, IPublisher or IMediator is injected:
Order order = await sender.Send(new GetOrder(42), cancellationToken);
Handlers are found in the application and in every referenced project that uses Relevox.Contracts.
From MediatR 12
- Replace the
MediatRpackage withRelevoxin the application and withRelevox.Contractselsewhere. - Replace
using MediatR;withusing Relevox;andusing MediatR.Pipeline;withusing Relevox.Pipeline;. - Replace
AddMediatR(cfg => cfg.RegisterServicesFromAssembly(...))withAddRelevox(). Behaviours, processors and lifetimes are configured with the same members as before.
In an IDE, steps 2 and 3 are a code fix: after the package swap, apply Move from MediatR to Relevox to the
whole solution. From the command line it is dotnet format analyzers --diagnostics RVX0007 --severity info.
- Migration guide
- What matches MediatR, and what differs on purpose
- Diagnostics
- Source, issues and samples
Packages
| Package | Version | Downloads |
|---|---|---|
| Relevox.Contracts | 1.7.0 | 3,059 |
| Relevox | 1.7.0 | 2,854 |
| Relevox.Testing | 1.7.0 | 1,765 |
| Relevox.FluentValidation | 1.7.0 | 762 |
| Relevox.MediatRBridge | 1.7.0 | 326 |