When this page is relevant
Use compile-time diagnostics to catch singleton-to-scoped and singleton-to-transient lifetime mismatches before stale state or thread-safety bugs ship.
Problem guide
This page is for teams searching for captive dependency detection in ASP.NET Core, worker services, and generic-host apps.
When this page is relevant
Use compile-time diagnostics to catch singleton-to-scoped and singleton-to-transient lifetime mismatches before stale state or thread-safety bugs ship.
Recommended install command
dotnet add package DependencyInjection.Lifetime.Analyzers --version 2.2.2
Relevant diagnostics
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.
DI009
open generic singleton registrations that depend on shorter-lived services.