Public .NET API ReferenceL2 Cross-Cutting & ReliabilityStableAOT: Partial

EricksonLopez.Mediator

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.

14 namespaces90 types280 membersGenerated from XML docs & assemblies · UTC 2026-12-01

Showing 90 of 90 types (280 members)

EricksonLopez.Mediator#

39
class

DiscoverHandlersAttribute

Assembly: EricksonLopez.Mediator
public sealed class DiscoverHandlersAttribute : Attribute
Inherits: Attribute

Specifies a marker type whose containing assembly is scanned at compile time for mediator handlers and behaviors.

Members (2)

  • constructorDiscoverHandlersAttribute
    public DiscoverHandlersAttribute(Type assemblyMarkerType)

    Initializes a new instance of the `DiscoverHandlersAttribute` class with the specified assembly marker type.

    assemblyMarkerType: Type
    A marker type located in the target assembly to scan for handlers.
  • propertyAssemblyMarkerType
    public Type AssemblyMarkerType { get; }

    Gets the marker type whose containing assembly is scanned.

enum

HandlerLifetime

Assembly: EricksonLopez.Mediator
public enum HandlerLifetime

Specifies the lifetime of a handler registration within the dependency injection container.

Members (3)

  • fieldScoped
    Scoped

    Specifies that a new instance of the handler is created per service scope.

  • fieldSingleton
    Singleton

    Specifies that a single instance of the handler is created and shared across all requests.

  • fieldTransient
    Transient

    Specifies that a new instance of the handler is created each time it is requested.

interface

ICommandHandler<TCommand, TResponse>

Assembly: EricksonLopez.Mediator
public interface ICommandHandler<TCommand, TResponse> where TCommand : ICommand<TResponse>

Defines a handler for processing a command of type `TCommand`.

Remarks:

Command handlers encapsulate business logic that mutates state and produce a response. The mediator framework guarantees that each command type routes to a single registered handler. Type parameters: TCommand: The type of command to process.; TResponse: The type of response returned by the handler.

Members (1)

  • methodHandle
    ValueTask<TResponse> Handle(TCommand command, CancellationToken cancellationToken)

    Processes the specified command.

    command: TCommand
    The command instance to process.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response produced by the command.

interface

ICommand<TResponse>

Assembly: EricksonLopez.Mediator
public interface ICommand<TResponse>

Defines a command that produces a response of type `TResponse`.

Remarks:

Commands represent operations that mutate system state and must be handled by a single `ICommandHandler<TCommand, TResponse>`. Type parameters: TResponse: The type of the result produced by executing the command.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IMediator

Assembly: EricksonLopez.Mediator
public interface IMediator : ISender, IPublisher
Implements: IPublisher, ISender

Defines a mediator that combines message dispatching and notification publishing capabilities.

Remarks:

Unifies `ISender` and `IPublisher` into a single contract.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

INext

Assembly: EricksonLopez.Mediator
public interface INext

Defines a callback delegate representing the next step in a notification processing pipeline.

Remarks:

This is the non-generic variant of `INext`, used as the continuation type for `INotificationBehavior<TNotification>`. It is distinct from `INext<TResponse>`, which is used for command and query pipeline behaviors. This abstraction enables zero-allocation pipeline execution across notification behaviors and handlers by requiring implementations to be `readonly struct` types, satisfying the `where TNext : struct, INext` constraint on `INotificationBehavior<TNotification>`.

Members (1)

  • methodInvokeAsync
    ValueTask InvokeAsync()

    Invokes the next behavior or handler in the pipeline.

    Returns: A value task representing the asynchronous operation.

interface

INext<TResponse>

Assembly: EricksonLopez.Mediator
public interface INext<TResponse>

Defines a callback delegate representing the next step in a request processing pipeline.

Remarks:

This abstraction enables zero-allocation pipeline execution across behaviors and handlers. Type parameters: TResponse: The type of response returned by the downstream pipeline.

Members (1)

  • methodInvokeAsync
    ValueTask<TResponse> InvokeAsync()

    Invokes the next behavior or handler in the pipeline.

    Returns: A value task representing the asynchronous operation that yields the response from subsequent pipeline components.

interface

INotification

Assembly: EricksonLopez.Mediator
public interface INotification

Defines a message that represents an event to be published to zero or more handlers.

Remarks:

Notifications support multicast dispatching via `IPublisher` and can have zero or multiple registered `INotificationHandler<TNotification>` instances.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

INotificationBehavior<TNotification>

Assembly: EricksonLopez.Mediator
public interface INotificationBehavior<TNotification> where TNotification : INotification

Defines a cross-cutting behavior that surrounds notification handling within the mediator pipeline.

Remarks:

Type parameters: TNotification: The type of notification processed by this behavior.

Members (1)

  • methodHandle<TNext>
    ValueTask Handle<TNext>(TNotification notification, TNext next, CancellationToken cancellationToken) where TNext : struct, INext

    Intercepts the notification publishing pipeline and invokes the next step.

    notification: TNotification
    The notification instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or handlers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

interface

INotificationHandler<TNotification>

Assembly: EricksonLopez.Mediator
public interface INotificationHandler<TNotification> where TNotification : INotification

Defines a handler for processing notifications of type `TNotification`.

Remarks:

Multiple handlers can be registered for the same notification type, and are executed according to the configured publishing strategy. Type parameters: TNotification: The type of notification to process.

Members (1)

  • methodHandle
    ValueTask Handle(TNotification notification, CancellationToken cancellationToken)

    Processes the specified notification.

    notification: TNotification
    The notification instance to process.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation.

interface

IPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator
public interface IPipelineBehavior<TRequest, TResponse>

Defines a cross-cutting behavior that intercepts request processing within the mediator pipeline.

Remarks:

Behaviors can be chained to form an execution pipeline surrounding the target handler. Type parameters: TRequest: The type of request being intercepted.; TResponse: The type of response returned by the pipeline.

Members (1)

  • methodHandle<TNext>
    ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

interface

IPublisher

Assembly: EricksonLopez.Mediator
public interface IPublisher

Defines a mechanism for publishing notification messages to registered handlers.

Members (1)

  • methodPublish<TNotification>
    ValueTask Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification

    Publishes the specified notification to all registered handlers.

    notification: TNotification
    The notification instance to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation.

    Type parameters: TNotification: The type of notification being published.

interface

IQueryHandler<TQuery, TResponse>

Assembly: EricksonLopez.Mediator
public interface IQueryHandler<TQuery, TResponse> where TQuery : IQuery<TResponse>

Defines a handler for processing queries of type `TQuery`.

Remarks:

Query handlers encapsulate read-only data retrieval logic and produce a response without mutating state. The mediator framework guarantees that each query type routes to a single registered handler. Type parameters: TQuery: The type of query to process.; TResponse: The type of response returned by the handler.

Members (1)

  • methodHandle
    ValueTask<TResponse> Handle(TQuery query, CancellationToken cancellationToken)

    Processes the specified query.

    query: TQuery
    The query instance to process.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response produced by the query.

interface

IQuery<TResponse>

Assembly: EricksonLopez.Mediator
public interface IQuery<TResponse>

Defines a query that produces a response of type `TResponse`.

Remarks:

Queries represent read-only operations that do not mutate system state and must be handled by a single `IQueryHandler<TQuery, TResponse>`. Type parameters: TResponse: The type of the result produced by evaluating the query.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IRequest

Assembly: EricksonLopez.Mediator
public interface IRequest : IRequest<Unit>
Implements: IRequest<Unit>

Defines a marker interface for a request that produces a response of type `Unit`. Provided for migration compatibility with MediatR.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IRequestHandler<TRequest>

Assembly: EricksonLopez.Mediator
public interface IRequestHandler<TRequest> : IRequestHandler<TRequest, Unit> where TRequest : IRequest<Unit>
Implements: IRequestHandler<TRequest, Unit>

Defines a handler for processing a request of type `TRequest` that produces a response of type `Unit`. Provided for migration compatibility with MediatR.

Remarks:

Type parameters: TRequest: The type of request to process.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

IRequestHandler<TRequest, TResponse>

Assembly: EricksonLopez.Mediator
public interface IRequestHandler<TRequest, TResponse>

Defines a handler for processing a request of type `TRequest` that produces a response of type `TResponse`. Provided for migration compatibility with MediatR.

Remarks:

Type parameters: TRequest: The type of request to process.; TResponse: The type of response produced by the handler.

Members (1)

  • methodHandle
    ValueTask<TResponse> Handle(TRequest request, CancellationToken cancellationToken)

    Processes the specified request.

    request: TRequest
    The request instance to process.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response produced by the request.

interface

IRequest<TResponse>

Assembly: EricksonLopez.Mediator
public interface IRequest<TResponse> : ICommand<TResponse>
Implements: ICommand<TResponse>

Defines a marker interface for a request that produces a response of type `TResponse`. Provided for migration compatibility with MediatR; prefer `ICommand<TResponse>` or `IQuery<TResponse>` in new code.

Remarks:

Type parameters: TResponse: The type of response produced by the request.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

interface

ISender

Assembly: EricksonLopez.Mediator
public interface ISender

Defines a mechanism for dispatching commands, queries, and stream requests to their respective handlers.

Members (5)

  • methodCreateStream<TResponse>
    IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)

    Dispatches a stream request to its registered handler and returns an asynchronous sequence of items.

    request: IStreamRequest<TResponse>
    The stream request instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the streaming operation.

    Returns: An asynchronous stream yielding items of type `TResponse`.

    Type parameters: TResponse: The type of elements yielded by the response stream.

  • methodSend<TResponse>
    ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default)

    Dispatches a command to its registered handler.

    command: ICommand<TResponse>
    The command instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Type parameters: TResponse: The type of response produced by the command handler.

  • methodSend<TResponse>
    ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default)

    Dispatches a query to its registered handler.

    query: IQuery<TResponse>
    The query instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Type parameters: TResponse: The type of response produced by the query handler.

  • methodSendCommand<TCommand, TResponse>
    ValueTask<TResponse> SendCommand<TCommand, TResponse>(TCommand command, CancellationToken cancellationToken = default) where TCommand : ICommand<TResponse>

    Dispatches a strongly typed command directly via generic static dispatch without boxing or runtime reflection.

    command: TCommand
    The command instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Type parameters: TCommand: The concrete type of the command.; TResponse: The type of response produced by the command handler.

  • methodSendQuery<TQuery, TResponse>
    ValueTask<TResponse> SendQuery<TQuery, TResponse>(TQuery query, CancellationToken cancellationToken = default) where TQuery : IQuery<TResponse>

    Dispatches a strongly typed query directly via generic static dispatch without boxing or runtime reflection.

    query: TQuery
    The query instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Type parameters: TQuery: The concrete type of the query.; TResponse: The type of response produced by the query handler.

interface

IStreamRequestHandler<TRequest, TResponse>

Assembly: EricksonLopez.Mediator
public interface IStreamRequestHandler<TRequest, TResponse> where TRequest : IStreamRequest<TResponse>

Defines a handler for processing stream requests of type `TRequest`.

Remarks:

Type parameters: TRequest: The type of stream request to process.; TResponse: The type of elements yielded by the response stream.

Members (1)

  • methodHandle
    IAsyncEnumerable<TResponse> Handle(TRequest request, CancellationToken cancellationToken)

    Processes the specified stream request and returns an asynchronous sequence of items.

    request: TRequest
    The stream request instance to process.
    cancellationToken: CancellationToken
    A token that can be used to cancel the streaming operation.

    Returns: An asynchronous enumerable yielding elements of type `TResponse`.

interface

IStreamRequest<TResponse>

Assembly: EricksonLopez.Mediator
public interface IStreamRequest<TResponse>

Defines a request that yields an asynchronous stream of items of type `TResponse`.

Remarks:

Stream requests must be handled by a single `IStreamRequestHandler<TRequest, TResponse>`. Type parameters: TResponse: The type of elements yielded by the stream.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

class

MediatorHealthCheckExtensions

Assembly: EricksonLopez.Mediator
public static class MediatorHealthCheckExtensions

Provides extension methods for registering `MediatorHealthCheck` with dependency injection.

Members (1)

  • methodAddMediatorHealthCheck
    public static IServiceCollection AddMediatorHealthCheck(this IServiceCollection services)

    Registers `MediatorHealthCheck` with the specified service collection.

    services: this IServiceCollection
    The service collection to register the health check into.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

class

MediatorRecursionException

Assembly: EricksonLopez.Mediator
public sealed class MediatorRecursionException : InvalidOperationException
Inherits: InvalidOperationException

