EricksonLopez.Mediator

dotnet-mediator · CQRS & Messaging

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L2 Cross-Cutting & ReliabilityStableMaintenance: ActiveAOT: PartialMIT LicenseConfidence: HIGH
Applicationnet8.0net9.0net10.0

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
Also published in this family:
EricksonLopez.Mediator.OpenTelemetryEricksonLopez.Mediator.FluentValidationEricksonLopez.Mediator.TestingEricksonLopez.Mediator.ResultEricksonLopez.Mediator.RateLimitingEricksonLopez.Mediator.AspNetCore

4. Verified Ecosystem Metrics#

v2.0.0
NuGet Published Version
v3.2.0
Repo HEAD Version
7,953
NuGet Downloads
10
Packable Packages
280
Public API Members
38
Benchmark Rows (RyuJIT)

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 IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.MediatorPrimaryPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full5,569High-performance, zero-allocation, AOT-compatible mediator pattern implementation for .NET 10.
EricksonLopez.Mediator.OpenTelemetryPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full409OpenTelemetry distributed tracing and metrics instrumentation for EricksonLopez.Mediator.
EricksonLopez.Mediator.FluentValidationPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Incompatible332FluentValidation pipeline behavior and extensions for EricksonLopez.Mediator.
EricksonLopez.Mediator.TestingPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full298In-memory FakeMediator and testing doubles for EricksonLopez.Mediator.
EricksonLopez.Mediator.ResultPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full292Result pattern integration and pipeline short-circuiting abstractions for EricksonLopez.Mediator.
EricksonLopez.Mediator.RateLimitingPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full283Rate limiting pipeline behavior for EricksonLopez.Mediator based on System.Threading.RateLimiting.
EricksonLopez.Mediator.AspNetCorePublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full262ASP.NET Core Minimal API endpoint mapping extensions for EricksonLopez.Mediator.
EricksonLopez.Mediator.PollyPublishedv2.0.0 / v3.2.0net8.0, net9.0, net10.0AOT: Full261Polly v8 resilience policies and pipeline integration for EricksonLopez.Mediator.
EricksonLopez.Mediator.GeneratorAnalyzer / GeneratorPublishedv2.0.0 / v3.2.0netstandard2.0AOT: N/A (Analyzer/Legacy)247Source generator for EricksonLopez.Mediator.
EricksonLopez.Mediator.CachingUnpublished— / v3.2.0net8.0, net9.0, net10.0AOT: Full0Query 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#

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
EricksonLopez.Mediator Dependency Topology2 upstream library dependencies and 7 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

2 upstream library dependencies and 7 downstream dependent libraries verified in dependencies.json.

DirectionLibraryTierRelationship Kinds
UpstreamEricksonLopez.ResultL0Adapter, NuGet Package
UpstreamEricksonLopez.CachingL2Adapter
DownstreamEricksonLopez.ConcurrencyL2Adapter, NuGet Package
DownstreamEricksonLopez.IdempotencyL2Adapter, NuGet Package
DownstreamEricksonLopez.ResilienceL2Adapter, NuGet Package
DownstreamEricksonLopez.TransactionL2Compile-Time
DownstreamEricksonLopez.OutboxL3Adapter, Compile-Time, NuGet Package
DownstreamEricksonLopez.SecurityL3Adapter
DownstreamEricksonLopez.ProcessesL4Compile-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_mediator

10. Target Frameworks & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 10 packages: 8 Full, 0 Partial, 1 Incompatible, 1 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.MediatortruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.OpenTelemetrytruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.FluentValidationfalsetrueIncompatiblenet8.0, net9.0, net10.0
EricksonLopez.Mediator.TestingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.ResulttruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.RateLimitingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.AspNetCoretruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.PollytruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.Mediator.GeneratorfalsefalseNotApplicablenetstandard2.0
EricksonLopez.Mediator.CachingtruetrueFullnet8.0, net9.0, net10.0

11. Upstream Dependencies & Downstream Dependents#

Upstream Dependencies (2)

Downstream Dependents (7)

12. Optional Adapters & Third-Party Integrations#

Internal Adapter Edges & Integration Packages

Verified External NuGet Dependencies (6)

FluentValidationMicrosoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.Diagnostics.HealthChecks.AbstractionsOpenTelemetry.ApiPolly.CoreSystem.Threading.RateLimiting

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

  • MediatorHealthCheckExtensions.AddMediatorHealthCheck

    Registers `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.AddMediatorCacheInvalidation

    Registers the open generic `CacheInvalidationPipelineBehavior<TRequest, TResponse>` with the service collection.

  • CachingMediatorExtensions.AddMediatorCaching

    Registers the open generic `CachingPipelineBehavior<TRequest, TResponse>` with the service collection.

  • ServiceCollectionExtensions.AddMediatorOpenTelemetry

    Registers and configures OpenTelemetry instrumentation options for the mediator pipeline.

  • MediatorPollyExtensions.AddMediatorDefaultResiliencePipeline

    Configures and registers a default Polly resilience pipeline for the mediator.

  • MediatorPollyExtensions.AddMediatorPolly

    Registers the open generic `PollyResilienceBehavior<TRequest, TResponse>` with the service collection.

  • RateLimitingMediatorExtensions.AddMediatorRateLimiting

    Registers the rate limiting pipeline behavior with the service collection.

  • MediatorFluentValidationExtensions.AddMediatorFluentValidation

    Registers 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.AddMediatorFluentValidatorsFromAssembly

    Discovers 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).

Total rows: 38 · Measured: 38 · NA / Error: 0 · Suites: 1

Observed runtimes: .NET 10.0.10 X64 RyuJIT x86-64-v4 · .NET 10.0.12 X64 RyuJIT x86-64-v3 · .NET 8.0.31 X64 RyuJIT x86-64-v3 · .NET 9.0.20 X64 RyuJIT x86-64-v3

Observed CPUs: AMD EPYC 7763 2.45GHz, 1 CPU, 4 logical and 2 physical cores · AMD Ryzen 7 9800X3D 4.70GHz, 1 CPU, 8 logical and 8 physical cores

SuiteMethodRuntimeMean (ns)Allocated (B)Status
MediatorBenchmarksDirectCall.NET 10.0.10 X64 RyuJIT x86-64-v40.1770measured
MediatorBenchmarksDirectCall.NET 8.0.31 X64 RyuJIT x86-64-v30.2960measured
MediatorBenchmarksDirectCall.NET 9.0.20 X64 RyuJIT x86-64-v30.330measured
MediatorBenchmarksDirectCall.NET 10.0.12 X64 RyuJIT x86-64-v30.5990measured
MediatorBenchmarksDirectCall.NET 10.0.12 X64 RyuJIT x86-64-v30.6010measured
MediatorBenchmarksSendCommand_NoBehaviors.NET 10.0.10 X64 RyuJIT x86-64-v411.18624measured
MediatorBenchmarksSendQuery_NoBehaviors.NET 10.0.12 X64 RyuJIT x86-64-v315.6650measured
MediatorBenchmarksSendQuery_NoBehaviors.NET 10.0.12 X64 RyuJIT x86-64-v315.8110measured
MediatorBenchmarksSendQuery_NoBehaviors.NET 9.0.20 X64 RyuJIT x86-64-v318.7090measured
MediatorBenchmarksSendCommand_NoBehaviors.NET 10.0.12 X64 RyuJIT x86-64-v321.0370measured
MediatorBenchmarksSendCommand_NoBehaviors.NET 10.0.12 X64 RyuJIT x86-64-v321.0960measured
MediatorBenchmarksSendCommand_NoBehaviors.NET 9.0.20 X64 RyuJIT x86-64-v324.8120measured
MediatorBenchmarksSendQuery_NoBehaviors.NET 8.0.31 X64 RyuJIT x86-64-v325.7450measured
MediatorBenchmarksSendCommand_NoBehaviors.NET 8.0.31 X64 RyuJIT x86-64-v326.1850measured
MediatorBenchmarksPublishNotification_OneHandler.NET 10.0.12 X64 RyuJIT x86-64-v340.32424measured
MediatorBenchmarksPublishNotification_OneHandler.NET 10.0.12 X64 RyuJIT x86-64-v341.37124measured
MediatorBenchmarksSendCommand_OneBehavior.NET 9.0.20 X64 RyuJIT x86-64-v345.810measured
MediatorBenchmarksSendCommand_OneBehavior.NET 10.0.12 X64 RyuJIT x86-64-v347.1590measured
MediatorBenchmarksSendCommand_OneBehavior.NET 10.0.12 X64 RyuJIT x86-64-v347.1860measured
MediatorBenchmarksPublishNotification_OneHandler.NET 9.0.20 X64 RyuJIT x86-64-v354.34924measured
MediatorBenchmarksPublishNotification_OneHandler.NET 8.0.31 X64 RyuJIT x86-64-v358.00724measured
MediatorBenchmarksSendCommand_OneBehavior.NET 8.0.31 X64 RyuJIT x86-64-v358.7110measured
MediatorBenchmarksNestedSend.NET 10.0.12 X64 RyuJIT x86-64-v370.87924measured
MediatorBenchmarksNestedSend.NET 10.0.12 X64 RyuJIT x86-64-v371.73424measured
MediatorBenchmarksNestedSend.NET 9.0.20 X64 RyuJIT x86-64-v379.65124measured

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.

VersionSourcePublished DateSummary
v2.0.0 ↗nuget2026-09-24Published EricksonLopez.Mediator 2.0.0 to NuGet.org.
v2.0.0 ↗github2026-09-24Ecosystem 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 ↗github2026-08-27Ecosystem 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 ↗nuget2026-08-27Published EricksonLopez.Mediator 1.0.0 to NuGet.org.

Libraries in the same tier, architectural layer, or directly paired via dependency edges.

17. Documentation, API Reference & Portal Links#

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

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.