Mediarq.MediatRCompat 1.5.1

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

Mediarq.MediatRCompat

An optional compatibility shim so you can migrate to Mediarq incrementally: keep your existing MediatR.IRequest/IRequestHandler/INotification/INotificationHandler/IStreamRequest/ IStreamRequestHandler classes completely unchanged, wire them through Mediarq's own dispatch pipeline, and convert handlers to native Mediarq types file by file (e.g. with Mediarq.Analyzers) at your own pace.

dotnet add package Mediarq.MediatRCompat

Usage

Register it in addition to (after) AddMediarq/AddMediarqCore, which must already have configured Mediarq's own dispatch services:

builder.Services.AddMediarq(isHttp: true, typeof(Program).Assembly)
                 .AddMediarqMediatRCompat(typeof(Program).Assembly);

AddMediarqMediatRCompat scans the given assemblies for classes implementing MediatR's own IRequestHandler<,> / IRequestHandler<> / INotificationHandler<> / IStreamRequestHandler<,>, and registers each behind a MediatRCompatMediator that dispatches through Mediarq's real ISender/IPublisher — so your existing handlers run through the same pipeline behaviors (validation, logging, ...) as native Mediarq requests.

Inject MediatR.IMediator (or ISender/IPublisher) exactly as you did with MediatR — no source change needed in the classes that send requests or publish notifications, either:

public sealed class Ping(string Message) : MediatR.IRequest<string>;

public sealed class PingHandler : MediatR.IRequestHandler<Ping, string>
{
    public Task<string> Handle(Ping request, CancellationToken ct) => Task.FromResult(request.Message);
}

// Unchanged call site:
var response = await mediator.Send(new Ping("hi"));

The runtime-typed Send(object) / Publish(object) / CreateStream(object) overloads MediatR itself exposes are supported too (useful for generic infrastructure code that doesn't know the request type at compile time).

What isn't bridged

This shim covers requests, handlers, notifications and streaming — the same surface Mediarq.Analyzers' migration analyzer targets. It does not bridge MediatR's IPipelineBehavior<,>, IRequestPreProcessor<>/IRequestPostProcessor<,>, or IRequestExceptionHandler<,,>: their signatures differ enough from Mediarq's own that converting them is left as a manual step even in a full rewrite — see Migrating from MediatR. Write any new cross-cutting behavior directly against Mediarq's IPipelineBehavior<,>.

Note on performance

Because a MediatR-shaped request's concrete type is only known at runtime, dispatching it requires reflection once per concrete type (the result is cached — subsequent calls for the same type are reflection-free). This is an explicit migration/compatibility path, not the Native-AOT hot path: convert a handler to a native Mediarq type when you want fully reflection-free dispatch for it.

Learn more

Mediarq.Analyzers · Migrating from MediatR · Full README

MIT © Nicolas Rouffart

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.1 128 7/26/2026
1.5.0 111 7/26/2026
1.4.0 118 7/24/2026
1.3.0 111 7/24/2026