Welcome to the SharpDispatch documentation. SharpDispatch is a lightweight, high-performance CQRS command dispatching library for .NET 10.
Dispatch commands. Nothing else. No event sourcing, no sagas, no message bus — just blazing-fast, type-safe command dispatch with three pluggable dispatchers and full Native AOT support.
| Guide | What it covers |
|---|---|
| Getting Started | Install, define commands/handlers, register & dispatch |
| Dispatchers | The three dispatchers — when to use which, lifetimes, decorators |
| Advanced Patterns | Struct commands, scoping, exception handling, testing, performance |
| Native AOT | Reflection-free registration for trimmed/AOT deployments |
| API Reference | Every public type and member at a glance |
- Install the package — see Getting Started.
- Run the examples — compile and run them from this repository:
examples/ConsoleQuickStart— the minimal end-to-end flow.examples/MinimalApi— SharpDispatch inside an ASP.NET Core minimal API, including a logging decorator.examples/HighPerformance— the optimized dispatcher with struct commands and a rough latency probe.
- Pick a dispatcher — the Dispatchers page explains the trade-offs in plain language.
| Type | Purpose |
|---|---|
ICommand |
Marker interface for commands |
ICommandHandler<TCommand> |
Handler contract |
ICommandDispatcher |
Dispatcher abstraction |
CommandDispatchResult |
Value-type result (Success, Message, IsSuccess, IsFailure) |
ServiceProviderCommandDispatcher |
DI-based dispatcher (default) |
InMemoryCommandDispatcher |
Handler registry without DI — great for tests |
OptimizedCommandDispatcher |
FrozenDictionary + pre-built typed delegates |
CommandDispatcherBuilder |
Reflection-free, AOT-safe fluent registration |
DispatchServiceCollectionExtensions |
AddCommandHandler, AddCommandDispatcher, AddOptimizedCommandDispatcher, TryDecorate |
src/SharpDispatch/ The library
tests/SharpDispatch.Tests/ xUnit test suite (43 tests)
examples/ConsoleQuickStart/ Simplest possible usage
examples/MinimalApi/ ASP.NET Core integration
examples/HighPerformance/ Optimized dispatcher + struct commands
docs/ These documents