Send0xx.Dispatcher.SourceGeneration 3.0.0

dotnet add package Send0xx.Dispatcher.SourceGeneration --version 3.0.0
                    
NuGet\Install-Package Send0xx.Dispatcher.SourceGeneration -Version 3.0.0
                    
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="Send0xx.Dispatcher.SourceGeneration" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Send0xx.Dispatcher.SourceGeneration" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Send0xx.Dispatcher.SourceGeneration" />
                    
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 Send0xx.Dispatcher.SourceGeneration --version 3.0.0
                    
#r "nuget: Send0xx.Dispatcher.SourceGeneration, 3.0.0"
                    
#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 Send0xx.Dispatcher.SourceGeneration@3.0.0
                    
#: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=Send0xx.Dispatcher.SourceGeneration&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Send0xx.Dispatcher.SourceGeneration&version=3.0.0
                    
Install as a Cake Tool

Dispatcher

NuGet DependencyInjection NuGet SourceGeneration License: MIT CI Coverage Status

Dispatcher is a small CQRS library for .NET applications that use dependency injection. It provides focused APIs for queries, commands, notifications, handlers, and pipeline behaviors.

Read the documentation

Main features

  • Reflection-free dispatch. Handler routes are stored in frozen dictionaries, and handlers and pipeline behaviors are resolved from the current dependency-injection scope.
  • Polymorphic routes. A message uses its exact handler when one exists, and otherwise the most-specific compatible base class or interface handler. Routes are decided during registry creation or at compile time, not per dispatch.
  • Internal handlers and modular composition. Handlers never have to be public, and an application split across assemblies registers each module's handlers separately, under either registration mode.
  • Trimming and Native AOT support. The source generator emits registrations and dispatch tables at compile time, and its package does not reference the reflection-based implementation at all.
  • Built-in OpenTelemetry. Tracing activities and an operation-duration histogram, disabled by default, adding no work to the dispatch path while off.

Install

For the simplest Microsoft dependency-injection setup, install:

dotnet add package Send0xx.Dispatcher.DependencyInjection

For source-generated registration and Native AOT, install instead:

dotnet add package Send0xx.Dispatcher.SourceGeneration

Choose one implementation package. Both bring in the abstractions, runtime, and dependency injection integration they require.

Quick start

Define a query and its handler:

using Dispatcher;

public sealed record GetGreetingQuery(string Name) : IQuery<string>;

internal sealed class GetGreetingQueryHandler
    : IQueryHandler<GetGreetingQuery, string>
{
    public ValueTask<string> HandleAsync(
        GetGreetingQuery query,
        CancellationToken cancellationToken = default) =>
        ValueTask.FromResult($"Hello, {query.Name}!");
}

Register Dispatcher and scan the application assembly for handlers:

using Dispatcher.DependencyInjection;

builder.Services
    .AddDispatcher()
    .AddDispatcherHandlers(typeof(Program).Assembly);

Inject a focused dispatcher interface and send the query:

app.MapGet("/greetings/{name}", async (
    string name,
    IQueryDispatcher queries,
    CancellationToken cancellationToken) =>
{
    var greeting = await queries.QueryAsync(
        new GetGreetingQuery(name),
        cancellationToken);

    return Results.Ok(greeting);
});

The getting started guide walks through this in full.

Samples

All samples target .NET 10. Start with the samples overview, or go directly to the dependency-injection Minimal API or the Native AOT Minimal API.

Contributing

Contributions and design discussions are welcome. See the contribution guide to get started. Maintainers can find CI, documentation, and NuGet publishing instructions in the release guide.

License

Dispatcher is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0 104 9/1/2026
2.0.0 105 8/29/2026
1.0.0 113 8/20/2026
1.0.0-rc.2 79 8/16/2026
1.0.0-rc.1 76 8/16/2026
1.0.0-preview.12 74 8/15/2026
1.0.0-preview.11 72 8/15/2026
1.0.0-preview.10 74 8/15/2026
1.0.0-preview.9 71 8/13/2026
1.0.0-preview.8 66 8/11/2026
1.0.0-preview.7 71 8/11/2026
1.0.0-preview.6 72 8/10/2026
1.0.0-preview.5 74 8/8/2026
1.0.0-preview.4 77 8/8/2026