TimeWarp.Mediator.Generators 14.0.0-beta.4

Prefix Reserved
This is a prerelease version of TimeWarp.Mediator.Generators.
There is a newer version of this package available.
See the version list below for details.
dotnet add package TimeWarp.Mediator.Generators --version 14.0.0-beta.4
                    
NuGet\Install-Package TimeWarp.Mediator.Generators -Version 14.0.0-beta.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TimeWarp.Mediator.Generators" Version="14.0.0-beta.4">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TimeWarp.Mediator.Generators" Version="14.0.0-beta.4" />
                    
Directory.Packages.props
<PackageReference Include="TimeWarp.Mediator.Generators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TimeWarp.Mediator.Generators --version 14.0.0-beta.4
                    
#r "nuget: TimeWarp.Mediator.Generators, 14.0.0-beta.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TimeWarp.Mediator.Generators@14.0.0-beta.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TimeWarp.Mediator.Generators&version=14.0.0-beta.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=TimeWarp.Mediator.Generators&version=14.0.0-beta.4&prerelease
                    
Install as a Cake Tool

TimeWarp Mediator

CI NuGet NuGet Downloads

Simple, unambitious mediator implementation in .NET

In-process messaging with no dependencies.

Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.

About This Fork

TimeWarp.Mediator is a fork of the excellent MediatR library by Jimmy Bogard. We created this fork to:

  • ✅ Correct the spelling from "MediatR" to "Mediator"
  • ✅ Release under The Unlicense for maximum freedom
  • ✅ Maintain full API compatibility with MediatR
  • ✅ Add helpful diagnostic tools like GetPipelineInfo()

Migration from MediatR

Migrating from MediatR is the 13.x reflection rename — see our migration guide. That path is AddMediator(), not source generation.

Two stacks (read this before AddMediator)

This repository ships two independent dispatchers. Calling AddMediator() does not register the source-generated mediator.

Registration Dispatcher
services.AddMediator(...) Reflection MediatR fork (13.x runtime, still in this repo)
services.AddGeneratedMediator() Source-generated unscoped IMediator / ISender / IPublisher
services.AddGeneratedMediator<TScope>() Source-generated named pipeline (ISender<TScope> / IPublisher<TScope>)

14.0.0-beta is not a drop-in for 13.0.0. As of 14.0.0-beta.4, the generated stack is proven only against the M1/M2 golden files in this repo. Do not bump a 13.0.0 host to 14.0.0-beta and keep AddMediator(...) expecting source-gen, AOT-clean dispatch, or named pipelines. TimeWarp.State and TimeWarp.Nuru must call AddGeneratedMediator() / AddGeneratedMediator<TScope>(). This tree's <Version> is 14.0.0-beta.4. nuget.org serves that as a prerelease; 13.0.0 remains the last stable reflection line.

GitHub issue #52 stays open until a stable 14.0.0.

Comparison: documentation/generated-vs-legacy.md. Milestones: m1-generated-mediator.md, m2-named-pipelines.md.


Original MediatR

CI NuGet NuGet MyGet (dev)

Simple mediator implementation in .NET

In-process messaging with no dependencies.

Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.

Examples in the wiki.

Installing the reflection stack (AddMediator)

NuGet 13.0.0 is the last published reflection line. Install TimeWarp.Mediator:

dotnet add package TimeWarp.Mediator --version 13.0.0

This is the MediatR-fork runtime: assembly scan, wrappers, MakeGenericType. 14.0.0-beta still contains this runtime, but that prerelease is not a drop-in for 13.0.0 (see Two stacks).

Installing the generated stack (AddGeneratedMediator)

A generated host needs Contracts + Generators. Analyzers ride inside the Generators nupkg; add TimeWarp.Mediator.Analyzers only when the generator is not referenced.

<ItemGroup>
  <PackageReference Include="TimeWarp.Mediator.Contracts" Version="14.0.0-beta.4" />
  <PackageReference Include="TimeWarp.Mediator.Generators" Version="14.0.0-beta.4" />
</ItemGroup>
dotnet add package TimeWarp.Mediator.Contracts --version 14.0.0-beta.4
dotnet add package TimeWarp.Mediator.Generators --version 14.0.0-beta.4
# library-only (no generator):
dotnet add package TimeWarp.Mediator.Analyzers --version 14.0.0-beta.4

Do not add only TimeWarp.Mediator and call AddMediator() expecting this stack.

Using Contracts-Only Package

