Repository navigation
Core Concepts
Alexander Stärk edited this page Sep 25, 2026
·
1 revision
Basilisque Dependency Injection has three core parts:
- Marker attributes on your service types
- A source generator that scans these attributes
- Generated registration code that integrates with
IServiceCollection
For each participating assembly, the generator creates:
- A
DependencyRegistratorclass -
IServiceCollectionextension methods in your root namespace:InitializeDependencies()RegisterServices()
RegisterServices() is the one-line default.
InitializeDependencies() gives you explicit control over the registration builder flow.
The generated registrator does not only register local services.
It also discovers Basilisque-generated registrators in referenced assemblies and adds them to a dependency collection. This allows registering an entire graph of Basilisque-enabled projects through one top-level call.
You can annotate classes, structs, and interfaces with:
RegisterServiceTransientRegisterServiceScopedRegisterServiceSingletonRegisterService(RegistrationScope...)
Shared options are available through RegisterServiceAttribute, including:
AsImplementsITypeNameFactoryFactoryMethodNameKey