What problem does it solve?
Uncontrolled dependency injection patterns in Blazor can lead to runtime failures, singleton leaks, and hard-to-test code, so this guidance keeps constructors, components, and services aligned with predictable DI behavior.
Core Features & Use Cases
- Constructor injection focus: Emphasizes required constructor parameters and discourages instantiating dependencies inside methods when DI can provide them.
- Blazor component guidance: Reinforces using [Inject] with required for UI components and avoids service locator anti-patterns that hide dependencies.
- Configuration handling: Recommends IOptions<T> for configuration-bound services instead of passing IConfiguration throughout business logic.
- Use case: When adding a new service, handler, or component that relies on shared app services, follow these guidelines to register the service properly and wire dependencies cleanly.
Quick Start
Ask the assistant to review a Blazor component or service constructor and ensure it uses required constructor injection, required [Inject] properties, and IOptions for configuration instead of manual instantiation.