Represents an exception thrown when mediator dispatch recursion exceeds the configured maximum depth limit (ELM014).

Members (6)

  • constructorMediatorRecursionException
    public MediatorRecursionException(int maxDepth, int currentDepth, Type? requestType = null)

    Initializes a new instance of the `MediatorRecursionException` class with recursion depth details.

    maxDepth: int
    The maximum allowed recursion depth.
    currentDepth: int
    The current recursion depth.
    requestType: Type?
    The type of the request being dispatched.
  • constructorMediatorRecursionException
    public MediatorRecursionException(string message)

    Initializes a new instance of the `MediatorRecursionException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorMediatorRecursionException
    public MediatorRecursionException(string message, Exception innerException)

    Initializes a new instance of the `MediatorRecursionException` class with a specified error message and inner exception.

    message: string
    The error message that explains the reason for the exception.
    innerException: Exception
    The exception that is the cause of the current exception.
  • propertyCurrentDepth
    public int CurrentDepth { get; }

    Gets the recursion depth observed when the threshold was exceeded.

  • propertyMaxDepth
    public int MaxDepth { get; }

    Gets the maximum allowed recursion depth.

  • propertyRequestType
    public Type? RequestType { get; }

    Gets the runtime type of the request being dispatched when recursion exceeded the threshold, if available.

class

MediatorValidationException

Assembly: EricksonLopez.Mediator
public sealed class MediatorValidationException : Exception
Inherits: Exception

Represents an exception thrown when request validation fails during pipeline execution.

Members (3)

  • constructorMediatorValidationException
    public MediatorValidationException(IReadOnlyList<string> errors)

    Initializes a new instance of the `MediatorValidationException` class with a collection of validation error messages.

    errors: IReadOnlyList<string>
    The collection of validation error messages.
  • constructorMediatorValidationException
    public MediatorValidationException(string message)

    Initializes a new instance of the `MediatorValidationException` class with a single validation error message.

    message: string
    The message that describes the validation error.
  • propertyErrors
    public IReadOnlyList<string> Errors { get; }

    Gets the collection of validation failure error messages.

class

NotificationHandlerAggregateException

Assembly: EricksonLopez.Mediator
public sealed class NotificationHandlerAggregateException : Exception
Inherits: Exception

Represents an aggregate exception containing exceptions thrown by notification handlers during a publish operation.

Members (2)

  • constructorNotificationHandlerAggregateException
    public NotificationHandlerAggregateException(IReadOnlyList<Exception> exceptions)

    Initializes a new instance of the `NotificationHandlerAggregateException` class with the specified handler exceptions.

    exceptions: IReadOnlyList<Exception>
    The collection of exceptions thrown during notification publishing.
  • propertyHandlerExceptions
    public IReadOnlyList<Exception> HandlerExceptions { get; }

    Gets the collection of exceptions thrown by individual notification handlers.

class

NotificationOrderAttribute

Assembly: EricksonLopez.Mediator
public sealed class NotificationOrderAttribute : Attribute
Inherits: Attribute

Specifies the execution order of a notification handler relative to other handlers of the same notification type.

Remarks:

Handlers with lower order values are executed before handlers with higher order values. Handlers that do not specify an order default to an order of 0. Handlers with identical orders preserve registration order (FIFO).

Members (2)

  • constructorNotificationOrderAttribute
    public NotificationOrderAttribute(int order)

    Initializes a new instance of the `NotificationOrderAttribute` class with the specified order.

    order: int
    The execution order value. Lower values execute earlier.
  • propertyOrder
    public int Order { get; }

    Gets the execution priority order for the decorated notification handler.

enum

PublishStrategy

Assembly: EricksonLopez.Mediator
public enum PublishStrategy

Specifies the dispatching strategy used when publishing notifications to multiple handlers.

Members (3)

  • fieldParallel
    Parallel

    Executes all registered notification handlers concurrently using `Task.WhenAll(Task[])`. In DI-managed pipelines, each handler is resolved within an isolated child `DependencyInjection.AsyncServiceScope` to prevent concurrent access collisions on shared scoped services.

  • fieldSequential
    Sequential

    Executes all registered notification handlers sequentially in registration order.

  • fieldSequentialAggregateExceptions
    SequentialAggregateExceptions

    Executes all handlers sequentially, catching failures and aggregating them into a `NotificationHandlerAggregateException`.

class

PublishStrategyAttribute

Assembly: EricksonLopez.Mediator
public sealed class PublishStrategyAttribute : Attribute
Inherits: Attribute

Specifies the publishing strategy applied when dispatching the decorated notification type.

Remarks:

This attribute must be applied to the class or struct representing the notification.

Members (2)

  • constructorPublishStrategyAttribute
    public PublishStrategyAttribute(PublishStrategy strategy)

    Initializes a new instance of the `PublishStrategyAttribute` class with the specified execution strategy.

    strategy: PublishStrategy
    The publishing strategy to apply to the notification.
  • propertyStrategy
    public PublishStrategy Strategy { get; }

    Gets the configured publishing strategy.

class

ServiceLifetimeAttribute

Assembly: EricksonLopez.Mediator
public sealed class ServiceLifetimeAttribute : Attribute
Inherits: Attribute

Specifies the service lifetime of the decorated handler within the dependency injection container.

Remarks:

When this attribute is omitted, the source generator registers the handler with `HandlerLifetime.Transient` lifetime by default. This lifetime controls the handler registration only. The mediator interfaces (`IMediator`, `ISender`, and `IPublisher`) are registered separately as `Scoped` by default via `AddEricksonLopezMediator()` (ADR-037), which is independent of the handler registration lifetime configured here.

Members (2)

  • constructorServiceLifetimeAttribute
    public ServiceLifetimeAttribute(HandlerLifetime lifetime)

    Initializes a new instance of the `ServiceLifetimeAttribute` class with the specified service lifetime.

    lifetime: HandlerLifetime
    The service lifetime to apply to the handler registration.
  • propertyLifetime
    public HandlerLifetime Lifetime { get; }

    Gets the configured lifetime for the handler registration.

class

StaticMediator

Assembly: EricksonLopez.Mediator
public static class StaticMediator

Provides static mediator dispatching capabilities without requiring a dependency injection container.

Remarks:

This type is thread-safe, reflection-minimal, Native AOT compatible, and intended for high-performance, embedded, or constrained runtime environments. The primary dispatch path (`SendCommand<TCommand, TResponse>` and `SendQuery<TQuery, TResponse>`) uses compile-time type keys and performs zero reflection. The polymorphic fallback path (activated when the runtime type of the argument differs from the compile-time type) uses `object.GetType()` for dictionary lookup — it does NOT use `MethodInfo.Invoke` or emit dynamic code. See ADR-032 for full details and rationale. Notification Handler Order: Notification handlers are invoked in the order they were registered (FIFO). This guarantee relies on `ConcurrentQueue<T>` semantics. Cancellation: All dispatch methods honour a pre-cancelled `CancellationToken` by throwing `OperationCanceledException` before invoking any handler, consistent with the behaviour of the DI-based `GeneratedMediator`. Scoped handlers: Unlike the DI-based mediator, `StaticMediator` holds direct references to handler instances. Handlers that hold scoped resources (e.g. a `DbContext`) must be managed by the caller. Call `Reset` between test cases or application restarts to avoid stale handler references.

Members (9)

  • methodFreeze
    public static void Freeze()

    Freezes all handler registrations, rendering `StaticMediator` immutable. Once frozen, any subsequent call to registration methods will throw an `InvalidOperationException`.

  • methodPublish<TNotification>
    public static async ValueTask Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification

    Publishes a notification to all registered static handlers in registration order (FIFO).

    notification: TNotification
    The notification instance to publish.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation.

    Handlers are invoked sequentially in the order they were registered. If a handler throws an exception, subsequent handlers will not be invoked and the exception propagates to the caller. To invoke all handlers regardless of individual failures and collect all exceptions, use the DI-based `GeneratedMediator` with the `[PublishStrategy(PublishStrategy.SequentialAggregateExceptions)]` attribute. Type parameters: TNotification: The type of notification being published. Exceptions: ArgumentNullException: `notification` is `null`; OperationCanceledException: `cancellationToken` is already cancelled

  • methodRegisterCommandHandler<TCommand, TResponse>
    public static void RegisterCommandHandler<TCommand, TResponse>(ICommandHandler<TCommand, TResponse> handler) where TCommand : ICommand<TResponse>

    Registers a command handler instance for static dispatching.

    handler: ICommandHandler<TCommand, TResponse>
    The command handler instance to register.

    If a handler for `TCommand` is already registered, it is silently replaced. This is intentional to support re-registration scenarios in tests; call `Reset` between test cases for clean isolation. Type parameters: TCommand: The type of command handled.; TResponse: The type of response produced by the command. Exceptions: ArgumentNullException: `handler` is `null`

  • methodRegisterNotificationHandler<TNotification>
    public static void RegisterNotificationHandler<TNotification>(INotificationHandler<TNotification> handler) where TNotification : INotification

    Registers a notification handler instance for static dispatching.

    handler: INotificationHandler<TNotification>
    The notification handler instance to register.

    Multiple handlers may be registered for the same notification type. They are invoked in registration order (FIFO) when `Publish<TNotification>` is called, unless ordered by `NotificationOrderAttribute`. Type parameters: TNotification: The type of notification handled. Exceptions: ArgumentNullException: `handler` is `null`

  • methodRegisterQueryHandler<TQuery, TResponse>
    public static void RegisterQueryHandler<TQuery, TResponse>(IQueryHandler<TQuery, TResponse> handler) where TQuery : IQuery<TResponse>

    Registers a query handler instance for static dispatching.

    handler: IQueryHandler<TQuery, TResponse>
    The query handler instance to register.

    Type parameters: TQuery: The type of query handled.; TResponse: The type of response produced by the query. Exceptions: ArgumentNullException: `handler` is `null`

  • methodReset
    public static void Reset()

    Removes all statically registered command, query, and notification handlers.

    Call this method between test cases or application restarts to ensure clean handler state.

  • methodSendCommand<TCommand, TResponse>
    public static ValueTask<TResponse> SendCommand<TCommand, TResponse>(TCommand command, CancellationToken cancellationToken = default) where TCommand : ICommand<TResponse>

    Dispatches a strongly typed command directly to its registered static handler without reflection.

    command: TCommand
    The command instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Polymorphic Dispatch: Dispatch is keyed by the compile-time type `TCommand` (ADR-032). If invoking via an interface reference (e.g. `ICommand<TResponse>`), the type must match the registration or be dispatched via the DI-based `IMediator` which generates exhaustive runtime type switches. Type parameters: TCommand: The concrete type of the command.; TResponse: The type of response returned by the command handler. Exceptions: ArgumentNullException: `command` is `null`; OperationCanceledException: `cancellationToken` is already cancelled; InvalidOperationException: No static command handler is registered for `TCommand`

  • methodSendQuery<TQuery, TResponse>
    public static ValueTask<TResponse> SendQuery<TQuery, TResponse>(TQuery query, CancellationToken cancellationToken = default) where TQuery : IQuery<TResponse>

    Dispatches a strongly typed query directly to its registered static handler without reflection.

    query: TQuery
    The query instance to dispatch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the handler.

    Type parameters: TQuery: The concrete type of the query.; TResponse: The type of response returned by the query handler. Exceptions: ArgumentNullException: `query` is `null`; OperationCanceledException: `cancellationToken` is already cancelled; InvalidOperationException: No static query handler is registered for `TQuery`

  • propertyIsFrozen
    public static bool IsFrozen { get; }

    Gets a value indicating whether handler registrations in `StaticMediator` have been frozen.

struct

Unit

Assembly: EricksonLopez.Mediator
public readonly struct Unit : IEquatable<Unit>, IComparable<Unit>, IComparable
Implements: IComparable, IComparable<Unit>, IEquatable<Unit>

Represents a type with a single value, typically used to indicate the absence of a return value in generic signatures.

Members (12)

  • methodCompareTo
    public int CompareTo(Unit other)

    Inherits documentation from base type or interface.

    other: Unit
  • methodEquals
    public override bool Equals(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodEquals
    public bool Equals(Unit other)

    Inherits documentation from base type or interface.

    other: Unit
  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodoperator !=
    public static bool operator !=(Unit first, Unit second)

    Determines whether two `Unit` values are not equal.

    first: Unit
    The first instance to compare.
    second: Unit
    The second instance to compare.

    Returns: Always `false`.

  • methodoperator <
    public static bool operator <(Unit left, Unit right)

    Determines whether the first `Unit` is less than the second.

    left: Unit
    The first instance to compare.
    right: Unit
    The second instance to compare.

    Returns: Always `false`.

  • methodoperator <=
    public static bool operator <=(Unit left, Unit right)

    Determines whether the first `Unit` is less than or equal to the second.

    left: Unit
    The first instance to compare.
    right: Unit
    The second instance to compare.

    Returns: Always `true`.

  • methodoperator ==
    public static bool operator ==(Unit first, Unit second)

    Determines whether two `Unit` values are equal.

    first: Unit
    The first instance to compare.
    second: Unit
    The second instance to compare.

    Returns: Always `true`.

  • methodoperator >
    public static bool operator >(Unit left, Unit right)

    Determines whether the first `Unit` is greater than the second.

    left: Unit
    The first instance to compare.
    right: Unit
    The second instance to compare.

    Returns: Always `false`.

  • methodoperator >=
    public static bool operator >=(Unit left, Unit right)

    Determines whether the first `Unit` is greater than or equal to the second.

    left: Unit
    The first instance to compare.
    right: Unit
    The second instance to compare.

    Returns: Always `true`.

  • propertyValue
    public static ref readonly Unit Value { get; }

    Gets the single `Unit` value.

class

UseBehaviorAttribute

Assembly: EricksonLopez.Mediator
public sealed class UseBehaviorAttribute : Attribute
Inherits: Attribute

Specifies that a pipeline behavior applies to the decorated request type.

Remarks:

This attribute must be applied to the class or struct representing the command or query. The behavior type must implement `IPipelineBehavior<TRequest, TResponse>`.

Members (3)

  • constructorUseBehaviorAttribute
    public UseBehaviorAttribute(Type behaviorType, int order = 0)

    Initializes a new instance of the `UseBehaviorAttribute` class with the specified behavior type and execution order.

    behaviorType: Type
    The type of the pipeline behavior.
    order: int
    The execution order relative to other behaviors. Lower values execute first.
  • propertyBehaviorType
    public Type BehaviorType { get; }

    Gets the type of the pipeline behavior to execute.

  • propertyOrder
    public int Order { get; }

    Gets the execution order of the behavior. Lower numbers run first.

class

UseGlobalBehaviorAttribute

Assembly: EricksonLopez.Mediator
public sealed class UseGlobalBehaviorAttribute : Attribute
Inherits: Attribute

Specifies that a pipeline behavior applies globally to all requests across the assembly.

Remarks:

This attribute must be applied at the assembly level. The behavior type must implement `IPipelineBehavior<TRequest, TResponse>`.

Members (3)

  • constructorUseGlobalBehaviorAttribute
    public UseGlobalBehaviorAttribute(Type behaviorType, int order = 0)

    Initializes a new instance of the `UseGlobalBehaviorAttribute` class with the specified behavior type and execution order.

    behaviorType: Type
    The type of the pipeline behavior.
    order: int
    The execution order relative to other behaviors. Lower values execute first.
  • propertyBehaviorType
    public Type BehaviorType { get; }

    Gets the type of the pipeline behavior to execute.

  • propertyOrder
    public int Order { get; }

    Gets the execution order of the behavior. Lower numbers run first.

class

ValidateLengthAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateLengthAttribute : Attribute
Inherits: Attribute

Validates that the length of the decorated string falls within the specified bounds.

Members (4)

  • constructorValidateLengthAttribute
    public ValidateLengthAttribute(int minimumLength, int maximumLength, string? errorMessage = null)

    Initializes a new instance of the `ValidateLengthAttribute` class with the specified minimum and maximum lengths.

    minimumLength: int
    The minimum allowed character length.
    maximumLength: int
    The maximum allowed character length.
    errorMessage: string?
    The optional custom error message returned when validation fails.
  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the custom error message returned when validation fails.

  • propertyMaximumLength
    public int MaximumLength { get; }

    Gets the maximum allowed character length.

  • propertyMinimumLength
    public int MinimumLength { get; }

    Gets the minimum allowed character length.

class

ValidateNotEmptyAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateNotEmptyAttribute : Attribute
Inherits: Attribute

Validates that the decorated string, collection, or identifier is not empty.

Members (2)

  • constructorValidateNotEmptyAttribute
    public ValidateNotEmptyAttribute(string? errorMessage = null)

    Initializes a new instance of the `ValidateNotEmptyAttribute` class.

    errorMessage: string?
    The optional custom error message returned when validation fails.
  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the custom error message returned when validation fails.

class

ValidateNotNullAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateNotNullAttribute : Attribute
Inherits: Attribute

Validates that the decorated property is not `null`.

Members (2)

  • constructorValidateNotNullAttribute
    public ValidateNotNullAttribute(string? errorMessage = null)

    Initializes a new instance of the `ValidateNotNullAttribute` class.

    errorMessage: string?
    The optional custom error message returned when validation fails.
  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the custom error message returned when validation fails.

class

ValidateRangeAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateRangeAttribute : Attribute
Inherits: Attribute

Validates that the decorated numeric value falls within the specified range.

Members (4)

  • constructorValidateRangeAttribute
    public ValidateRangeAttribute(double minimum, double maximum, string? errorMessage = null)

    Initializes a new instance of the `ValidateRangeAttribute` class with the specified minimum and maximum bounds.

    minimum: double
    The minimum acceptable numeric value.
    maximum: double
    The maximum acceptable numeric value.
    errorMessage: string?
    The optional custom error message returned when validation fails.
  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the custom error message returned when validation fails.

  • propertyMaximum
    public double Maximum { get; }

    Gets the maximum acceptable numeric value.

  • propertyMinimum
    public double Minimum { get; }

    Gets the minimum acceptable numeric value.

class

ValidateRegexAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateRegexAttribute : Attribute
Inherits: Attribute

Validates that the decorated string matches the specified regular expression pattern.

Members (3)

  • constructorValidateRegexAttribute
    public ValidateRegexAttribute(string pattern, string? errorMessage = null)

    Initializes a new instance of the `ValidateRegexAttribute` class with the specified pattern.

    pattern: string
    The regular expression pattern used for validation.
    errorMessage: string?
    The optional custom error message returned when validation fails.
  • propertyErrorMessage
    public string? ErrorMessage { get; set; }

    Gets or sets the custom error message returned when validation fails.

  • propertyPattern
    public string Pattern { get; }

    Gets the regular expression pattern for validation.

class

ValidateRequestAttribute

Assembly: EricksonLopez.Mediator
public sealed class ValidateRequestAttribute : Attribute
Inherits: Attribute

Enables compile-time validation code generation for the decorated request type.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

EricksonLopez.Mediator.AspNetCore#

1
class

MediatorEndpointRouteBuilderExtensions

Assembly: EricksonLopez.Mediator.AspNetCore
public static class MediatorEndpointRouteBuilderExtensions

Provides extension methods on `IEndpointRouteBuilder` to map CQRS commands and queries as Minimal API endpoints.

Members (3)

  • methodMapCommand<TCommand, TResponse>
    public static RouteHandlerBuilder MapCommand<TCommand, TResponse>(this IEndpointRouteBuilder endpoints, string pattern) where TCommand : ICommand<TResponse>

    Maps an HTTP POST endpoint for the specified command type `TCommand`.

    endpoints: this IEndpointRouteBuilder
    The route builder to map the endpoint into.
    pattern: string
    The URL route pattern.

    Returns: A `RouteHandlerBuilder` that can be used to further customize the endpoint.

    Type parameters: TCommand: The command type implementing `ICommand<TResponse>`.; TResponse: The response type returned by the command handler. Exceptions: ArgumentNullException: `endpoints` or `pattern` is `null`

  • methodMapCommand<TCommand, TResponse>
    public static RouteHandlerBuilder MapCommand<TCommand, TResponse>(this IEndpointRouteBuilder endpoints, string pattern, string httpMethod) where TCommand : ICommand<TResponse>

    Maps an HTTP endpoint with the specified HTTP method for the specified command type `TCommand`.

    endpoints: this IEndpointRouteBuilder
    The route builder to map the endpoint into.
    pattern: string
    The URL route pattern.
    httpMethod: string
    The HTTP method to map (for example, "POST", "PUT", "DELETE").

    Returns: A `RouteHandlerBuilder` that can be used to further customize the endpoint.

    Type parameters: TCommand: The command type implementing `ICommand<TResponse>`.; TResponse: The response type returned by the command handler. Exceptions: ArgumentNullException: `endpoints`, `pattern`, or `httpMethod` is `null`

  • methodMapQuery<TQuery, TResponse>
    public static RouteHandlerBuilder MapQuery<TQuery, TResponse>(this IEndpointRouteBuilder endpoints, string pattern) where TQuery : IQuery<TResponse>

    Maps an HTTP GET endpoint for the specified query type `TQuery`.

    endpoints: this IEndpointRouteBuilder
    The route builder to map the endpoint into.
    pattern: string
    The URL route pattern.

    Returns: A `RouteHandlerBuilder` that can be used to further customize the endpoint.

    Type parameters: TQuery: The query type implementing `IQuery<TResponse>`.; TResponse: The response type returned by the query handler. Exceptions: ArgumentNullException: `endpoints` or `pattern` is `null`

EricksonLopez.Mediator.Behaviors#

2
class

MaxRecursionDepthBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator
public sealed class MaxRecursionDepthBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Pipeline behavior that intercepts and prevents unbounded recursive mediator dispatches (ELM014 / BREAK-001).

Remarks:

Type parameters: TRequest: The type of request being processed.; TResponse: The type of response returned by the handler.

Members (5)

  • constructorMaxRecursionDepthBehavior
    public MaxRecursionDepthBehavior()

    Initializes a new instance of the `MaxRecursionDepthBehavior<TRequest, TResponse>` class with default maximum depth of 64.

  • constructorMaxRecursionDepthBehavior
    public MaxRecursionDepthBehavior(int maxDepth)

    Initializes a new instance of the `MaxRecursionDepthBehavior<TRequest, TResponse>` class with the specified depth threshold.

    maxDepth: int
    The maximum recursion depth allowed before throwing an exception.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

  • propertyMaxDepth
    public int MaxDepth { get; init; }

    Gets or initializes the maximum allowed recursion depth threshold.

  • fieldDefaultMaxDepth
    public const int DefaultMaxDepth

    Specifies the default maximum recursion depth threshold.

class

MediatorRecursionContext

Assembly: EricksonLopez.Mediator
public static class MediatorRecursionContext

Provides access to the mediator dispatch recursion depth across the active asynchronous execution context.

Members (3)

  • methodReset
    public static void Reset()

    Resets the current recursion depth to zero for the active asynchronous execution context.

  • propertyCurrentDepth
    public static int CurrentDepth { get; }

    Gets the current mediator dispatch recursion depth in the active asynchronous execution context.

  • propertyDepth
    public static int Depth { get; }

    Gets the current mediator dispatch recursion depth (alias for `CurrentDepth`).

EricksonLopez.Mediator.Caching#

11
class

CacheInvalidationPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.Caching
public sealed class CacheInvalidationPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Post-commit cache invalidation pipeline behavior that inspects `IResultOutcome` without reflection or boxing and wraps distributed cache prefix evictions in a fail-safe `try/catch` boundary so transient Redis outages never fail an already-committed business transaction.

Remarks:

Type parameters: TRequest: The request type.; TResponse: The response type.

Members (2)

  • constructorCacheInvalidationPipelineBehavior
    public CacheInvalidationPipelineBehavior(ICacheProvider? cacheProvider = null, ITenantCacheContext? tenantContext = null, Action<Exception, string>? onInvalidationFailure = null)

    Initializes a new instance of the `CacheInvalidationPipelineBehavior<TRequest, TResponse>` class.

    cacheProvider: ICacheProvider?
    The optional distributed/hybrid cache provider.
    tenantContext: ITenantCacheContext?
    The optional tenant or tenant+company cache context.
    onInvalidationFailure: Action<Exception, string>?
    Optional diagnostic callback invoked when a post-commit eviction encounters an exception.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

class

CacheableAttribute

Assembly: EricksonLopez.Mediator.Caching
public sealed class CacheableAttribute : Attribute
Inherits: Attribute

Specifies caching metadata for a query or request type.

Members (2)

  • constructorCacheableAttribute
    public CacheableAttribute(int durationSeconds = 300)

    Initializes a new instance of the `CacheableAttribute` class.

    durationSeconds: int
    Expiration duration in seconds (default is 300s = 5 minutes).
  • propertyDurationSeconds
    public int DurationSeconds { get; }

    Gets the cache expiration duration in seconds.

class

CachingMediatorExtensions

Assembly: EricksonLopez.Mediator.Caching
public static class CachingMediatorExtensions

Provides extension methods for registering caching pipeline behaviors with dependency injection.

Members (2)

  • methodAddMediatorCacheInvalidation
    public static IServiceCollection AddMediatorCacheInvalidation(this IServiceCollection services)

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

    services: this IServiceCollection
    The service collection to register the behavior into.

    Returns: The same service collection instance for method chaining.

  • methodAddMediatorCaching
    public static IServiceCollection AddMediatorCaching(this IServiceCollection services)

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

    services: this IServiceCollection
    The service collection to register the behavior into.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

class

CachingPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.Caching
public sealed class CachingPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Provides transparent response caching for requests implementing `ICacheableRequest` and automated prefix invalidation for requests implementing `IInvalidateCacheRequest`.

Remarks:

Type parameters: TRequest: The request type.; TResponse: The response type.

Members (2)

  • constructorCachingPipelineBehavior
    public CachingPipelineBehavior(ICacheProvider? cacheProvider = null, ITenantCacheContext? tenantContext = null)

    Initializes a new instance of the `CachingPipelineBehavior<TRequest, TResponse>` class.

    cacheProvider: ICacheProvider?
    The optional cache provider.
    tenantContext: ITenantCacheContext?
    The optional tenant context for multi-tenant cache key isolation.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

interface

ICacheableRequest

Assembly: EricksonLopez.Mediator.Caching
public interface ICacheableRequest

Defines a request contract that enables transparent response caching within the mediator pipeline.

Members (2)

  • propertyCacheKey
    string CacheKey { get; }

    Gets the unique cache key for this request and its parameters.

  • propertyExpiration
    TimeSpan? Expiration { get; }

    Gets the optional custom expiration duration for the cached response.

interface

IInvalidateCacheRequest

Assembly: EricksonLopez.Mediator.Caching
public interface IInvalidateCacheRequest

Defines a request contract that triggers cache prefix invalidation upon successful completion.

Members (1)

  • propertyCachePrefix
    string CachePrefix { get; }

    Gets the cache key prefix to invalidate upon successful execution.

interface

IInvalidatesQueryCache

Assembly: EricksonLopez.Mediator.Caching
public interface IInvalidatesQueryCache

Defines a command contract that invalidates one or more logical query cache scopes after successful execution.

Members (2)

  • propertyInvalidateAllCompanyQueries
    bool InvalidateAllCompanyQueries { get; }

    Gets a value indicating whether all cached entries under the active tenant and company prefix should be evicted.

  • propertyInvalidatedScopes
    IReadOnlyList<string> InvalidatedScopes { get; }

    Gets the logical cache scopes (e.g., query names or domain scopes) to evict under the active tenant/company prefix.

interface

ITenantCacheContext

Assembly: EricksonLopez.Mediator.Caching
public interface ITenantCacheContext

Provides the ambient tenant identifier used by `CachingPipelineBehavior<TRequest, TResponse>` to isolate cached responses and cache invalidation prefixes per tenant.

Members (1)

  • propertyTenantId
    string? TenantId { get; }

    Gets the active tenant identifier for the current execution scope, or `null` if not tenant-scoped.

interface

ITenantCompanyCacheContext

Assembly: EricksonLopez.Mediator.Caching
public interface ITenantCompanyCacheContext : ITenantCacheContext
Implements: ITenantCacheContext

Extends `ITenantCacheContext` with the active company identifier for multi-tenant, multi-company holdings.

Members (1)

  • propertyCompanyId
    string? CompanyId { get; }

    Gets the active company identifier within the current tenant scope, or `null` if not company-scoped.

class

TenantCacheKeyFormatter

Assembly: EricksonLopez.Mediator.Caching
public static class TenantCacheKeyFormatter

Builds deterministic, tenant-isolated cache keys and invalidation prefixes for mediator requests.

Members (2)

  • methodFormatQueryKey
    public static string FormatQueryKey(string? tenantId, Type requestType, string cacheKey)

    Formats a tenant-isolated query cache key in the canonical format `tenant:{tenantId}:query:{requestTypeFullName}:{cacheKey}`.

    tenantId: string?
    The tenant identifier, or `null`/whitespace for non-tenant-scoped keys.
    requestType: Type
    The mediator request type.
    cacheKey: string
    The request-specific cache key segment.

    Returns: The formatted cache key.

  • methodScopeKey
    public static string ScopeKey(string? tenantId, string rawKey)

    Formats a cache key prefixed with the active tenant identifier when present.

    tenantId: string?
    The tenant identifier, or `null`/whitespace to return `rawKey` unchanged.
    rawKey: string
    The raw cache key or prefix.

    Returns: The tenant-scoped cache key or prefix.

class

TenantCompanyCacheKeyFormatter

Assembly: EricksonLopez.Mediator.Caching
public static class TenantCompanyCacheKeyFormatter

Builds deterministic, fail-closed multi-tenant and multi-company cache keys and invalidation prefixes in the canonical `tenant:{tid}:company:{cid}:{scope}:{key}` format.

Members (3)

  • methodFormat
    public static string Format(string? tenantId, string? companyId, string scope, string key)

    Formats a strictly isolated cache key as `tenant:{tenantId}:company:{companyId}:{scope}:{key}`. Fails closed by throwing `InvalidOperationException` if `tenantId` or `companyId` is missing or empty (`Guid.Empty`).

    tenantId: string?
    The active non-empty tenant identifier.
    companyId: string?
    The active non-empty company identifier.
    scope: string
    The logical cache scope (e.g., `query:GetProducts` or `inventory`).
    key: string
    The entry-specific key segment.

    Returns: The canonical formatted cache key.

    Exceptions: InvalidOperationException: `tenantId` or `companyId` is null, whitespace, or `Guid.Empty`.

  • methodFormatPrefix
    public static string FormatPrefix(string? tenantId, string? companyId, string? scope = null)

    Formats a deterministic eviction prefix `tenant:{tenantId}:company:{companyId}:` or `tenant:{tenantId}:company:{companyId}:{scope}:`, failing closed when tenant or company context is missing.

    tenantId: string?
    The active non-empty tenant identifier.
    companyId: string?
    The active non-empty company identifier.
    scope: string?
    Optional scope suffix.

    Returns: The canonical eviction prefix.

  • methodFormatQueryKey
    public static string FormatQueryKey(string? tenantId, string? companyId, Type requestType, string cacheKey)

    Formats a query cache key as `tenant:{tenantId}:company:{companyId}:query:{requestTypeName}:{cacheKey}`.

    tenantId: string?
    The active non-empty tenant identifier.
    companyId: string?
    The active non-empty company identifier.
    requestType: Type
    The query request type.
    cacheKey: string
    The query-specific cache key segment.

    Returns: The canonical formatted query cache key.

EricksonLopez.Mediator.FluentValidation#

1
class

ValidationPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.FluentValidation
public sealed class ValidationPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Provides a pipeline behavior that executes registered `IValidator<T>` instances prior to handler execution.

Remarks:

Behavior: All registered validators for `TRequest` are executed concurrently via `Task.WhenAll`. If any validator produces failures, the behavior short-circuits in one of three ways: - If an `IResultFactory<TResponse>` is registered for `TResponse`, returns a failure result constructed by the factory without throwing. - If `TResponse` is non-generic `Result`, returns a failure result directly without throwing. - Otherwise, throws a `ValidationException` containing all validation failures. Registration: Use `AddMediatorFluentValidation()` to register this behavior and explicitly register validators via `AddMediatorFluentValidationValidator<TValidator>()` or assembly scanning via `AddMediatorFluentValidatorsFromAssembly()`. AOT / Trimming: `ValidationPipelineBehavior<TRequest, TResponse>` itself is AOT-safe when validators are registered explicitly. Assembly scanning (`AddMediatorFluentValidatorsFromAssembly`) uses reflection and is annotated with `CodeAnalysis.RequiresUnreferencedCodeAttribute`. CancellationToken: The `cancellationToken` is forwarded to each `IValidator<T>.ValidateAsync` call. Cancellation before all validators complete causes a `TaskCanceledException`. Replaces: `EricksonLopez.Mediator.Validation.ValidationBehavior<TRequest, TResponse>` which was deprecated in ADR-033. Type parameters: TRequest: The type of request being validated. Must implement `ICommand<TResponse>` or `IQuery<TResponse>`.; TResponse: The type of response returned by the pipeline.

Members (2)

  • constructorValidationPipelineBehavior
    public ValidationPipelineBehavior(IEnumerable<IValidator<TRequest>>? validators = null, IResultFactory<TResponse>? resultFactory = null)

    Initializes a new instance of the `ValidationPipelineBehavior<TRequest, TResponse>` class.

    validators: IEnumerable<IValidator<TRequest>>?
    The collection of `IValidator<T>` instances applied to `TRequest`. When empty or `null`, no validation is performed and the next delegate is invoked directly.
    resultFactory: IResultFactory<TResponse>?
    An optional factory that constructs a failure response of type `TResponse` from a validation error. When `null`, a `ValidationException` is thrown instead.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate. Exceptions: ValidationException: Validation fails and no `IResultFactory<TResponse>` is registered

EricksonLopez.Mediator.Generator#

10
record

BehaviorDefinition

Assembly: EricksonLopez.Mediator.Generator
public record BehaviorDefinition(string BehaviorType, string Lifetime)

Represents the metadata of a discovered pipeline behavior and its service lifetime using symbol-free value records.

Members (3)

  • constructorBehaviorDefinition
    public BehaviorDefinition(string BehaviorType, string Lifetime)

    Initializes a new instance of BehaviorDefinition.

    BehaviorType: string
    The fully qualified type name representing the pipeline behavior.
    Lifetime: string
    The configured dependency injection lifetime for the behavior.
  • propertyBehaviorType
    public string BehaviorType { get; init; }

    The fully qualified type name representing the pipeline behavior.

  • propertyLifetime
    public string Lifetime { get; init; }

    The configured dependency injection lifetime for the behavior.

class

DependencyInjectionGenerator

Assembly: EricksonLopez.Mediator.Generator
public static class DependencyInjectionGenerator

Generates dependency injection registration code for discovered mediator components. Uses deterministic sorting, tooling compliance attributes, and gated contract emission (REM-10, REM-13).

Members (1)

  • methodGenerate
    public static string Generate(MediatorModel model)

    Generates C# source code for registering mediator components into an `IServiceCollection`.

    model: MediatorModel
    The model containing discovered handlers, behaviors, and pipeline metadata.

    Returns: A string containing the generated C# source code.

class

DispatcherGenerator

Assembly: EricksonLopez.Mediator.Generator
public static class DispatcherGenerator

Generates compile-time strongly typed mediator dispatchers. Implements REM-01 (nested type naming), REM-02 (zero-alloc struct monomorphization), REM-10 (deterministic sorting), and REM-13 ([GeneratedCode], semantic validations, switch splitting).

Members (1)

  • methodGenerate
    public static string Generate(MediatorModel model)

    Generates C# source code for the concrete mediator dispatcher implementation.

    model: MediatorModel
    The model containing discovered handlers, behaviors, and pipeline metadata.

    Returns: A string containing the generated C# source code.

struct

EquatableArray<T>

Assembly: EricksonLopez.Mediator.Generator
public readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IReadOnlyList<T>
Implements: IEquatable<EquatableArray<T>>, IReadOnlyList<T>

Represents an immutable array that provides value-based equality semantics.

Remarks:

This struct wraps an underlying array and computes value equality based on sequence elements. Type parameters: T: The type of elements in the array.

Members (14)

  • constructorEquatableArray
    public EquatableArray(T[]? array)

    Initializes a new instance of the `EquatableArray<T>` struct with the specified array.

    array: T[]?
    The underlying array to wrap.
  • methodAsSpan
    public ReadOnlySpan<T> AsSpan()

    Creates a read-only span over the underlying array.

    Returns: A read-only span covering the elements of the array.

  • methodEquals
    public bool Equals(EquatableArray<T> other)

    Determines whether the specified `EquatableArray<T>` is equal to the current instance.

    other: EquatableArray<T>
    The array to compare with the current instance.

    Returns: `true` if the specified array is equal to the current instance; otherwise, `false`.

  • methodEquals
    public override bool Equals(object? obj)

    Inherits documentation from base type or interface.

    obj: object?
  • methodGetEnumerator
    public IEnumerator<T> GetEnumerator()

    Returns an enumerator that iterates through the collection.

    Returns: An enumerator that can be used to iterate through the collection.

  • methodGetHashCode
    public override int GetHashCode()

    Inherits documentation from base type or interface.

  • methodToArray
    public T[] ToArray()

    Copies the elements of the `EquatableArray<T>` to a new array.

    Returns: An array containing copies of the elements of the `EquatableArray<T>`.

  • methodToList
    public List<T> ToList()

    Creates a new `List<T>` containing the elements of the array.

    Returns: A new list containing the elements of the array.

  • methodimplicit operator EquatableArray<T>
    public static implicit operator EquatableArray<T>(T[] array)

    Converts an array of type `T` to an `EquatableArray<T>` instance.

    array: T[]
    The array to convert.

    Returns: A new `EquatableArray<T>` instance wrapping the specified array.

  • methodoperator !=
    public static bool operator !=(EquatableArray<T> left, EquatableArray<T> right)

    Determines whether two specified instances of `EquatableArray<T>` are not equal.

    left: EquatableArray<T>
    The first array to compare.
    right: EquatableArray<T>
    The second array to compare.

    Returns: `true` if the arrays are not equal; otherwise, `false`.

  • methodoperator ==
    public static bool operator ==(EquatableArray<T> left, EquatableArray<T> right)

    Determines whether two specified instances of `EquatableArray<T>` are equal.

    left: EquatableArray<T>
    The first array to compare.
    right: EquatableArray<T>
    The second array to compare.

    Returns: `true` if the arrays are equal; otherwise, `false`.

  • propertyCount
    public int Count { get; }

    Gets the number of elements contained in the array.

  • propertyEmpty
    public static EquatableArray<T> Empty { get; }

    Gets an empty `EquatableArray<T>`.

  • propertythis[int index]
    public T this[int index] { get; }

    Gets the element at the specified zero-based index.

    index: int
    The zero-based index of the element to retrieve.

    Returns: The element at the specified index.

    Exceptions: IndexOutOfRangeException: `index` is less than zero or greater than or equal to `Count`

record

HandlerDefinition

Assembly: EricksonLopez.Mediator.Generator
public record HandlerDefinition(string HandlerType, string RequestType, string ResponseType, EquatableArray<string> Behaviors, string Lifetime, EquatableArray<PropertyValidation> Validations, string? RequestSafeName)

Represents the metadata of a discovered mediator handler using symbol-free value records.

Members (8)

  • constructorHandlerDefinition
    public HandlerDefinition(string HandlerType, string RequestType, string ResponseType, EquatableArray<string> Behaviors, string Lifetime, EquatableArray<PropertyValidation> Validations = default, string? RequestSafeName = null)

    Initializes a new instance of HandlerDefinition.

    HandlerType: string
    The fully qualified type name of the handler.
    RequestType: string
    The fully qualified type name of the request processed by the handler.
    ResponseType: string
    The fully qualified type name of the response produced by the handler.
    Behaviors: EquatableArray<string>
    The pipeline behavior fully qualified type names applicable to this handler.
    Lifetime: string
    The configured dependency injection lifetime.
    Validations: EquatableArray<PropertyValidation>
    The collection of property validation rules for the request.
    RequestSafeName: string?
    The identifier-safe name for synthesized structs.
  • propertyBehaviors
    public EquatableArray<string> Behaviors { get; init; }

    The pipeline behavior fully qualified type names applicable to this handler.

  • propertyHandlerType
    public string HandlerType { get; init; }

    The fully qualified type name of the handler.

  • propertyLifetime
    public string Lifetime { get; init; }

    The configured dependency injection lifetime.

  • propertyRequestSafeName
    public string? RequestSafeName { get; init; }

    The identifier-safe name for synthesized structs.

  • propertyRequestType
    public string RequestType { get; init; }

    The fully qualified type name of the request processed by the handler.

  • propertyResponseType
    public string ResponseType { get; init; }

    The fully qualified type name of the response produced by the handler.

  • propertyValidations
    public EquatableArray<PropertyValidation> Validations { get; init; }

    The collection of property validation rules for the request.

record

MediatorModel

Assembly: EricksonLopez.Mediator.Generator
public record MediatorModel(EquatableArray<HandlerDefinition> CommandHandlers, EquatableArray<HandlerDefinition> QueryHandlers, EquatableArray<HandlerDefinition> NotificationHandlers, EquatableArray<NotificationDefinition> Notifications, EquatableArray<HandlerDefinition> StreamHandlers, EquatableArray<BehaviorDefinition> AllBehaviors, EquatableArray<string> ResultResponseTypes, bool HasResultFactoryContract)

Represents the aggregated compilation model containing all discovered mediator components using symbol-free value records.

Members (9)

  • constructorMediatorModel
    public MediatorModel(EquatableArray<HandlerDefinition> CommandHandlers, EquatableArray<HandlerDefinition> QueryHandlers, EquatableArray<HandlerDefinition> NotificationHandlers, EquatableArray<NotificationDefinition> Notifications, EquatableArray<HandlerDefinition> StreamHandlers, EquatableArray<BehaviorDefinition> AllBehaviors, EquatableArray<string> ResultResponseTypes, bool HasResultFactoryContract = false)

    Initializes a new instance of MediatorModel.

    CommandHandlers: EquatableArray<HandlerDefinition>
    The discovered command handlers.
    QueryHandlers: EquatableArray<HandlerDefinition>
    The discovered query handlers.
    NotificationHandlers: EquatableArray<HandlerDefinition>
    The discovered notification handlers.
    Notifications: EquatableArray<NotificationDefinition>
    The discovered notification definitions grouped by notification type.
    StreamHandlers: EquatableArray<HandlerDefinition>
    The discovered stream request handlers.
    AllBehaviors: EquatableArray<BehaviorDefinition>
    All discovered pipeline behaviors across the compilation.
    ResultResponseTypes: EquatableArray<string>
    All response type names implementing the result pattern.
    HasResultFactoryContract: bool
    Indicates whether IResultFactory contract is present in compilation references.
  • propertyAllBehaviors
    public EquatableArray<BehaviorDefinition> AllBehaviors { get; init; }

    All discovered pipeline behaviors across the compilation.

  • propertyCommandHandlers
    public EquatableArray<HandlerDefinition> CommandHandlers { get; init; }

    The discovered command handlers.

  • propertyHasResultFactoryContract
    public bool HasResultFactoryContract { get; init; }

    Indicates whether IResultFactory contract is present in compilation references.

  • propertyNotificationHandlers
    public EquatableArray<HandlerDefinition> NotificationHandlers { get; init; }

    The discovered notification handlers.

  • propertyNotifications
    public EquatableArray<NotificationDefinition> Notifications { get; init; }

    The discovered notification definitions grouped by notification type.

  • propertyQueryHandlers
    public EquatableArray<HandlerDefinition> QueryHandlers { get; init; }

    The discovered query handlers.

  • propertyResultResponseTypes
    public EquatableArray<string> ResultResponseTypes { get; init; }

    All response type names implementing the result pattern.

  • propertyStreamHandlers
    public EquatableArray<HandlerDefinition> StreamHandlers { get; init; }

    The discovered stream request handlers.

class

MediatorModelBuilder

Assembly: EricksonLopez.Mediator.Generator
public static class MediatorModelBuilder

Provides analysis and model building capabilities for mediator components in a Roslyn compilation.

Members (2)

  • methodBuild
    public static MediatorModel? Build(Compilation compilation, List<INamedTypeSymbol> types, SourceProductionContext context)

    Builds the mediator model from the specified compilation and discovered types. Preserved for backward compatibility with generator test drivers.

    compilation: Compilation
    The Roslyn compilation unit.
    types: List<INamedTypeSymbol>
    The list of candidate message and handler type symbols.
    context: SourceProductionContext
    The source production context for reporting diagnostics.

    Returns: The constructed `MediatorModel`, or `null` if model generation should abort.

  • methodGetSafeStructName
    public static string GetSafeStructName(INamedTypeSymbol typeSymbol)

    Implements stack-based ContainingType traversal to synthesize unique, collision-free struct identifiers (REM-01).

    typeSymbol: INamedTypeSymbol
    The named type symbol whose identifier is synthesized.

    Returns: A collision-free struct identifier string.

class

MediatorSourceGenerator

Assembly: EricksonLopez.Mediator.Generator
public sealed class MediatorSourceGenerator : IIncrementalGenerator
Implements: IIncrementalGenerator

Generates compile-time dispatchers and dependency injection registrations for mediator handlers and behaviors. Uses symbol-free value records and incremental caching (REM-09).

Members (1)

  • methodInitialize
    public void Initialize(IncrementalGeneratorInitializationContext context)

    Inherits documentation from base type or interface.

    context: IncrementalGeneratorInitializationContext
record

NotificationDefinition

Assembly: EricksonLopez.Mediator.Generator
public record NotificationDefinition(string NotificationType, EquatableArray<string> Behaviors, string PublishStrategy, EquatableArray<HandlerDefinition> Handlers, string? NotificationSafeName)

Represents the discovered metadata for a notification type and its associated handlers and behaviors using symbol-free value records.

Members (6)

  • constructorNotificationDefinition
    public NotificationDefinition(string NotificationType, EquatableArray<string> Behaviors, string PublishStrategy, EquatableArray<HandlerDefinition> Handlers, string? NotificationSafeName = null)

    Initializes a new instance of NotificationDefinition.

    NotificationType: string
    The fully qualified type name representing the notification.
    Behaviors: EquatableArray<string>
    The collection of pipeline behavior fully qualified type names applied to this notification.
    PublishStrategy: string
    The execution strategy name used when publishing the notification.
    Handlers: EquatableArray<HandlerDefinition>
    The collection of discovered notification handlers.
    NotificationSafeName: string?
    The identifier-safe name for synthesized structs.
  • propertyBehaviors
    public EquatableArray<string> Behaviors { get; init; }

    The collection of pipeline behavior fully qualified type names applied to this notification.

  • propertyHandlers
    public EquatableArray<HandlerDefinition> Handlers { get; init; }

    The collection of discovered notification handlers.

  • propertyNotificationSafeName
    public string? NotificationSafeName { get; init; }

    The identifier-safe name for synthesized structs.

  • propertyNotificationType
    public string NotificationType { get; init; }

    The fully qualified type name representing the notification.

  • propertyPublishStrategy
    public string PublishStrategy { get; init; }

    The execution strategy name used when publishing the notification.

record

PropertyValidation

Assembly: EricksonLopez.Mediator.Generator
public record PropertyValidation(string PropertyName, string PropertyType, string RuleType, string? CustomMessage, double Min, double Max, int MinLength, int MaxLength, string? RegexPattern, bool IsGuid, bool HasLength, bool HasCount)

Represents a compile-time property validation rule defined on a request.

Members (13)

  • constructorPropertyValidation
    public PropertyValidation(string PropertyName, string PropertyType, string RuleType, string? CustomMessage, double Min, double Max, int MinLength, int MaxLength, string? RegexPattern, bool IsGuid = false, bool HasLength = false, bool HasCount = false)

    Initializes a new instance of PropertyValidation.

    PropertyName: string
    The name of the property being validated.
    PropertyType: string
    The string representation of the property type.
    RuleType: string
    The kind of validation rule to enforce.
    CustomMessage: string?
    The optional custom error message when validation fails.
    Min: double
    The minimum numeric bound for range validation.
    Max: double
    The maximum numeric bound for range validation.
    MinLength: int
    The minimum character length bound for string length validation.
    MaxLength: int
    The maximum character length bound for string length validation.
    RegexPattern: string?
    The regular expression pattern for regex validation.
    IsGuid: bool
    Indicates if the property type is semantically System.Guid.
    HasLength: bool
    Indicates if the property type semantically has a public Length property or is string/array.
    HasCount: bool
    Indicates if the property type semantically has a public Count property or implements ICollection.
  • propertyCustomMessage
    public string? CustomMessage { get; init; }

    The optional custom error message when validation fails.

  • propertyHasCount
    public bool HasCount { get; init; }

    Indicates if the property type semantically has a public Count property or implements ICollection.

  • propertyHasLength
    public bool HasLength { get; init; }

    Indicates if the property type semantically has a public Length property or is string/array.

  • propertyIsGuid
    public bool IsGuid { get; init; }

    Indicates if the property type is semantically System.Guid.

  • propertyMax
    public double Max { get; init; }

    The maximum numeric bound for range validation.

  • propertyMaxLength
    public int MaxLength { get; init; }

    The maximum character length bound for string length validation.

  • propertyMin
    public double Min { get; init; }

    The minimum numeric bound for range validation.

  • propertyMinLength
    public int MinLength { get; init; }

    The minimum character length bound for string length validation.

  • propertyPropertyName
    public string PropertyName { get; init; }

    The name of the property being validated.

  • propertyPropertyType
    public string PropertyType { get; init; }

    The string representation of the property type.

  • propertyRegexPattern
    public string? RegexPattern { get; init; }

    The regular expression pattern for regex validation.

  • propertyRuleType
    public string RuleType { get; init; }

    The kind of validation rule to enforce.

EricksonLopez.Mediator.Generator.Analyzers#

4
class

DiagnosticDescriptors

Assembly: EricksonLopez.Mediator.Generator
public static class DiagnosticDescriptors

Centralized diagnostic descriptors for the EricksonLopez.Mediator analyzer and generator suite. Fixes DEFECT-GEN-05 by caching all descriptors in static readonly instances.

Members (17)

  • fieldELM001
    public static readonly DiagnosticDescriptor ELM001

    ELM001: Handler Not Found.

  • fieldELM002
    public static readonly DiagnosticDescriptor ELM002

    ELM002: Multiple Command Handlers.

  • fieldELM003
    public static readonly DiagnosticDescriptor ELM003

    ELM003: Multiple Query Handlers.

  • fieldELM004Behavior
    public static readonly DiagnosticDescriptor ELM004Behavior

    ELM004: Invalid Behavior Signature.

  • fieldELM004Handler
    public static readonly DiagnosticDescriptor ELM004Handler

    ELM004: Invalid Command/Query Handler Signature.

  • fieldELM004NotificationHandler
    public static readonly DiagnosticDescriptor ELM004NotificationHandler

    ELM004: Invalid Notification Handler Signature.

  • fieldELM005
    public static readonly DiagnosticDescriptor ELM005

    ELM005: Open Generic Handler Not Supported.

  • fieldELM006
    public static readonly DiagnosticDescriptor ELM006

    ELM006: Notification Handler Not Found.

  • fieldELM007Notification
    public static readonly DiagnosticDescriptor ELM007Notification

    ELM007: Unsupported Open Generic Notification Behavior.

  • fieldELM007Request
    public static readonly DiagnosticDescriptor ELM007Request

    ELM007: Unsupported Open Generic Request Behavior.

  • fieldELM008
    public static readonly DiagnosticDescriptor ELM008

    ELM008: Behavior Order Conflict.

  • fieldELM009
    public static readonly DiagnosticDescriptor ELM009

    ELM009: Stream Handler Not Found.

  • fieldELM010
    public static readonly DiagnosticDescriptor ELM010

    ELM010: Multiple Stream Handlers.

  • fieldELM011
    public static readonly DiagnosticDescriptor ELM011

    ELM011: Invalid Stream Handler Signature.

  • fieldELM012
    public static readonly DiagnosticDescriptor ELM012

    ELM012: Captive Scoped Dependency or Disposable Handler in StaticMediator (REM-04, BREAK-002).

  • fieldELM013
    public static readonly DiagnosticDescriptor ELM013

    ELM013: Message Contract Must Be Immutable (REM-14, BREAK-010).

  • fieldELM014
    public static readonly DiagnosticDescriptor ELM014

    ELM014: Pipeline Behavior Registered in DI Without Matching [UseGlobalBehavior] Attribute.

class

ImmutabilityAnalyzer

Assembly: EricksonLopez.Mediator.Generator
public sealed class ImmutabilityAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Roslyn diagnostic analyzer ELM013: Enforces immutability on message contracts (ICommand, IQuery, INotification, IStreamRequest). Flags public setters, mutable fields, and non-readonly structs. Addresses REM-14, BREAK-010, FIND-ARCH-001, and THREAT-03.

Members (3)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Defines the diagnostic identifier for message immutability violations.

class

PipelineRegistrationParityAnalyzer

Assembly: EricksonLopez.Mediator.Generator
public sealed class PipelineRegistrationParityAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Roslyn diagnostic analyzer `ELM014` detecting open-generic `IPipelineBehavior<,>` registrations in `IServiceCollection` that lack a corresponding `[assembly: UseGlobalBehavior(...)]` attribute when compile-time global pipeline generation is active in the compilation.

Members (3)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Diagnostic ID emitted when a DI-registered open-generic behavior is omitted from `[UseGlobalBehavior]`.

class

StaticMediatorCaptiveDependencyAnalyzer

Assembly: EricksonLopez.Mediator.Generator
public sealed class StaticMediatorCaptiveDependencyAnalyzer : DiagnosticAnalyzer
Inherits: DiagnosticAnalyzer

Roslyn diagnostic analyzer ELM012: Detects captive scoped dependencies (*DbContext, Scoped lifetime) and unmanaged disposable types (IDisposable, IAsyncDisposable) in handlers registered with StaticMediator. Addresses REM-04, BREAK-002, FIND-DI-002, THREAT-01, and THREAT-08.

Members (3)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Defines the diagnostic identifier for captive scoped dependencies in StaticMediator.

EricksonLopez.Mediator.HealthChecks#

1
class

MediatorHealthCheck

Assembly: EricksonLopez.Mediator
public sealed class MediatorHealthCheck : IHealthCheck
Implements: IHealthCheck

Provides health check verification for the mediator dispatch pipeline and service registration.

Members (2)

  • constructorMediatorHealthCheck
    public MediatorHealthCheck(ISender? sender = null)

    Initializes a new instance of the `MediatorHealthCheck` class.

    sender: ISender?
    The optional sender service used to verify mediator registration.
  • methodCheckHealthAsync
    public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    context: HealthCheckContext
    cancellationToken: CancellationToken

EricksonLopez.Mediator.OpenTelemetry#

6
class

MediatorMetrics

Assembly: EricksonLopez.Mediator.OpenTelemetry
public static class MediatorMetrics

Provides OpenTelemetry metrics instrumentation counters and histograms for mediator operations.

Members (12)

  • propertyMeterInstance
    public static Meter MeterInstance { get; }

    Gets the underlying `Metrics.Meter` instance.

  • propertyNotificationCounter
    public static Counter<long> NotificationCounter { get; }

    Gets the counter for total notifications published.

  • propertyRequestCounter
    public static Counter<long> RequestCounter { get; }

    Gets the counter for total requests dispatched.

  • propertyRequestDurationHistogram
    public static Histogram<double> RequestDurationHistogram { get; }

    Gets the histogram for request durations.

  • propertyRequestFailureCounter
    public static Counter<long> RequestFailureCounter { get; }

    Gets the counter for total request failures.

  • fieldMeterName
    public const string MeterName

    Defines the name of the OpenTelemetry meter.

  • fieldMeterVersion
    public const string MeterVersion

    Defines the version of the OpenTelemetry meter.

  • fieldNotificationsTotalMetricName
    public const string NotificationsTotalMetricName

    Defines the metric name for total notifications.

  • fieldRequestDurationMetricName
    public const string RequestDurationMetricName

    Defines the metric name for request duration.

  • fieldRequestsFailuresMetricName
    public const string RequestsFailuresMetricName

    Defines the metric name for request failures.

  • fieldRequestsTotalMetricName
    public const string RequestsTotalMetricName

    Defines the metric name for total requests.

  • fieldVersion
    public const string Version

    Defines the version of the OpenTelemetry meter.

class

MediatorOpenTelemetryOptions

Assembly: EricksonLopez.Mediator.OpenTelemetry
public sealed class MediatorOpenTelemetryOptions

Specifies configuration options for OpenTelemetry activity and metric instrumentation in the mediator pipeline.

Members (3)

  • propertyActivitySourceName
    public string ActivitySourceName { get; set; }

    Gets or sets the name of the `ActivitySource` for distributed tracing.

  • propertyEnrichActivity
    public Action<Activity, object>? EnrichActivity { get; set; }

    Gets or sets a callback delegate used to enrich created `Activity` instances with custom tags.

  • propertySlo
    public MediatorSloOptions Slo { get; set; }

    Gets or sets the Service Level Objective (SLO) thresholds applied during request instrumentation.

class

MediatorSloOptions

Assembly: EricksonLopez.Mediator.OpenTelemetry
public sealed class MediatorSloOptions

Codifies Service Level Objective (SLO) availability, latency, and freshness thresholds for Mediator pipeline telemetry.

Members (6)

  • propertyAvailabilityTarget
    public double AvailabilityTarget { get; set; }

    Gets or sets the target availability ratio between 0 and 1 (defaults to `0.999` / 99.9%).

  • propertyCriticalLatencyP99Ms
    public double CriticalLatencyP99Ms { get; set; }

    Gets or sets the critical command P99 latency ceiling in milliseconds (defaults to `1000` ms).

  • propertyDataFreshnessSeconds
    public int DataFreshnessSeconds { get; set; }

    Gets or sets the read-projection freshness budget in seconds (defaults to `30` s).

  • propertyLatencyP95Ms
    public double LatencyP95Ms { get; set; }

    Gets or sets the P95 request latency budget in milliseconds (defaults to `200` ms).

  • propertyLatencyP99Ms
    public double LatencyP99Ms { get; set; }

    Gets or sets the P99 request latency budget in milliseconds (defaults to `500` ms).

  • propertyMeterName
    public string MeterName { get; set; }

    Gets or sets the OpenTelemetry meter name (defaults to `MediatorMetrics.MeterName`).

class

OpenTelemetryBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.OpenTelemetry
public sealed class OpenTelemetryBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Represents a pipeline behavior that generates OpenTelemetry distributed traces and records request metrics.

Remarks:

Combines distributed tracing via `ActivitySource` with metrics via `Metrics.Meter`. Operates with zero overhead when no trace or metric listeners are attached. Type parameters: TRequest: The type of request being traced.; TResponse: The type of response returned by the pipeline.

Members (4)

  • constructorOpenTelemetryBehavior
    public OpenTelemetryBehavior()

    Initializes a new instance of the `OpenTelemetryBehavior<TRequest, TResponse>` class with default options.

  • constructorOpenTelemetryBehavior
    public OpenTelemetryBehavior(MediatorOpenTelemetryOptions? options = null)

    Initializes a new instance of the `OpenTelemetryBehavior<TRequest, TResponse>` class with the specified options.

    options: MediatorOpenTelemetryOptions?
    The configuration options for OpenTelemetry instrumentation. When `null`, the default activity source name and no enrichment callback are used.
  • constructorOpenTelemetryBehavior
    public OpenTelemetryBehavior(MediatorSloOptions sloOptions)

    Initializes a new instance of the `OpenTelemetryBehavior<TRequest, TResponse>` class with explicit `MediatorSloOptions`.

    sloOptions: MediatorSloOptions
    The SLO thresholds to enforce on trace tags.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

class

OpenTelemetryNotificationBehavior<TNotification>

Assembly: EricksonLopez.Mediator.OpenTelemetry
public sealed class OpenTelemetryNotificationBehavior<TNotification> : INotificationBehavior<TNotification> where TNotification : INotification
Implements: INotificationBehavior<TNotification>

Pipeline behavior that records OpenTelemetry notification metrics during notification publishing.

Remarks:

Type parameters: TNotification: The type of notification being dispatched.

Members (1)

  • methodHandle<TNext>
    public async ValueTask Handle<TNext>(TNotification notification, TNext next, CancellationToken cancellationToken) where TNext : struct, INext

    Intercepts the notification publishing pipeline and invokes the next step.

    notification: TNotification
    The notification instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or handlers.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

class

ServiceCollectionExtensions

Assembly: EricksonLopez.Mediator.OpenTelemetry
public static class ServiceCollectionExtensions

Provides extension methods for configuring OpenTelemetry instrumentation with dependency injection.

Members (1)

  • methodAddMediatorOpenTelemetry
    public static IServiceCollection AddMediatorOpenTelemetry(this IServiceCollection services, Action<MediatorOpenTelemetryOptions>? configure = null)

    Registers and configures OpenTelemetry instrumentation options for the mediator pipeline.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<MediatorOpenTelemetryOptions>?
    An optional delegate used to configure `MediatorOpenTelemetryOptions`.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Mediator.Polly#

3
class

MediatorPollyExtensions

Assembly: EricksonLopez.Mediator.Polly
public static class MediatorPollyExtensions

Provides extension methods for configuring Polly resilience pipelines in dependency injection.

Remarks:

This class is obsolete. Migrate to `EricksonLopez.Resilience.Mediator` from the `EricksonLopez.Resilience` ecosystem.

Members (2)

  • methodAddMediatorDefaultResiliencePipeline
    public static IServiceCollection AddMediatorDefaultResiliencePipeline(this IServiceCollection services, Action<ResiliencePipelineBuilder> configure)

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

    services: this IServiceCollection
    The service collection to register the pipeline into.
    configure: Action<ResiliencePipelineBuilder>
    A delegate used to configure the resilience pipeline builder.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

  • methodAddMediatorPolly
    public static IServiceCollection AddMediatorPolly(this IServiceCollection services)

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

    services: this IServiceCollection
    The service collection to register the behavior into.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

class

PollyResilienceBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.Polly
public sealed class PollyResilienceBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Represents a pipeline behavior that executes requests within a Polly resilience pipeline.

Remarks:

Deprecation Notice: This behavior is deprecated in favor of `EricksonLopez.Resilience.Mediator` from the `EricksonLopez.Resilience` package ecosystem, which adheres to Clean Architecture by decoupling application handlers from direct Polly dependencies. If `TRequest` is decorated with `UseResiliencePipelineAttribute`, this behavior resolves the named resilience pipeline from `ResiliencePipelineProvider<TKey>` and wraps handler execution with the configured Polly strategy (retry, circuit breaker, timeout, etc.). AOT / Trimming: This type uses `GetCustomAttribute` in a closed-generic static initializer to cache the pipeline key. The `CodeAnalysis.DynamicallyAccessedMembersAttribute` on `TRequest` ensures the `UseResiliencePipelineAttribute` metadata is preserved under trimming when applied by the Source Generator or manually. Type parameters: TRequest: The type of the request being handled.; TResponse: The type of the response expected from the pipeline.

Members (2)

  • constructorPollyResilienceBehavior
    public PollyResilienceBehavior(ResiliencePipelineProvider<string>? pipelineProvider = null, ResiliencePipeline? defaultPipeline = null)

    Initializes a new instance of the `PollyResilienceBehavior<TRequest, TResponse>` class.

    pipelineProvider: ResiliencePipelineProvider<string>?
    The optional resilience pipeline provider used to resolve keyed pipelines.
    defaultPipeline: ResiliencePipeline?
    The optional fallback resilience pipeline.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

class

UseResiliencePipelineAttribute

Assembly: EricksonLopez.Mediator.Polly
public sealed class UseResiliencePipelineAttribute : Attribute
Inherits: Attribute

Specifies the key of the Polly resilience pipeline to apply to the decorated request type.

Remarks:

This attribute is obsolete. Migrate to `EricksonLopez.Resilience.Mediator` from the `EricksonLopez.Resilience` ecosystem.

Members (2)

  • constructorUseResiliencePipelineAttribute
    public UseResiliencePipelineAttribute(string pipelineKey)

    Initializes a new instance of the `UseResiliencePipelineAttribute` class with the specified pipeline key.

    pipelineKey: string
    The unique key identifying the resilience pipeline.

    Exceptions: ArgumentNullException: `pipelineKey` is `null`

  • propertyPipelineKey
    public string PipelineKey { get; }

    Gets the key of the resilience pipeline configured in the Polly registry.

EricksonLopez.Mediator.RateLimiting#

3
class

RateLimitExceededException

Assembly: EricksonLopez.Mediator.RateLimiting
public sealed class RateLimitExceededException : Exception
Inherits: Exception

Represents an exception thrown when a request is rejected due to rate limits being exceeded.

Members (2)

  • constructorRateLimitExceededException
    public RateLimitExceededException(string message, TimeSpan? retryAfter = null)

    Initializes a new instance of the `RateLimitExceededException` class with the specified error message and optional retry duration.

    message: string
    The message that describes the rate limit failure.
    retryAfter: TimeSpan?
    The optional wait duration before retrying the operation.
  • propertyRetryAfter
    public TimeSpan? RetryAfter { get; }

    Gets the suggested duration to wait before retrying the operation, if provided by the rate limiter.

class

RateLimitingBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.RateLimiting
public sealed class RateLimitingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Represents a pipeline behavior that enforces throughput constraints using a `RateLimiter`.

Remarks:

Type parameters: TRequest: The type of request being processed.; TResponse: The type of response returned by the pipeline.

Members (2)

  • constructorRateLimitingBehavior
    public RateLimitingBehavior(RateLimiter? rateLimiter = null)

    Initializes a new instance of the `RateLimitingBehavior<TRequest, TResponse>` class.

    rateLimiter: RateLimiter?
    The optional rate limiter instance used to acquire execution leases.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate. Exceptions: RateLimitExceededException: The rate limit is exceeded and permit acquisition fails

class

RateLimitingMediatorExtensions

Assembly: EricksonLopez.Mediator.RateLimiting
public static class RateLimitingMediatorExtensions

Provides extension methods for registering rate limiting mediator behaviors in dependency injection.

Members (1)

  • methodAddMediatorRateLimiting
    public static IServiceCollection AddMediatorRateLimiting(this IServiceCollection services)

    Registers the rate limiting pipeline behavior with the service collection.

    services: this IServiceCollection
    The service collection to register the behavior into.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Mediator.Result#

3
interface

IResultFactory<TResponse>

Assembly: EricksonLopez.Mediator.Result
public interface IResultFactory<TResponse>

Defines a factory for creating strongly typed failure responses without runtime reflection.

Remarks:

This abstraction allows pipeline behaviors to short-circuit execution by producing typed failure results. Type parameters: TResponse: The type of the failure response to create.

Members (1)

  • methodCreateFailure
    TResponse CreateFailure(Error error)

    Creates a failure response containing the specified error metadata.

    error: Error
    The error metadata detailing why the operation failed.

    Returns: A failure response of type `TResponse`.

class

InputSafetyPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Mediator.Result
public sealed class InputSafetyPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
Implements: IPipelineBehavior<TRequest, TResponse>

Pipeline behavior that guards inbound mediator requests against unsafe string content (C0 control characters and unambiguous HTML/script injection vectors) before handlers execute, returning a controlled validation failure via `IResultFactory<TResponse>`.

Remarks:

Type parameters: TRequest: The request type.; TResponse: The response type.

Members (2)

  • constructorInputSafetyPipelineBehavior
    public InputSafetyPipelineBehavior(IResultFactory<TResponse>? resultFactory = null, Func<Type, bool>? shouldRecurse = null, int maxScanDepth = InputSafetyScanner.DefaultMaxScanDepth)

    Initializes a new instance of the `InputSafetyPipelineBehavior<TRequest, TResponse>` class.

    resultFactory: IResultFactory<TResponse>?
    The optional factory used to create strongly-typed failure responses without reflection.
    shouldRecurse: Func<Type, bool>?
    An optional predicate determining whether nested non-scalar types should be scanned.
    maxScanDepth: int
    The maximum recursion depth when scanning nested request properties.
  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Intercepts the request execution pipeline and invokes the next step.

    request: TRequest
    The request instance being processed.
    next: TNext
    The pipeline continuation delegate to invoke downstream behaviors or the handler.
    cancellationToken: CancellationToken
    A token that can be used to cancel the operation.

    Returns: A value task representing the asynchronous operation that yields the response from the pipeline.

    Type parameters: TNext: The type of the struct-based pipeline continuation delegate.

class

InputSafetyScanner

Assembly: EricksonLopez.Mediator.Result
public static partial class InputSafetyScanner

Provides reusable input-safety scanning for inbound mediator requests, guarding against C0 control characters (including PostgreSQL-incompatible null bytes) and unambiguous HTML/script-injection vectors before requests reach handlers or persistence.

Members (4)

  • methodIsScalar
    public static bool IsScalar(Type type)

    Determines whether the specified type is a scalar primitive/value type that does not require property recursion.

    type: Type
    The type to inspect.

    Returns: `true` if the type is scalar; otherwise, `false`.

  • methodTryFindUnsafeInput
    public static bool TryFindUnsafeInput(object? value, out Error error, int maxDepth = DefaultMaxScanDepth, Func<Type, bool>? shouldRecurse = null)

    Inspects an arbitrary request object graph for unsafe string content up to `maxDepth`.

    value: object?
    The root request object to inspect.
    error: out Error
    When this method returns `true`, contains the validation error describing the violation.
    maxDepth: int
    The maximum recursion depth for nested complex objects.
    shouldRecurse: Func<Type, bool>?
    An optional predicate determining whether a non-scalar property type should be recursively scanned.

    Returns: `true` if unsafe input was detected; otherwise, `false`.

  • methodTryValidateString
    public static bool TryValidateString(string? value, out Error error)

    Validates a single string value for disallowed control characters and dangerous HTML/script markup.

    value: string?
    The string to validate.
    error: out Error
    When this method returns `true`, contains the validation error describing the violation.

    Returns: `true` if the string contains unsafe content; otherwise, `false`.

  • fieldDefaultMaxScanDepth
    public const int DefaultMaxScanDepth

    The default maximum object-graph recursion depth when scanning request properties.

EricksonLopez.Mediator.Testing#

5
struct

DelegateNext

Assembly: EricksonLopez.Mediator.Testing
public readonly struct DelegateNext : INext
Implements: INext

Represents a test continuation delegate for evaluating `INotificationBehavior<TNotification>` implementations.

Members (3)

  • constructorDelegateNext
    public DelegateNext()

    Initializes a new instance of the `DelegateNext` struct with a completed default continuation.

  • constructorDelegateNext
    public DelegateNext(Func<ValueTask> continuation)

    Initializes a new instance of the `DelegateNext` struct with an asynchronous callback delegate.

    continuation: Func<ValueTask>
    The asynchronous delegate to invoke.

    Exceptions: ArgumentNullException: `continuation` is `null`

  • methodInvokeAsync
    public ValueTask InvokeAsync()

    Invokes the next behavior or handler in the pipeline.

    Returns: A value task representing the asynchronous operation that yields the response from subsequent pipeline components.

struct

DelegateNext<TResponse>

Assembly: EricksonLopez.Mediator.Testing
public readonly struct DelegateNext<TResponse> : INext<TResponse>
Implements: INext<TResponse>

Represents a test continuation delegate for evaluating `IPipelineBehavior<TRequest, TResponse>` implementations.

Remarks:

Type parameters: TResponse: The type of response returned by the continuation.

Members (3)

  • constructorDelegateNext
    public DelegateNext(Func<ValueTask<TResponse>> continuation)

    Initializes a new instance of the `DelegateNext<TResponse>` struct with an asynchronous callback delegate.

    continuation: Func<ValueTask<TResponse>>
    The asynchronous delegate to invoke.

    Exceptions: ArgumentNullException: `continuation` is `null`

  • constructorDelegateNext
    public DelegateNext(TResponse constantResult)

    Initializes a new instance of the `DelegateNext<TResponse>` struct that returns a constant synchronous value.

    constantResult: TResponse
    The constant result to return.
  • methodInvokeAsync
    public ValueTask<TResponse> InvokeAsync()

    Invokes the next behavior or handler in the pipeline.

    Returns: A value task representing the asynchronous operation that yields the response from subsequent pipeline components.

class

FakeAssertionException

Assembly: EricksonLopez.Mediator.Testing
public sealed class FakeAssertionException : Exception
Inherits: Exception

Represents an exception thrown when an assertion in `FakeMediator` fails.

Members (1)

  • constructorFakeAssertionException
    public FakeAssertionException(string message)

    Initializes a new instance of the `FakeAssertionException` class with the specified error message.

    message: string
    The message that describes the assertion failure.
class

FakeMediator

Assembly: EricksonLopez.Mediator.Testing
public sealed class FakeMediator : IMediator
Implements: IMediator

Provides an in-memory test double for `IMediator` to simplify unit testing.

Remarks:

Handlers and expectations are configured programmatically without requiring code generation or dependency injection containers.

Members (21)

  • methodCreateStream<TResponse>
    public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TResponse> request, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    request: IStreamRequest<TResponse>
    cancellationToken: CancellationToken

    Exceptions: OperationCanceledException: `cancellationToken` is already cancelled; ArgumentNullException: `request` is `null`; InvalidOperationException: No handler is configured for the runtime type of `request`

  • methodPublish<TNotification>
    public async ValueTask Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification

    Inherits documentation from base type or interface.

    notification: TNotification
    cancellationToken: CancellationToken

    Exceptions: OperationCanceledException: `cancellationToken` is already cancelled; ArgumentNullException: `notification` is `null`

  • methodReceivedCount<TRequest>
    public int ReceivedCount<TRequest>()

    Calculates the number of times a message of type `TRequest` was received.

    Returns: The total number of matching messages received.

    Type parameters: TRequest: The type of request or notification to count.

  • methodReceivedNotificationsOf<TNotification>
    public IReadOnlyList<TNotification> ReceivedNotificationsOf<TNotification>() where TNotification : class

    Retrieves all received notifications matching the specified type `TNotification`.

    Returns: A read-only collection of matching notifications.

    Type parameters: TNotification: The type of notification to filter.

  • methodReceivedRequestsOf<TRequest>
    public IReadOnlyList<TRequest> ReceivedRequestsOf<TRequest>() where TRequest : class

    Retrieves all received requests matching the specified type `TRequest`.

    Returns: A read-only collection of matching requests.

    Type parameters: TRequest: The type of request to filter.

  • methodReset
    public void Reset()

    Clears all registered handlers and received request history.

  • methodSend<TResponse>
    public ValueTask<TResponse> Send<TResponse>(ICommand<TResponse> command, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    command: ICommand<TResponse>
    cancellationToken: CancellationToken

    Exceptions: OperationCanceledException: `cancellationToken` is already cancelled; ArgumentNullException: `command` is `null`; InvalidOperationException: No handler is configured for the runtime type of `command`

  • methodSend<TResponse>
    public ValueTask<TResponse> Send<TResponse>(IQuery<TResponse> query, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    query: IQuery<TResponse>
    cancellationToken: CancellationToken

    Exceptions: OperationCanceledException: `cancellationToken` is already cancelled; ArgumentNullException: `query` is `null`; InvalidOperationException: No handler is configured for the runtime type of `query`

  • methodSendCommand<TCommand, TResponse>
    public ValueTask<TResponse> SendCommand<TCommand, TResponse>(TCommand command, CancellationToken cancellationToken = default) where TCommand : ICommand<TResponse>

    Inherits documentation from base type or interface.

    command: TCommand
    cancellationToken: CancellationToken
  • methodSendQuery<TQuery, TResponse>
    public ValueTask<TResponse> SendQuery<TQuery, TResponse>(TQuery query, CancellationToken cancellationToken = default) where TQuery : IQuery<TResponse>

    Inherits documentation from base type or interface.

    query: TQuery
    cancellationToken: CancellationToken
  • methodSetupCommand<TCommand, TResponse>
    public FakeMediator SetupCommand<TCommand, TResponse>(Func<TCommand, CancellationToken, ValueTask<TResponse>> handler) where TCommand : ICommand<TResponse>

    Configures an asynchronous response delegate for the specified command type.

    handler: Func<TCommand, CancellationToken, ValueTask<TResponse>>
    The asynchronous delegate to execute when the command is sent.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TCommand: The type of command to handle.; TResponse: The type of response returned by the command handler.

  • methodSetupCommand<TCommand, TResponse>
    public FakeMediator SetupCommand<TCommand, TResponse>(Func<TCommand, TResponse> handler) where TCommand : ICommand<TResponse>

    Configures a synchronous response delegate for the specified command type.

    handler: Func<TCommand, TResponse>
    The delegate to execute when the command is sent.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TCommand: The type of command to handle.; TResponse: The type of response returned by the command handler.

  • methodSetupNotification<TNotification>
    public FakeMediator SetupNotification<TNotification>(Func<TNotification, CancellationToken, ValueTask> handler) where TNotification : INotification

    Configures an asynchronous callback delegate for the specified notification type.

    handler: Func<TNotification, CancellationToken, ValueTask>
    The asynchronous delegate to execute when the notification is published.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TNotification: The type of notification to handle.

  • methodSetupQuery<TQuery, TResponse>
    public FakeMediator SetupQuery<TQuery, TResponse>(Func<TQuery, CancellationToken, ValueTask<TResponse>> handler) where TQuery : IQuery<TResponse>

    Configures an asynchronous response delegate for the specified query type.

    handler: Func<TQuery, CancellationToken, ValueTask<TResponse>>
    The asynchronous delegate to execute when the query is sent.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TQuery: The type of query to handle.; TResponse: The type of response returned by the query handler.

  • methodSetupQuery<TQuery, TResponse>
    public FakeMediator SetupQuery<TQuery, TResponse>(Func<TQuery, TResponse> handler) where TQuery : IQuery<TResponse>

    Configures a synchronous response delegate for the specified query type.

    handler: Func<TQuery, TResponse>
    The delegate to execute when the query is sent.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TQuery: The type of query to handle.; TResponse: The type of response returned by the query handler.

  • methodSetupStream<TRequest, TResponse>
    public FakeMediator SetupStream<TRequest, TResponse>(Func<TRequest, CancellationToken, IAsyncEnumerable<TResponse>> handler) where TRequest : IStreamRequest<TResponse>

    Configures an asynchronous streaming delegate for the specified stream request type.

    handler: Func<TRequest, CancellationToken, IAsyncEnumerable<TResponse>>
    The streaming delegate to execute when the stream is created.

    Returns: The current `FakeMediator` instance for fluent chaining.

    Type parameters: TRequest: The type of stream request to handle.; TResponse: The type of elements yielded by the stream.

  • methodShouldHaveReceived<TRequest>
    public void ShouldHaveReceived<TRequest>()

    Verifies that at least one message of type `TRequest` was received.

    Type parameters: TRequest: The type of request or notification expected. Exceptions: FakeAssertionException: No matching message was received

  • methodShouldHaveReceived<TRequest>
    public void ShouldHaveReceived<TRequest>(Func<TRequest, bool> predicate)

    Verifies that at least one message of type `TRequest` matching the specified predicate was received.

    predicate: Func<TRequest, bool>
    The condition to evaluate on received messages.

    Type parameters: TRequest: The type of request or notification expected. Exceptions: FakeAssertionException: No message matching the predicate was received

  • methodShouldNotHaveReceived<TRequest>
    public void ShouldNotHaveReceived<TRequest>()

    Verifies that no messages of type `TRequest` were received.

    Type parameters: TRequest: The type of request or notification that should not have been received. Exceptions: FakeAssertionException: At least one message of type `TRequest` was received

  • propertyReceivedNotifications
    public IReadOnlyList<object> ReceivedNotifications { get; }

    Gets the collection of all notifications published to this fake mediator.

  • propertyReceivedRequests
    public IReadOnlyList<object> ReceivedRequests { get; }

    Gets the collection of all command and query requests dispatched to this fake mediator.

class

MediatorPipelineParityVerifier

Assembly: EricksonLopez.Mediator.Testing
public static class MediatorPipelineParityVerifier

Fitness verifier asserting 100% parity and deterministic execution ordering between assembly-level `UseGlobalBehaviorAttribute` declarations (consumed by `GeneratedMediator`) and open-generic `IPipelineBehavior<TRequest, TResponse>` registrations in `IServiceCollection`.

Members (2)

  • methodAssertGlobalBehaviorsMatchServiceRegistrations
    public static void AssertGlobalBehaviorsMatchServiceRegistrations(Assembly applicationAssembly, IServiceCollection services, IReadOnlyList<Type>? expectedOrderedOpenGenericBehaviors = null)

    Verifies that assembly-level `UseGlobalBehaviorAttribute` declarations match `IServiceCollection` open-generic `IPipelineBehavior<TRequest, TResponse>` registrations and optional expected execution order.

    applicationAssembly: Assembly
    The assembly declaring `UseGlobalBehaviorAttribute` attributes.
    services: IServiceCollection
    The configured `IServiceCollection`.
    expectedOrderedOpenGenericBehaviors: IReadOnlyList<Type>?
    Optional expected ordered list of open-generic behavior types.

    Exceptions: FakeAssertionException: Parity or execution order invariants are violated.

  • methodAssertParity
    public static void AssertParity(Assembly applicationAssembly, IServiceCollection services, IReadOnlyList<Type>? expectedOrderedOpenGenericBehaviors = null)

    Verifies that every open-generic `IPipelineBehavior<TRequest, TResponse>` registered in `services` has a matching `UseGlobalBehaviorAttribute` on `applicationAssembly` (and vice-versa), with strictly unique execution orders and optional exact sequence matching.

    applicationAssembly: Assembly
    The assembly declaring `UseGlobalBehaviorAttribute` attributes.
    services: IServiceCollection
    The configured `IServiceCollection`.
    expectedOrderedOpenGenericBehaviors: IReadOnlyList<Type>?
    Optional expected ordered list of open-generic behavior types.

    Exceptions: FakeAssertionException: Parity or execution order invariants are violated.

Microsoft.Extensions.DependencyInjection#

1
class

MediatorFluentValidationExtensions

Assembly: EricksonLopez.Mediator.FluentValidation
public static class MediatorFluentValidationExtensions

Provides extension methods for configuring `ValidationPipelineBehavior<TRequest, TResponse>` and FluentValidation validators in dependency injection.

Remarks:

This class is the successor to the deprecated `MediatorValidationExtensions` in `EricksonLopez.Mediator.Validation` (deprecated via ADR-033).

Members (3)

  • methodAddMediatorFluentValidation
    public static IServiceCollection AddMediatorFluentValidation(this IServiceCollection services)

    Registers the open generic `ValidationPipelineBehavior<TRequest, TResponse>` as a pipeline behavior in the service collection.

    services: this IServiceCollection
    The service collection to configure.

    Returns: The same `IServiceCollection` instance for method chaining.

    Call this method once during application startup (e.g., in `Program.cs`). It registers `ValidationPipelineBehavior<TRequest, TResponse>` as an open generic `IPipelineBehavior<TRequest, TResponse>` using `TryAddTransient`, so calling it more than once is safe. Validators (`IValidator<T>`) must be registered separately using `AddMediatorFluentValidatorsFromAssembly` or `AddMediatorFluentValidationValidator<TValidator, TRequest>`. Exceptions: ArgumentNullException: `services` is `null` Example:

    builder.Services.AddMediatorFluentValidation();
    builder.Services.AddMediatorFluentValidatorsFromAssembly(typeof(Program).Assembly);
  • methodAddMediatorFluentValidationValidator<TValidator, TRequest>
    public static IServiceCollection AddMediatorFluentValidationValidator<TValidator, TRequest>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Scoped) where TValidator : class, IValidator<TRequest>

    Registers a single FluentValidation validator explicitly, without assembly scanning.

    services: this IServiceCollection
    The service collection to register the validator into.
    lifetime: ServiceLifetime
    The service lifetime applied to the validator. Defaults to `ServiceLifetime.Scoped`.

    Returns: The same `IServiceCollection` instance for method chaining.

    This overload is the AOT-safe alternative to `AddMediatorFluentValidatorsFromAssembly`. Because the validator type is specified as a generic parameter, the compiler preserves the type and its metadata under trimming. Type parameters: TValidator: The concrete validator type to register.; TRequest: The request type that `TValidator` validates. Exceptions: ArgumentNullException: `services` is `null` Example:

    // AOT-safe registration
    builder.Services.AddMediatorFluentValidation();
    builder.Services.AddMediatorFluentValidationValidator<CreateUserCommandValidator, CreateUserCommand>();
  • methodAddMediatorFluentValidatorsFromAssembly
    public static IServiceCollection AddMediatorFluentValidatorsFromAssembly(this IServiceCollection services, Assembly assembly, ServiceLifetime lifetime = ServiceLifetime.Scoped)

    Discovers and registers all FluentValidation validators found in the specified assembly into the service collection.

    services: this IServiceCollection
    The service collection to register validators into.
    assembly: Assembly
    The assembly to scan for `IValidator<T>` implementations.
    lifetime: ServiceLifetime
    The service lifetime applied to discovered validators. Defaults to `ServiceLifetime.Scoped`.

    Returns: The same `IServiceCollection` instance for method chaining.

    AOT / Trimming: This method uses `AssemblyScanner` from FluentValidation, which relies on `System.Reflection` to enumerate types. It is annotated with `CodeAnalysis.RequiresUnreferencedCodeAttribute` and is NOT compatible with Native AOT or aggressive trimming. Use `AddMediatorFluentValidationValidator<TValidator, TRequest>` for an AOT-safe alternative. Exceptions: ArgumentNullException: `services` or `assembly` is `null` Example:

    // Not AOT-safe — use in standard .NET apps only
    builder.Services.AddMediatorFluentValidation();
    builder.Services.AddMediatorFluentValidatorsFromAssembly(typeof(Program).Assembly);

Search EricksonLopez.* Ecosystem

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