Albatross.Messaging.CodeGen 9.0.4-rc.50

Prefix Reserved
This is a prerelease version of Albatross.Messaging.CodeGen.
dotnet add package Albatross.Messaging.CodeGen --version 9.0.4-rc.50
                    
NuGet\Install-Package Albatross.Messaging.CodeGen -Version 9.0.4-rc.50
                    
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="Albatross.Messaging.CodeGen" Version="9.0.4-rc.50">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Albatross.Messaging.CodeGen" Version="9.0.4-rc.50" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.Messaging.CodeGen">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Albatross.Messaging.CodeGen --version 9.0.4-rc.50
                    
#r "nuget: Albatross.Messaging.CodeGen, 9.0.4-rc.50"
                    
#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 Albatross.Messaging.CodeGen@9.0.4-rc.50
                    
#: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=Albatross.Messaging.CodeGen&version=9.0.4-rc.50&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Albatross.Messaging.CodeGen&version=9.0.4-rc.50&prerelease
                    
Install as a Cake Tool

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();
There are no supported framework assets in this package.

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