ModulusKit.Generators 4.0.0

dotnet add package ModulusKit.Generators --version 4.0.0
                    
NuGet\Install-Package ModulusKit.Generators -Version 4.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="ModulusKit.Generators" Version="4.0.0">
  <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="ModulusKit.Generators" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ModulusKit.Generators">
  <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 ModulusKit.Generators --version 4.0.0
                    
#r "nuget: ModulusKit.Generators, 4.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 ModulusKit.Generators@4.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=ModulusKit.Generators&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ModulusKit.Generators&version=4.0.0
                    
Install as a Cake Tool

ModulusKit.Generators

Roslyn incremental source generators for Modulus -- strongly typed IDs, handler registration, and module auto-discovery.

Installation

dotnet add package ModulusKit.Generators

Or as an analyzer reference in your .csproj:

<PackageReference Include="ModulusKit.Generators"
                  OutputItemType="Analyzer"
                  ReferenceOutputAssembly="false" />

Note: This is a development-dependency (analyzer) package -- it does not flow transitively through other ModulusKit.* packages or through project references. Add the reference above to every project that defines handlers, validators, or [StronglyTypedId] types (and to the host, for module discovery). Solutions scaffolded by the modulus CLI have this wired up already.

Strongly Typed IDs

Generate type-safe entity identifiers with EF Core, JSON (including dictionary-key support), route/query binding, and comparison support:

using Modulus.Mediator.Abstractions;

[StronglyTypedId]
public readonly partial record struct OrderId;

[StronglyTypedId(typeof(int))]
public readonly partial record struct SequenceNumber;

[StronglyTypedId(typeof(string))]
public readonly partial record struct TenantId;

The generator produces: Value property, constructor, New() factory (Guid only), Empty, IComparable<T>, IParsable<T>/Parse/TryParse (minimal API route/query parameter binding), plus ValueConverter (EF Core), JsonConverter (System.Text.Json — including ReadAsPropertyName/WriteAsPropertyName for use as a Dictionary<TId, TValue> key), and TypeConverter (MVC model binding).

Supported backing types: Guid (default), int, long, string.

Bulk EF Core registration

When the compilation references EF Core, the generator also emits ModulusStronglyTypedIdConventions.UseModulusStronglyTypedIds(this ModelConfigurationBuilder) — one call from DbContext.ConfigureConventions that registers every discovered ID's ValueConverter (local declarations plus public ones from referenced assemblies that were themselves built with an EF Core reference):

protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
    => configurationBuilder.UseModulusStronglyTypedIds();

Handler Registration

Auto-register all handlers and validators at compile time:

// Source-generated extension method
services.AddModulusHandlers();

Discovers: ICommandHandler<>, IQueryHandler<>, IStreamQueryHandler<>, IDomainEventHandler<>, IIntegrationEventHandler<>, and AbstractValidator<>.

Module Auto-Discovery

Auto-discover all IModuleRegistration implementations from referenced assemblies:

// Source-generated extension methods
builder.Services.AddAllModules(builder.Configuration);
app.MapAllModuleEndpoints();

Control initialization order with [ModuleOrder(n)].

Diagnostics

ID Severity Description
MODGEN001 Error [StronglyTypedId] target must be partial
MODGEN002 Error [StronglyTypedId] target must be a record struct
MODGEN003 Info Open generic handler skipped for registration
MODGEN004 Warning IModuleRegistration missing required static methods
MODGEN005 Error [StronglyTypedId] backing type is unsupported (only Guid, int, long, string)
MODGEN006 Error [StronglyTypedId] target must be a top-level type

Learn More

See the Modulus documentation for full generator reference.

There are no supported framework assets in this 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
4.0.0 102 7/26/2026
3.1.0 294 7/26/2026
3.0.0 231 7/26/2026
2.1.0 101 7/4/2026
2.0.0 106 7/3/2026
1.2.5 130 3/15/2026
1.2.4 116 3/15/2026
1.2.3 115 3/14/2026
1.2.2 114 3/14/2026
1.2.1 114 3/14/2026
1.2.0 123 3/14/2026
1.1.1 110 3/8/2026
1.1.0 111 3/5/2026
1.0.1 114 3/5/2026