Skip to content

CRARCH0007 No IServiceProvider injection

  • Category: Architecture
  • Default severity: Warning
  • Diagnostic ID: CRARCH0007

Service locator patterns hide dependencies and make code harder to reason about.

Do not inject IServiceProvider; inject specific interfaces

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.