Albatross.Messaging.CodeGen
9.0.4-rc.50
Prefix Reserved
dotnet add package Albatross.Messaging.CodeGen --version 9.0.4-rc.50
NuGet\Install-Package Albatross.Messaging.CodeGen -Version 9.0.4-rc.50
<PackageReference Include="Albatross.Messaging.CodeGen" Version="9.0.4-rc.50"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Albatross.Messaging.CodeGen" Version="9.0.4-rc.50" />
<PackageReference Include="Albatross.Messaging.CodeGen"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Albatross.Messaging.CodeGen --version 9.0.4-rc.50
#r "nuget: Albatross.Messaging.CodeGen, 9.0.4-rc.50"
#:package Albatross.Messaging.CodeGen@9.0.4-rc.50
#addin nuget:?package=Albatross.Messaging.CodeGen&version=9.0.4-rc.50&prerelease
#tool nuget:?package=Albatross.Messaging.CodeGen&version=9.0.4-rc.50&prerelease
Usage: Reference the project as an analyzer:
<PackageReference Include="Albatross.Messaging.CodeGen" Version="7.3.0" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
If the referenced project has a partial interface that start with I and ends with Command, the code generator will find any concrete class that implements the inteface and add the JsonDerivedType attribute for that class to the interface.
For example, if you have the following interface:
public partial interface IMyCommand
{
}
And the following class:
public class MyCommand : IMyCommand
{
}
The code generator will create a partial interface of the same name and add the following attribute to the interface:
[JsonDerivedType(typeof(MyCommand), "MyCommand")]
public partial interface IMyCommand
{}
This allows the proper json serialization of the interface IMyCommand. Note that the type discriminator is the name of the class without the namespace.
Command handler registration
The code generator also finds every concrete class that implements ICommandHandler<TCommand> or
ICommandHandler<TCommand, TResponse> and generates a single CommandHandlerRegistration class with a
RegisterCommands extension method that wires them all into the service collection. The class is placed in the
<RootNamespace>.AutoGenerated namespace of the project being compiled, regardless of where the handlers
themselves live:
namespace Sample.AutoGenerated {
public static class CommandHandlerRegistration {
public static IServiceCollection RegisterCommands(this IServiceCollection services, Func<ulong, object, IServiceProvider, string> getQueueName) {
services.AddScoped<ICommandHandler<PingCommand>, PingCommandHandler>();
services.AddCommand<PingCommand>(new string[] { "Sample.Core.Commands.PingCommand" }, getQueueName);
return services;
}
}
}
To consume the generated code, import that namespace:
using Sample.AutoGenerated;
services.AddCommandBus()
.RegisterCommands(Sample.Extensions.GetQueueName)
.AddPublisher();
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
|---|---|---|
| 9.0.4-rc.50 | 72 | 7/28/2026 |
| 9.0.4-rc.48 | 69 | 7/13/2026 |
| 9.0.3 | 106 | 1/14/2026 |
| 9.0.2-21.main | 80 | 12/11/2025 |
| 9.0.0 | 106 | 10/28/2025 |
| 8.0.2 | 87 | 12/11/2025 |
| 8.0.2-14.main | 99 | 9/30/2025 |
| 8.0.1 | 186 | 3/9/2025 |
| 7.7.2 | 256 | 3/5/2025 |