DI001
Service Scope Not Disposed
`IServiceScope` instances created with `CreateScope()` or `CreateAsyncScope()` that are never disposed.
Rules
Browse all analyzer rules with rule summaries, README examples, and extracted sample-app snippets.
DI001
`IServiceScope` instances created with `CreateScope()` or `CreateAsyncScope()` that are never disposed.
DI002
a service resolved from a scope that is returned or stored somewhere longer-lived.
DI003
singleton services capturing scoped or transient dependencies, including constructor injection and high-confidence factory paths such as inline delegates, method-group factories, keyed resolutions, and `ActivatorUtilities.CreateInstance(...)` without explicit constructor arguments.
DI004
using a service after the scope that produced it has already ended.
DI005
`CreateScope()` used in async flows where async disposal is needed.
DI006
`IServiceProvider` / `IServiceScopeFactory` / keyed provider stored in static fields or properties.
DI007
resolving dependencies via `IServiceProvider` inside app logic.
DI008
transient services implementing `IDisposable`/`IAsyncDisposable` in risky patterns.
DI009
open generic singleton registrations that depend on shorter-lived services.
DI010
constructors with too many meaningful dependencies.
DI011
constructor injection of `IServiceProvider`, `IServiceScopeFactory`, or `IKeyedServiceProvider` in normal services.
DI012
- `TryAdd*` calls after an `Add*` already registered that service.
DI013
invalid `typeof` service/implementation pairs that compile but fail at runtime.
DI014
root providers from `BuildServiceProvider()` that are never disposed.
DI015
registered services with direct or transitive constructor/factory dependencies that are not registered (including keyed and open-generic paths).
DI016
`BuildServiceProvider()` calls while composing registrations (for example in `ConfigureServices`, `IServiceCollection` extension registration methods, or registration lambdas).