What problem does it solve?
Inconsistent or incorrect dependency registrations lead to runtime errors, captive dependencies, thread-safety issues, and hard-to-debug lifetime problems; this Skill provides clear rules and patterns to register services correctly and avoid common DI anti-patterns.
Core Features & Use Cases
- Constructor injection guidance to eliminate service locator usage and make dependencies explicit.
- Lifetime decision guide for choosing between Singleton, Scoped, and Transient to prevent captive dependencies.
- Registration organization using IServiceCollection extension methods to modularize layer-specific services.
- Advanced patterns including keyed services for multiple implementations, decorator registration, factory delegates, and background service scoping with IServiceScopeFactory.
- Options and validation recommendations such as ValidateOnStart and strongly-typed options binding.
- Anti-pattern detection checklist and migration steps for integrating into existing projects.
Quick Start
Create an IServiceCollection extension method for your layer, move all builder.Services.Add* calls into it, and call that method from Program.cs to centralize registrations and lifetimes.