CleanArch.DevKit.Mediator
0.1.0-preview.1
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
<PackageReference Include="CleanArch.DevKit.Mediator" Version="0.1.0-preview.1" />
<PackageVersion Include="CleanArch.DevKit.Mediator" Version="0.1.0-preview.1" />
<PackageReference Include="CleanArch.DevKit.Mediator" />
paket add CleanArch.DevKit.Mediator --version 0.1.0-preview.1
#r "nuget: CleanArch.DevKit.Mediator, 0.1.0-preview.1"
#:package CleanArch.DevKit.Mediator@0.1.0-preview.1
#addin nuget:?package=CleanArch.DevKit.Mediator&version=0.1.0-preview.1&prerelease
#tool nuget:?package=CleanArch.DevKit.Mediator&version=0.1.0-preview.1&prerelease
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 | Versions 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. |
-
net10.0
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 |