Repository navigation
Manual Registrator Customization
Alexander Stärk edited this page Sep 25, 2026
·
1 revision
This page is about manual customization of the generated DependencyRegistrator partial class inside a consumer project.
It is not the same concept as analyzer extension support for other source generators.
For analyzer extension support, see Analyzer Extension Support (for Source Generators).
The generated DependencyRegistrator is partial and intentionally extensible.
Use custom partial method implementations when:
- you need registrations that are hard to express with attributes
- you need pre/post logic around generated registration
- you want to integrate registrations from other tools
using Microsoft.Extensions.DependencyInjection;
public partial class DependencyRegistrator
{
partial void doAfterRegistration(IServiceCollection services)
{
services.AddSingleton<IMyManualService, MyManualService>();
}
}You can implement any generated partial hook methods your scenario requires.
Recommended split:
- Attribute registrations: default path for most services
- Partial extension code: exceptional or advanced scenarios
This keeps generated and manual registration logic easy to maintain.