DependencyModulesDependency injection, decided at compile time
Declare registration next to the class it belongs to, and a source generator writes the IServiceCollection calls during the build. Nothing reflects, nothing scans at startup, and the trimmer can follow every registration you declared.
Every .NET application keeps a list like this, and nothing checks that it is complete:
csharp
services.AddScoped<IOrderRepository, OrderRepository>();services.AddSingleton<IEmailSender, SmtpEmailSender>();// … another two hundred lines
Forget a line and you find out at run time, in the environment you deployed to. Reach for a runtime scanner instead and you trade that for three new problems: you can no longer read what was registered, the scan runs on every start, and the trimmer cannot see through reflection — so a published, trimmed build registers nothing at all.