TimeWarp.Mediator
15.0.0-beta.10
Prefix Reserved
dotnet add package TimeWarp.Mediator --version 15.0.0-beta.10
NuGet\Install-Package TimeWarp.Mediator -Version 15.0.0-beta.10
<PackageReference Include="TimeWarp.Mediator" Version="15.0.0-beta.10" />
<PackageVersion Include="TimeWarp.Mediator" Version="15.0.0-beta.10" />
<PackageReference Include="TimeWarp.Mediator" />
paket add TimeWarp.Mediator --version 15.0.0-beta.10
#r "nuget: TimeWarp.Mediator, 15.0.0-beta.10"
#:package TimeWarp.Mediator@15.0.0-beta.10
#addin nuget:?package=TimeWarp.Mediator&version=15.0.0-beta.10&prerelease
#tool nuget:?package=TimeWarp.Mediator&version=15.0.0-beta.10&prerelease
TimeWarp.Mediator
Message contracts and the TWM001–TWM004, TWM012, and TWM013 analyzer for TimeWarp Mediator 15.0: requests, commands, queries, notifications, and pipeline types.
Install
dotnet add package TimeWarp.Mediator --version 15.0.0-beta.10
Without --version, that command resolves 14.0.0. Through 14.0.0 this package id was the reflection runtime (AddMediator). The 14.0.0 contracts were TimeWarp.Mediator.Contracts, and the analyzers were TimeWarp.Mediator.Analyzers. 15.0 reuses this id for the contracts and the analyzer. A host also references TimeWarp.Mediator.Generators at the same version. This package ships the TWM001–TWM004, TWM012, and TWM013 analyzer, GeneratedHandlerAttribute so a request can name a handler another generator emits, and GeneratedRequestPatternAttribute so a source type can declare requests and handlers another generator emits. There is no separate analyzers package.
Example
using Microsoft.Extensions.DependencyInjection;
using TimeWarp.Mediator;
using TimeWarp.Mediator.Generated;
ServiceCollection services = new();
services.AddGeneratedMediator();
using ServiceProvider provider = services.BuildServiceProvider();
using IServiceScope scope = provider.CreateScope();
string reply = await scope.ServiceProvider.GetRequiredService<ISender>().Send(new Ping());
public sealed class Ping : IRequest<string> { }
public sealed class PingHandler : IRequestHandler<Ping, string>
{
public ValueTask<string> Handle(Ping request, CancellationToken cancellationToken) =>
ValueTask.FromResult("Pong");
}
AddGeneratedMediator() is emitted into the host project by TimeWarp.Mediator.Generators, in the generated namespace (TimeWarp.Mediator.Generated unless the host sets TimeWarpMediatorNamespace). Call it from the host. Reference only this package from a project that declares messages and does not dispatch them. That project still gets TWM001–TWM004, and it opts in with [assembly: MediatorAssembly].
Requests another generator emits
Source generators do not see each other's output. When another generator emits a request and its handler into the host, declare them on a source type so Send dispatches them:
[GeneratedRequestPattern(
"{Host}.{Contract}ActionSet.Action",
"{Host}.{Contract}ActionSet.Handler",
"TimeWarp.Mediator.IRequest<{ContractType}.Response>",
typeof(CreateRole), typeof(UpdateRole))]
public partial class RoleState { }
requestTypeNameandhandlerTypeNameare dotted type names.{Host}is the attributed type's full name,{Contract}the contract's simple name,{ContractType}the contract's full name. No other placeholder exists.requestInterfaceNameis the Mediator interface the emitted request implements.TimeWarp.Mediator.IActionorTimeWarp.Mediator.IRequestis a void request.TimeWarp.Mediator.IRequest<{ContractType}.Response>(orIQuery<...>,ICommand<...>, or a fixed type such asIRequest<string>) gives the response. Behaviors constrained on that interface close over the request. The interface and its response must be in source or in a reference.- The attribute allows multiple uses and can be derived. A derived attribute declares its templates as constructor parameters with the same names (a default value is enough) or as
const stringfields namedRequestTypeName,HandlerTypeName, andRequestInterfaceName. Its contracts are a constructor parameter namedcontracts:
public sealed class ContractStateAttribute(params Type[] contracts) : GeneratedRequestPatternAttribute(contracts)
{
public const string RequestTypeName = "{Host}.{Contract}ActionSet.Action";
public const string HandlerTypeName = "{Host}.{Contract}ActionSet.Handler";
public const string RequestInterfaceName = "TimeWarp.Mediator.IAction";
}
The send uses the same handler call and the same woven behaviors as a request written in source. After every generator has run, TWM013 reports a declared request or handler that does not exist, a request that does not implement the declared interface, or a handler that is not its IRequestHandler.
Migration
15.0 is a breaking release. Handlers return ValueTask. The host calls AddGeneratedMediator() and supplies IServiceProvider. Registered pipeline behaviors are woven.
- This package targets net11.0 only (since 15.0.0-beta.9).
net10.0consumers stay on 15.0.0-beta.8 or earlier. Build with the .NET 11 SDK (11.0.100 or later) anddotnet build. Visual Studio and .NET Framework MSBuild are not supported. The SDK compiler must be at least the Roslyn version the packages reference; an older SDK reports CS8032/CS9057 and the generator emits nothing. - Through 14.0.0 the id
TimeWarp.Mediatorwas the reflection runtime (AddMediator). 15.0 reuses that id for the contracts and the analyzer. The 14.0.0 contracts idTimeWarp.Mediator.Contractsis gone, and so isAddMediator. - From MediatR: change
using MediatR;tousing TimeWarp.Mediator;.
Steps: Migration to 15.0.
Documentation
License
Licensed as Unlicense AND Apache-2.0. The Apache-2.0 terms cover code derived from MediatR by Jimmy Bogard. The notice and unlicense files ship in this package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- No dependencies.
NuGet packages (7)
Showing the top 5 NuGet packages that depend on TimeWarp.Mediator:
| Package | Downloads |
|---|---|
|
TimeWarp.State
State management for .NET. Blazor components, JavaScript interop, and render subscriptions are in TimeWarp.State.Blazor. |
|
|
TimeWarp.Nuru
Route-based CLI framework for .NET - batteries included with telemetry, REPL, and shell completion |
|
|
TimeWarp.Contracts
Transport-neutral operation contracts for HTTP, CLI, and MCP. One request type carries the canonical name; member metadata and kind are derived by each host's generator. |
|
|
TimeWarp.Foundation.Contracts
Shared contracts, request/response markers, route/auth/query source generator, and common types for the TimeWarp foundation layer. |
|
|
TimeWarp.Foundation.Server
ASP.NET server building blocks (modules, base endpoints, CORS) for the TimeWarp foundation layer. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 15.0.0-beta.10 | 756 | 11/17/2026 |
| 15.0.0-beta.9 | 562 | 11/15/2026 |
| 15.0.0-beta.8 | 234 | 11/14/2026 |
| 15.0.0-beta.6 | 823 | 11/9/2026 |
| 15.0.0-beta.5 | 203 | 11/5/2026 |
| 15.0.0-beta.4 | 981 | 10/31/2026 |
| 15.0.0-beta.2 | 242 | 10/28/2026 |
| 15.0.0-beta.1 | 66 | 10/26/2026 |
| 14.0.0 | 1,619 | 10/13/2026 |
| 14.0.0-beta.5 | 66 | 10/13/2026 |
| 14.0.0-beta.4 | 82 | 9/27/2026 |
| 14.0.0-beta.3 | 82 | 9/25/2026 |
| 14.0.0-beta.2 | 74 | 9/25/2026 |
| 14.0.0-beta.1 | 104 | 9/2/2026 |
| 13.0.0 | 17,509 | 8/4/2025 |
| 13.0.0-beta.4 | 242 | 7/30/2025 |
| 13.0.0-beta.3 | 241 | 7/28/2025 |
| 13.0.0-beta.2 | 168 | 7/5/2025 |
| 13.0.0-beta.1 | 163 | 7/5/2025 |