CRARCH0007 No IServiceProvider injection
- Category: Architecture
- Default severity: Warning
- Diagnostic ID:
CRARCH0007
What it checks
Section titled “What it checks”Service locator patterns hide dependencies and make code harder to reason about.
Diagnostic message
Section titled “Diagnostic message”Do not inject IServiceProvider; inject specific interfaces
How to resolve
Section titled “How to resolve”Inject explicit interfaces in constructors instead of IServiceProvider. Identify the services the type obtains through the provider and request their interfaces as constructor parameters. This makes the required dependencies visible in the constructor signature.