Vorn.Entities.Generators 8.2.0-rc3

This is a prerelease version of Vorn.Entities.Generators.
dotnet add package Vorn.Entities.Generators --version 8.2.0-rc3
                    
NuGet\Install-Package Vorn.Entities.Generators -Version 8.2.0-rc3
                    
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="Vorn.Entities.Generators" Version="8.2.0-rc3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vorn.Entities.Generators" Version="8.2.0-rc3" />
                    
Directory.Packages.props
<PackageReference Include="Vorn.Entities.Generators" />
                    
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 Vorn.Entities.Generators --version 8.2.0-rc3
                    
#r "nuget: Vorn.Entities.Generators, 8.2.0-rc3"
                    
#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 Vorn.Entities.Generators@8.2.0-rc3
                    
#: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=Vorn.Entities.Generators&version=8.2.0-rc3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Vorn.Entities.Generators&version=8.2.0-rc3&prerelease
                    
Install as a Cake Tool

Vorn.Entities.Generators

Vorn.Entities.Generators is a Roslyn source generator that emits dependency injection helpers for every aggregate described in your assembly. By annotating your domain project once, the generator produces extension methods that register MediatR handlers, caches, and interception services without hand-writing boilerplate.

Add the analyzer reference

Include the generator as an analyzer reference in the project that defines your entities and descriptors:

dotnet add package Vorn.Entities.Generators

📌 The package is a source generator, so it only needs to be referenced by the project that produces the entities. Downstream consumers (API, server, client) will use the generated extensions at compile time.

Opt-in per assembly

Decorate your assembly with [GenerateEntitiesRegistration] to activate generation.

using Vorn.Entities.Generators;

[assembly: GenerateEntitiesRegistration]

The generator scans the compilation for descriptor types decorated with [EntityDescriptorFor(typeof(TEntity))] where TEntity inherits from Vorn.Entities.Entity.

Describe descriptors

Use the descriptor attribute on your descriptor type so the generator can pair it with the entity:

[EntityDescriptorFor(typeof(Document))]
public sealed record DocumentDescriptor : EntityDescriptor
{
    public string? SearchText { get; init; }
}

You can repeat the attribute for every aggregate in the assembly. Abstract descriptors/entities are ignored automatically.

What gets generated

When descriptors are found, the generator emits an extension class named EntityManagementRegistrationOf<YourAssemblyName> (dots removed). The method wires common services:

public static class EntityManagementRegistrationOfDocumentsDomain
{
    public static void AddDocumentsDomainEntityHandlers(this IServiceCollection services)
    {
        services.AddMemoryCache();
        services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(EntityManagementRegistrationOfDocumentsDomain).Assembly));
        services.AddSingleton<IEntityCacheInvalidationService, EntityCacheInvalidationService>();
        services.AddSingleton<EntityManagementInterceptor>();
        services.AddScoped<IEntityUserService, EntityUserService>();
        services.AddScoped<IEntityTimeService, EntityTimeService>();
        services.AddTransient<IRequestHandler<AddEntityCommand<Document, DocumentDescriptor>, Document?>, AddEntityHandler<Document, DocumentDescriptor>>();
        // ...additional handlers per aggregate...
    }
}

The registrations cover every command/query handler (Add, Update, Remove, Get, Count) along with the cache implementations needed by the core library.

Consuming the generated code

Call the extension method from your host or composition root:

builder.Services.AddDocumentsDomainEntityHandlers();

Because the extension lives in the same assembly as your entities, it travels with the project wherever it is referenced. IDEs expose the generated file in the Analyzers → Documents node so you can inspect the output.

Tips

  • Commit the attributes alongside your DTO/descriptor definitions so the generator immediately tracks new aggregates.
  • If you need bespoke registrations (e.g., custom caching), you can still call the generated method and then override specific services.
  • Combine with dotnet format/dotnet build in CI to catch analyzer errors early; the generator surfaces diagnostics if descriptor/entity types cannot be resolved.
Product 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
8.2.0-rc3 148 10/12/2025