Excalibur.Dispatch.SourceGenerators
3.0.0-alpha.26
This is a prerelease version of Excalibur.Dispatch.SourceGenerators.
dotnet add package Excalibur.Dispatch.SourceGenerators --version 3.0.0-alpha.26
NuGet\Install-Package Excalibur.Dispatch.SourceGenerators -Version 3.0.0-alpha.26
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="Excalibur.Dispatch.SourceGenerators" Version="3.0.0-alpha.26" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Excalibur.Dispatch.SourceGenerators" Version="3.0.0-alpha.26" />
<PackageReference Include="Excalibur.Dispatch.SourceGenerators" />
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 Excalibur.Dispatch.SourceGenerators --version 3.0.0-alpha.26
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Excalibur.Dispatch.SourceGenerators, 3.0.0-alpha.26"
#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 Excalibur.Dispatch.SourceGenerators@3.0.0-alpha.26
#: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=Excalibur.Dispatch.SourceGenerators&version=3.0.0-alpha.26&prerelease
#tool nuget:?package=Excalibur.Dispatch.SourceGenerators&version=3.0.0-alpha.26&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Excalibur.Dispatch.SourceGenerators
Source generators for the Excalibur framework, enabling AOT-compatible code generation at compile time.
Quick Start
1. Install
dotnet add package Excalibur.Dispatch.SourceGenerators
2. Mark Services with [AutoRegister]
using Excalibur.Dispatch.Abstractions;
using Microsoft.Extensions.DependencyInjection;
// Basic usage - Scoped lifetime, registers as self and interfaces
[AutoRegister]
public class OrderHandler : IDispatchHandler<CreateOrderCommand>
{
public Task<IMessageResult> HandleAsync(
CreateOrderCommand message,
IMessageContext context,
CancellationToken ct)
{
// Handle the command
return Task.FromResult(MessageResult.Success());
}
}
// Explicit Singleton lifetime
[AutoRegister(Lifetime = ServiceLifetime.Singleton)]
public class CacheService : ICacheService { }
// Interfaces only (no concrete type registration)
[AutoRegister(AsSelf = false, AsInterfaces = true)]
public class MultiService : IFirst, ISecond { }
3. Call the Generated Extension
var builder = WebApplication.CreateBuilder(args);
// Register all [AutoRegister] services
builder.Services.AddGeneratedServices();
// Add Excalibur framework
builder.Services.AddDispatch();
var app = builder.Build();
Features
| Feature | Description |
|---|---|
| [AutoRegister] Attribute | Opt-in service registration at compile time |
| AOT Compatibility | Full Native AOT and trimming support |
| Lifetime Control | Singleton, Scoped, or Transient per service |
| Interface Registration | Control self vs interface registration |
| Zero Reflection | All discovery happens at compile time |
Attribute Options
[AutoRegister(
Lifetime = ServiceLifetime.Scoped, // Default: Scoped
AsSelf = true, // Default: true - register as concrete type
AsInterfaces = true // Default: true - register for interfaces
)]
public class MyService : IMyService { }
Generated Output
The generator creates AddGeneratedServices() in Microsoft.Extensions.DependencyInjection:
public static class GeneratedServiceCollectionExtensions
{
public static IServiceCollection AddGeneratedServices(this IServiceCollection services)
{
services.AddScoped<MyService>();
services.AddScoped<IMyService, MyService>();
return services;
}
}
All Generators
| Generator | Status | Purpose |
|---|---|---|
ServiceRegistrationSourceGenerator |
Active | [AutoRegister] service registration |
HandlerRegistrySourceGenerator |
Active | Handler discovery at compile time |
HandlerInvokerSourceGenerator |
Active | Zero-reflection handler invocation |
JsonSerializationSourceGenerator |
Active | AOT-compatible JSON serialization |
MessageTypeSourceGenerator |
Active | Message type registration |
MessageTypeRegistrySourceGenerator |
Active | Aggregate message type registry |
RoutingRuleSourceGenerator |
Active | Compile-time routing rules |
MessageFactorySourceGenerator |
Active | Message instantiation |
CachePolicySourceGenerator |
Active | Caching policy generation |
CacheInfoSourceGenerator |
Active | Cache key generation |
Documentation
License
This project is multi-licensed under:
See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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-alpha.26 | 36 | 3/5/2026 |
| 3.0.0-alpha.19 | 49 | 2/26/2026 |