Skip to content

The assembly identifier

How the Xxx in generated registration and mapping methods is derived, and how to override it.

1 min read

Every ImmediatePlatform generator emits assembly-level registration methods whose names contain an identifier derived from your assembly:

PackageGenerated method
Immediate.HandlersAddXxxHandlers(), AddXxxBehaviors()
Immediate.ApisMapXxxEndpoints()
Immediate.CacheAddXxxCaches()
Immediate.InjectionsAddXxxServices()
Immediate.JobsAddXxxJobs()

All five packages read the same source. Set it once and every generated method name changes together.

Default derivation

With no attribute present, the identifier is the assembly name with . and spaces removed, then trimmed.

Assembly nameIdentifierMethod
WebWebAddWebHandlers()
Application.WebApplicationWebAddApplicationWebHandlers()
My Cool.AppMyCoolAppAddMyCoolAppHandlers()

Overriding it

Apply the attribute anywhere in the assembly — conventionally in Program.cs or a dedicated AssemblyInfo.cs:

Program.cs
using Immediate.Handlers.Shared;

[assembly: ImmediateAssemblyIdentifier("Todo")]

Every applicable generator in the project now emits AddTodoHandlers(), MapTodoEndpoints(), AddTodoCaches(), AddTodoServices() and AddTodoJobs().

Validity rules

The supplied value is used only if it is a valid C# identifier that does not start with @. Otherwise the attribute is ignored and the default derivation is used instead.

[assembly: ImmediateAssemblyIdentifier("Todo App")]   // ignored — space is not valid
[assembly: ImmediateAssemblyIdentifier("@Todo")]      // ignored — leading @
[assembly: ImmediateAssemblyIdentifier("")]           // ignored — empty