EricksonLopez.Mediator
dotnet-mediator · CQRS & Messaging
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
High-throughput, zero-allocation CQRS mediator ecosystem for modern .NET (8, 9, 10). Features Roslyn compile-time dispatch, Native AOT-ready core (Partial across sub-packages), and zero-overhead pipeline extensions for caching, telemetry, and validation.
Reflection-based mediators allocate handler wrappers and dynamic delegate chains per request, blurring Command vs Query contracts and failing strict Native AOT builds.
3. Quick Install#
Primary package: EricksonLopez.Mediator
dotnet add package EricksonLopez.Mediator --version 2.0.0<PackageReference Include="EricksonLopez.Mediator" Version="2.0.0" /><PackageVersion Include="EricksonLopez.Mediator" Version="2.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You want CQRS segregated ICommand<T> / IQuery<T> / INotification contracts with Roslyn-generated monomorphized dispatch.
When NOT to use
- Your handlers only emit simple fire-and-forget domain events without request/response pipelines—use EricksonLopez.Events.
6. Core Capabilities & Design Invariants#
Segregated CQRS Contracts
Enforces ICommand<T>, IQuery<T>, and INotification boundaries with 13 Roslyn analyzers (ELM001–ELM013).
Struct Pipeline Continuations & Adapters
Constraint-based INext<TResponse> continuations plus adapters for Caching, OpenTelemetry, Polly, Minimal APIs, and FluentValidation.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.MediatorPrimary | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 5,569 | High-performance, zero-allocation, AOT-compatible mediator pattern implementation for .NET 10. |
| EricksonLopez.Mediator.OpenTelemetry | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 409 | OpenTelemetry distributed tracing and metrics instrumentation for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.FluentValidation | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 332 | FluentValidation pipeline behavior and extensions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Testing | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 298 | In-memory FakeMediator and testing doubles for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Result | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 292 | Result pattern integration and pipeline short-circuiting abstractions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.RateLimiting | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 283 | Rate limiting pipeline behavior for EricksonLopez.Mediator based on System.Threading.RateLimiting. |
| EricksonLopez.Mediator.AspNetCore | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 262 | ASP.NET Core Minimal API endpoint mapping extensions for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Polly | Published | v2.0.0 / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 261 | Polly v8 resilience policies and pipeline integration for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.GeneratorAnalyzer / Generator | Published | v2.0.0 / v3.2.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 247 | Source generator for EricksonLopez.Mediator. |
| EricksonLopez.Mediator.Caching | Unpublished | — / v3.2.0 | net8.0, net9.0, net10.0 | AOT: Full | 0 | Query caching and cache invalidation pipeline behaviors for EricksonLopez.Mediator. Supports stampede-protected multi-tier caching and Native AOT compatibility. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.Mediator. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using System;
using EricksonLopez.Mediator;
public sealed record CreateOrderCommand(string CustomerId, decimal Amount) : ICommand<Guid>;
public sealed record GetOrderByIdQuery(Guid OrderId) : IQuery<OrderDto?>;
public sealed record OrderDto(Guid OrderId, string CustomerId, decimal Amount, string Status);
public sealed record OrderCreatedEvent(Guid OrderId, string CustomerId) : INotification;9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_mediator["EricksonLopez.Mediator (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_mediator -.-> lib_result lib_caching["EricksonLopez.Caching (L2)"] lib_mediator -.-> lib_caching lib_concurrency["EricksonLopez.Concurrency (L2)"] lib_concurrency -.-> lib_mediator lib_idempotency["EricksonLopez.Idempotency (L2)"] lib_idempotency -.-> lib_mediator lib_resilience["EricksonLopez.Resilience (L2)"] lib_resilience -.-> lib_mediator lib_transaction["EricksonLopez.Transaction (L2)"] lib_transaction --> lib_mediator lib_outbox["EricksonLopez.Outbox (L3)"] lib_outbox --> lib_mediator lib_security["EricksonLopez.Security (L3)"] lib_security -.-> lib_mediator lib_processes["EricksonLopez.Processes (L4)"] lib_processes --> lib_mediator
View accessible text summary and structure
2 upstream library dependencies and 7 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Adapter, NuGet Package |
| Upstream | EricksonLopez.Caching | L2 | Adapter |
| Downstream | EricksonLopez.Concurrency | L2 | Adapter, NuGet Package |
| Downstream | EricksonLopez.Idempotency | L2 | Adapter, NuGet Package |
| Downstream | EricksonLopez.Resilience | L2 | Adapter, NuGet Package |
| Downstream | EricksonLopez.Transaction | L2 | Compile-Time |
| Downstream | EricksonLopez.Outbox | L3 | Adapter, Compile-Time, NuGet Package |
| Downstream | EricksonLopez.Security | L3 | Adapter |
| Downstream | EricksonLopez.Processes | L4 | Compile-Time, NuGet Package |
flowchart LR
lib_mediator["EricksonLopez.Mediator (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_mediator -.-> lib_result
lib_caching["EricksonLopez.Caching (L2)"]
lib_mediator -.-> lib_caching
lib_concurrency["EricksonLopez.Concurrency (L2)"]
lib_concurrency -.-> lib_mediator
lib_idempotency["EricksonLopez.Idempotency (L2)"]
lib_idempotency -.-> lib_mediator
lib_resilience["EricksonLopez.Resilience (L2)"]
lib_resilience -.-> lib_mediator
lib_transaction["EricksonLopez.Transaction (L2)"]
lib_transaction --> lib_mediator
lib_outbox["EricksonLopez.Outbox (L3)"]
lib_outbox --> lib_mediator
lib_security["EricksonLopez.Security (L3)"]
lib_security -.-> lib_mediator
lib_processes["EricksonLopez.Processes (L4)"]
lib_processes --> lib_mediator10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 10 packages: 8 Full, 0 Partial, 1 Incompatible, 1 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.Mediator | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.OpenTelemetry | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.FluentValidation | false | true | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Testing | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Result | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.RateLimiting | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.AspNetCore | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Polly | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.Mediator.Generator | false | false | NotApplicable | netstandard2.0 |
| EricksonLopez.Mediator.Caching | true | true | Full | net8.0, net9.0, net10.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (2)
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
- EricksonLopez.Concurrency.Mediator (EricksonLopez.Concurrency)→ EricksonLopez.Mediator
- EricksonLopez.Idempotency.Mediator (EricksonLopez.Idempotency)→ EricksonLopez.Mediator
- EricksonLopez.Mediator.Caching→ EricksonLopez.Caching (EricksonLopez.Caching)
- EricksonLopez.Mediator.Caching→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.FluentValidation→ EricksonLopez.Result.FluentValidation (EricksonLopez.Result)
- EricksonLopez.Mediator.OpenTelemetry→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Mediator.Result→ EricksonLopez.Result (EricksonLopez.Result)
- EricksonLopez.Outbox.Mediator (EricksonLopez.Outbox)→ EricksonLopez.Mediator
- EricksonLopez.Resilience.Mediator (EricksonLopez.Resilience)→ EricksonLopez.Mediator
- EricksonLopez.Security.Mediator (EricksonLopez.Security)→ EricksonLopez.Mediator
Verified External NuGet Dependencies (6)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
MediatorHealthCheckExtensions.AddMediatorHealthCheckRegisters `MediatorHealthCheck` with the specified service collection.
MediatorEndpointRouteBuilderExtensions.MapCommand<TCommand, TResponse>Maps an HTTP POST endpoint for the specified command type `TCommand`.
MediatorEndpointRouteBuilderExtensions.MapQuery<TQuery, TResponse>Maps an HTTP GET endpoint for the specified query type `TQuery`.
CachingMediatorExtensions.AddMediatorCacheInvalidationRegisters the open generic `CacheInvalidationPipelineBehavior<TRequest, TResponse>` with the service collection.
CachingMediatorExtensions.AddMediatorCachingRegisters the open generic `CachingPipelineBehavior<TRequest, TResponse>` with the service collection.
ServiceCollectionExtensions.AddMediatorOpenTelemetryRegisters and configures OpenTelemetry instrumentation options for the mediator pipeline.
MediatorPollyExtensions.AddMediatorDefaultResiliencePipelineConfigures and registers a default Polly resilience pipeline for the mediator.
MediatorPollyExtensions.AddMediatorPollyRegisters the open generic `PollyResilienceBehavior<TRequest, TResponse>` with the service collection.
RateLimitingMediatorExtensions.AddMediatorRateLimitingRegisters the rate limiting pipeline behavior with the service collection.
MediatorFluentValidationExtensions.AddMediatorFluentValidationRegisters the open generic `ValidationPipelineBehavior<TRequest, TResponse>` as a pipeline behavior in the service collection.
MediatorFluentValidationExtensions.AddMediatorFluentValidationValidator<TValidator, TRequest>Registers a single FluentValidation validator explicitly, without assembly scanning.
MediatorFluentValidationExtensions.AddMediatorFluentValidatorsFromAssemblyDiscovers and registers all FluentValidation validators found in the specified assembly into the service collection.
Key Public Types & Contracts
EricksonLopez.Mediator.DiscoverHandlersAttribute (class)Specifies a marker type whose containing assembly is scanned at compile time for mediator handlers and behaviors.
EricksonLopez.Mediator.HandlerLifetime (enum)Specifies the lifetime of a handler registration within the dependency injection container.
EricksonLopez.Mediator.ICommandHandler`2 (interface)Defines a handler for processing a command of type `TCommand`.
EricksonLopez.Mediator.ICommand`1 (interface)Defines a command that produces a response of type `TResponse`.
EricksonLopez.Mediator.IMediator (interface)Defines a mediator that combines message dispatching and notification publishing capabilities.
EricksonLopez.Mediator.INext (interface)Defines a callback delegate representing the next step in a notification processing pipeline.
EricksonLopez.Mediator.INext`1 (interface)Defines a callback delegate representing the next step in a request processing pipeline.
EricksonLopez.Mediator.INotification (interface)Defines a message that represents an event to be published to zero or more handlers.
EricksonLopez.Mediator.INotificationBehavior`1 (interface)Defines a cross-cutting behavior that surrounds notification handling within the mediator pipeline.
EricksonLopez.Mediator.INotificationHandler`1 (interface)Defines a handler for processing notifications of type `TNotification`.
EricksonLopez.Mediator.IPipelineBehavior`2 (interface)Defines a cross-cutting behavior that intercepts request processing within the mediator pipeline.
EricksonLopez.Mediator.IPublisher (interface)Defines a mechanism for publishing notification messages to registered handlers.
14. Verified Performance Benchmarks#
All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
| Suite | Method | Runtime | Mean (ns) | Allocated (B) | Status |
|---|---|---|---|---|---|
| MediatorBenchmarks | DirectCall | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 0.177 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 0.296 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 0.33 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.599 | 0 | measured |
| MediatorBenchmarks | DirectCall | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 0.601 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.10 X64 RyuJIT x86-64-v4 | 11.186 | 24 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 15.665 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 15.811 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 18.709 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 21.037 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 21.096 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 24.812 | 0 | measured |
| MediatorBenchmarks | SendQuery_NoBehaviors | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 25.745 | 0 | measured |
| MediatorBenchmarks | SendCommand_NoBehaviors | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 26.185 | 0 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 40.324 | 24 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 41.371 | 24 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 45.81 | 0 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 47.159 | 0 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 47.186 | 0 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 54.349 | 24 | measured |
| MediatorBenchmarks | PublishNotification_OneHandler | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 58.007 | 24 | measured |
| MediatorBenchmarks | SendCommand_OneBehavior | .NET 8.0.31 X64 RyuJIT x86-64-v3 | 58.711 | 0 | measured |
| MediatorBenchmarks | NestedSend | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 70.879 | 24 | measured |
| MediatorBenchmarks | NestedSend | .NET 10.0.12 X64 RyuJIT x86-64-v3 | 71.734 | 24 | measured |
| MediatorBenchmarks | NestedSend | .NET 9.0.20 X64 RyuJIT x86-64-v3 | 79.651 | 24 | measured |
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.2.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v2.0.0 ↗ | nuget | 2026-09-24 | Published EricksonLopez.Mediator 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-09-24 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.Mediator` | `2.0.0` | | `EricksonLopez.Mediator.Generator` | `2.0.0` | | `EricksonLopez.Mediator.OpenTelemetry` | `2.0.0` | | `EricksonLopez.Mediator.Polly` | `2.0.0` | | `EricksonLopez.Mediator.Result` | `2.0.0` | | `EricksonLopez.Mediator.Testing` | `2.0.0` | | `EricksonLopez.Mediator.FluentValidat... |
| v1.0.0 ↗ | github | 2026-08-27 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.Mediator` | `1.0.0` | | `EricksonLopez.Mediator.Generator` | `1.0.0` | | `EricksonLopez.Mediator.OpenTelemetry` | `1.0.0` | | `EricksonLopez.Mediator.Polly` | `1.0.0` | | `EricksonLopez.Mediator.Result` | `1.0.0` | | `EricksonLopez.Mediator.Testing` | `1.0.0` | | `EricksonLopez.Mediator.FluentValidat... |
| v1.0.0 ↗ | nuget | 2026-08-27 | Published EricksonLopez.Mediator 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
14 namespaces · 90 types · 280 members
Ecosystem Dependency Map →
Learning Center & Handbook →
Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.
18. Source Repository, License & Contributing#
Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).
19. Troubleshooting, Pitfalls & Migration Guidance#
- Notice library aotStatus is Partial: EricksonLopez.Mediator.FluentValidation sets IsAotCompatible=false while core and other 8 packages are Full AOT.
- Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.2.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (14 namespaces, 90 types, 280 members)
- MSBuild AOT / Trim Attributes
- 8 Full / 0 Partial / 1 Incompatible / 1 N/A
- BenchmarkDotNet Artifacts
- 38 total (38 measured, 0 na_error)
Explicit Verification Boundaries & Limitations
- All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
- 1 unpublished