EricksonLopez.Mediator Overview
EricksonLopez.Mediator (2.0.0 on NuGet, L2) is a source-generated CQRS mediator delivering ValueTask-based command, query, notification, and stream dispatch without runtime reflection or MediatR-style dynamic casting.
- Source-generated DI & dispatch (
EricksonLopez.Mediator.Generator): EmitsAddEricksonLopezMediator()and strongly-typed handler wiring at compile time alongsideELM001–ELM013diagnostics. - Zero-allocation pipeline continuations:
IPipelineBehavior<in TRequest, TResponse>constrainswhere TNext : struct, INext<TResponse>so nested behaviors invokenext.InvokeAsync()without closure heap allocations. - Explicit
StaticMediator& recursion guard:StaticMediatorsupports zero-DI AOT registration (Freeze(),SendCommand,SendQuery,Publish), whileMaxRecursionDepthBehaviorprevents unbounded self-dispatch. - Deprecated Polly bridge (
v2.0.0):EricksonLopez.Mediator.Pollyis marked[Obsolete](ADR-036) — useEricksonLopez.Resilience.Mediatorinstead.
Rendering diagram…
flowchart LR App["Caller -> ISender"] --> Gen["Generated Dispatch (Scoped)"] Gen --> B1["IPipelineBehavior<TReq, TRes> (INext<TRes> struct)"] B1 -- next.InvokeAsync() --> H["ICommandHandler / IQueryHandler -> ValueTask<TRes>"]
View accessible text summary and structure
ISender routes commands and queries through struct-constrained IPipelineBehavior continuations (next.InvokeAsync()) into source-generated ICommandHandler or IQueryHandler instances.
flowchart LR
App["Caller -> ISender"] --> Gen["Generated Dispatch (Scoped)"]
Gen --> B1["IPipelineBehavior<TReq, TRes> (INext<TRes> struct)"]
B1 -- next.InvokeAsync() --> H["ICommandHandler / IQueryHandler -> ValueTask<TRes>"]Package Roster & Native AOT Status (9 / 10 Published)
Section titled “Package Roster & Native AOT Status (9 / 10 Published)”9 of 10 packages are published at 2.0.0 on NuGet (7,953 total downloads; localVersion: 3.2.0 on disk), while EricksonLopez.Mediator.Caching remains unpublished (3.2.0 local only). Overall AOT status is Partial (8 Full, 1 Incompatible, 1 NotApplicable):
| Package | NuGet (2.0.0) |
AOT Status | TFMs | Role |
|---|---|---|---|---|
EricksonLopez.Mediator |
Published (5,569 dl) |
Full |
net8.0;net9.0;net10.0 |
ISender, IPublisher, StaticMediator, MaxRecursionDepthBehavior, MediatorHealthCheck |
EricksonLopez.Mediator.Generator |
Published (247 dl) |
NotApplicable |
netstandard2.0 |
Incremental generator emitting AddEricksonLopezMediator() + analyzers |
EricksonLopez.Mediator.OpenTelemetry |
Published (409 dl) |
Full |
net8.0;net9.0;net10.0 |
AddMediatorOpenTelemetry, MediatorMetrics |
EricksonLopez.Mediator.FluentValidation |
Published (332 dl) |
Incompatible |
net8.0;net9.0;net10.0 |
IsAotCompatible=false (assembly scanning uses [RequiresUnreferencedCode]; generic validator registration is AOT-safe) |
EricksonLopez.Mediator.Testing |
Published (298 dl) |
Full |
net8.0;net9.0;net10.0 |
FakeMediator, DelegateNext, MediatorPipelineParityVerifier |
EricksonLopez.Mediator.Result |
Published (292 dl) |
Full |
net8.0;net9.0;net10.0 |
IResultFactory<TResponse>, InputSafetyPipelineBehavior<,> |
EricksonLopez.Mediator.RateLimiting |
Published (283 dl) |
Full |
net8.0;net9.0;net10.0 |
AddMediatorRateLimiting via System.Threading.RateLimiting |
EricksonLopez.Mediator.AspNetCore |
Published (262 dl) |
Full |
net8.0;net9.0;net10.0 |
MapCommand / MapQuery Minimal API endpoints |
EricksonLopez.Mediator.Polly |
Published (261 dl) |
Full |
net8.0;net9.0;net10.0 |
Deprecated ([Obsolete]) — migrate to EricksonLopez.Resilience.Mediator |
EricksonLopez.Mediator.Caching |
Unpublished | Full |
net8.0;net9.0;net10.0 |
Local workspace 3.2.0 only (ICacheableRequest, AddMediatorCaching) |
Measured directly from BenchmarkDotNet.Artifacts (38 measured rows, 0 na_error rows) across .NET 8.0.31, .NET 9.0.20, .NET 10.0.10, and .NET 10.0.12 X64 RyuJIT (no NativeAOT reports):
MediatorBenchmarks.DirectCall: 0.1769 ns / 0 B (.NET 10.0.10RyuJITx86-64-v4)MediatorBenchmarks.SendCommand_NoBehaviors: 11.1858 ns / 24 B (.NET 10.0.10RyuJITx86-64-v4)MediatorBenchmarks.SendQuery_NoBehaviors: 15.6645 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.SendCommand_OneBehavior: 47.1593 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.SendCommand_FiveBehaviors: 183.9336 ns / 0 B (.NET 10.0.12RyuJITx86-64-v3)MediatorBenchmarks.PublishNotification_OneHandler: 40.3239 ns / 24 B (FiveHandlers: 199.3251 ns / 120 B;Parallel: 183.3404 ns / 192 B)