Relevox.Contracts 1.7.0

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

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

Send runs the pipeline of behaviours and processors, then the one handler found at build time, and returns the response. Publish hands the notification to the publisher, which runs every handler in order. CreateStream runs the stream behaviours around the one stream handler and returns an IAsyncEnumerable.

  • Same signatures as MediatR 12. Requests, notifications, streams, pipeline behaviours, pre and post processors, exception handlers and actions. Moving over changes packages, using directives 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 ISender and 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

  1. Replace the MediatR package with Relevox in the application and with Relevox.Contracts elsewhere.
  2. Replace using MediatR; with using Relevox; and using MediatR.Pipeline; with using Relevox.Pipeline;.
  3. Replace AddMediatR(cfg => cfg.RegisterServicesFromAssembly(...)) with AddRelevox(). 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.

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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Relevox.Contracts:

Package Downloads
Relevox

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.

Relevox.MediatRBridge

Runs MediatR and Relevox side by side: MediatR's IMediator, ISender and IPublisher send each message to whichever library has its handler, so a solution can move to Relevox one feature at a time.

GitHub repositories

This package is not used by any popular GitHub repositories.