To reference only the contracts for TimeWarp.Mediator, which includes:

  • IRequest (including generic variants)
  • CQRS markers and handlers: ICommand / ICommand<T>, IQuery<T>, IAction
  • Idempotency markers: IIdempotent, IIdempotentCommand / IIdempotentCommand<T> (+ handlers). IQuery<T> implements IIdempotent. Idempotent commands dispatch exactly like commands; these are types only (no idempotency-key enforcement or dedup store)
  • INotification
  • IStreamRequest
  • ISender / ISender<TScope>, IPublisher / IPublisher<TScope>
  • Membership attributes (MediatorAssembly, MediatorScope, MediatorBehavior)

Add a package reference to TimeWarp.Mediator.Contracts.

This package is useful when contracts live in a separate assembly from handlers (API / gRPC / Blazor). A generated host still needs Generators on the compilation that emits the mediator.

Generated membership and named pipelines

Hosts that reference Generators get TimeWarpMediatorAssembly=true from the package buildTransitive props. Domain libraries that only reference Analyzers must opt in:

[assembly: MediatorAssembly]
[assembly: MediatorBehavior(typeof(LoggingBehavior<,>))]
[assembly: MediatorBehavior(typeof(ClientStampBehavior<,>), Scope = typeof(ClientPipeline))]

Named pipelines use marker types, not strings (ClientPipeline / ServerPipeline):

public sealed class ClientPipeline
{
}

[MediatorScope(typeof(ClientPipeline))]
public sealed class ClientPing : IRequest<string>
{
}

[MediatorModule("Orders")] joins the graph. It does not name a pipeline.

services.AddGeneratedMediator();
services.AddGeneratedMediator<ClientPipeline>();
services.AddGeneratedMediator<ServerPipeline>();

Generated types (TimeWarp.Mediator.Generated.Mediator, Sender_* / Publisher_*, MediatorManifest, and the AddGeneratedMediator extensions) are internal to the host that emits them. Call AddGeneratedMediator() from the host's own code; other assemblies resolve IMediator / ISender / IPublisher. A test project that references two hosts sees no duplicate generated types, unless both hosts grant it InternalsVisibleTo.

Details: documentation/generated-vs-legacy.md, documentation/m1-generated-mediator.md, documentation/m2-named-pipelines.md.

Registering reflection AddMediator with IServiceCollection

The reflection package supports Microsoft.Extensions.DependencyInjection.Abstractions directly. This is not the generated dispatcher. To scan and register the fork runtime:

services.AddMediator(cfg => cfg.RegisterServicesFromAssemblyContaining<Startup>());

or with an assembly:

services.AddMediator(cfg => cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly));

This registers:

  • IMediator as transient
  • ISender as transient
  • IPublisher as transient
  • IRequestHandler<,> concrete implementations as transient
  • IRequestHandler<> concrete implementations as transient
  • INotificationHandler<> concrete implementations as transient
  • IStreamRequestHandler<> concrete implementations as transient
  • IRequestExceptionHandler<,,> concrete implementations as transient
  • IRequestExceptionAction<,>) concrete implementations as transient

This also registers open generic implementations for:

  • INotificationHandler<>
  • IRequestExceptionHandler<,,>
  • IRequestExceptionAction<,>

To register behaviors, stream behaviors, pre/post processors:

services.AddMediator(cfg => {
    cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly);
    cfg.AddBehavior<PingPongBehavior>();
    cfg.AddStreamBehavior<PingPongStreamBehavior>();
    cfg.AddRequestPreProcessor<PingPreProcessor>();
    cfg.AddRequestPostProcessor<PingPongPostProcessor>();
    cfg.AddOpenBehavior(typeof(GenericBehavior<,>));
    });

With additional methods for open generics and overloads for explicit service types.

License

TimeWarp Mediator is released under The Unlicense (see UNLICENSE). Original MediatR code by Jimmy Bogard is under Apache 2.0 (see NOTICE).

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TimeWarp.Mediator.Generators:

Package Downloads
TimeWarp.Nuru

Route-based CLI framework for .NET - batteries included with telemetry, REPL, and shell completion

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
14.0.0 338 10/13/2026
14.0.0-beta.5 244 10/13/2026
14.0.0-beta.4 898 9/27/2026
14.0.0-beta.3 71 9/25/2026
14.0.0-beta.2 66 9/25/2026
14.0.0-beta.1 275 9/2/2026