CleanArch.DevKit.Mediator 0.1.0-preview.1

This is a prerelease version of CleanArch.DevKit.Mediator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CleanArch.DevKit.Mediator --version 0.1.0-preview.1
                    
NuGet\Install-Package CleanArch.DevKit.Mediator -Version 0.1.0-preview.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="CleanArch.DevKit.Mediator" Version="0.1.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CleanArch.DevKit.Mediator" Version="0.1.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="CleanArch.DevKit.Mediator" />
                    
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 CleanArch.DevKit.Mediator --version 0.1.0-preview.1
                    
#r "nuget: CleanArch.DevKit.Mediator, 0.1.0-preview.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 CleanArch.DevKit.Mediator@0.1.0-preview.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=CleanArch.DevKit.Mediator&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CleanArch.DevKit.Mediator&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Tool

CleanArch.DevKit.Mediator

Source-generated mediator for .NET 10. Zero-reflection dispatch of IRequest<T>, INotification, and IStreamRequest<T>. The Roslyn generator ships inside the package as an analyzer asset — no separate install.

Part of the CleanArch.DevKit toolkit.

Install

dotnet add package CleanArch.DevKit.Mediator

Quick start

// 1. Declare an empty partial class — the generator fills it in.
namespace MyApp;
public partial class Mediator { }

// 2. Define a request and its handler.
public sealed record Ping(string Message) : IRequest<string>;

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

// 3. Wire it up.
var services = new ServiceCollection();
services.AddMediator();

await using var provider = services.BuildServiceProvider();
var mediator = provider.GetRequiredService<IMediator>();

var response = await mediator.Send(new Ping("hello"));

Primitives

Interface Purpose
IRequest<TResponse> Command/query — single handler, returns a response
INotification Event — zero, one, or many handlers, no response
IStreamRequest<TResponse> Streaming query — single handler, yields IAsyncEnumerable<TResponse>
// Send a request
var result = await mediator.Send(new GetUser(id));

// Publish a notification (Sequential by default; opt into Parallel via AddMediator options)
await mediator.Publish(new UserCreated(id));

// Consume a stream
await foreach (var item in mediator.CreateStream(new Count(5), ct))
    Console.WriteLine(item);

Pipeline behaviors

Plug cross-cutting concerns via IPipelineBehavior<TRequest, TResponse> registered as open generics. See CleanArch.DevKit.Mediator.Behaviors for ready-made Logging / Performance / UnhandledException behaviors.

Diagnostics

Code Severity Meaning
MED001 Error A request type has no matching handler
MED002 Error More than one handler is registered for the same request
MED003 Error partial class Mediator is missing from the consumer assembly

License

MIT — see LICENSE.

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

NuGet packages (5)

Showing the top 5 NuGet packages that depend on CleanArch.DevKit.Mediator:

Package Downloads
CleanArch.DevKit.Mediator.Validation

Source-generated fluent validation with a ValidationBehavior pipeline. Bridges to CleanArch.DevKit.Mediator. Part of the CleanArch.DevKit set.

CleanArch.DevKit.Mediator.Results

Result<T> + Error model with railway-oriented extensions (Map / Bind / Match) and a ResultBehavior that auto-converts ValidationException into a ValidationError. Part of the CleanArch.DevKit set.

CleanArch.DevKit.Mediator.Domain

Bridge between CleanArch.DevKit.Domain and CleanArch.DevKit.Mediator: IDomainEventNotification (combines IDomainEvent + INotification) and a typed PublishDomainEventsAsync extension on IMediator. Install this only if you use both Domain and Mediator together. Part of the CleanArch.DevKit set.

CleanArch.DevKit.Mediator.Behaviors

Common pipeline behaviors (LoggingBehavior, PerformanceBehavior, UnhandledExceptionBehavior) for CleanArch.DevKit.Mediator. Part of the CleanArch.DevKit set.

CleanArch.DevKit.Mediator.Testing

Mock-free testing helpers for CleanArch.DevKit.Mediator. FakeMediator with fluent setup and recording for IRequest, INotification and IStreamRequest. Part of the CleanArch.DevKit set.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 146 5/17/2026
1.1.0 131 5/17/2026
1.0.0 152 5/15/2026
0.1.0-preview.1 67 5/14/2026