DependencyInjection.Lifetime.Analyzers.Scan 3.10.1

dotnet tool install --global DependencyInjection.Lifetime.Analyzers.Scan --version 3.10.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DependencyInjection.Lifetime.Analyzers.Scan --version 3.10.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DependencyInjection.Lifetime.Analyzers.Scan&version=3.10.1
                    
nuke :add-package DependencyInjection.Lifetime.Analyzers.Scan --version 3.10.1
                    

DI Scan

Scan any .NET solution for Microsoft.Extensions.DependencyInjection lifetime problems without adding a package to it.

dnx DependencyInjection.Lifetime.Analyzers.Scan                 # .NET 10 SDK, no install step
dnx DependencyInjection.Lifetime.Analyzers.Scan -- MyApp.slnx -o results.sarif

dotnet tool install -g DependencyInjection.Lifetime.Analyzers.Scan   # .NET 8 or 9 SDK
di-scan MyApp.slnx

The scanner builds the solution with the DependencyInjection.Lifetime.Analyzers analyzers injected, then prints the rules that fired, how often, where, the surrounding source, and a link to each rule's page. It also writes a SARIF 2.1.0 file for GitHub code scanning. Your project files are not changed.

Use it to try the analyzers on a real codebase before adding the package, compare releases, and review suspected false positives with the surrounding source in the HTML report.

Proof

The scanner and rules are regression-tested against 14 pinned public repositories and 471 findings, including ASP.NET Core apps, framework libraries, workers, open generics, keyed services, and alternate containers. The corpus has already driven precision fixes in DI001, DI006, DI015, and DI019. See the scanner guide and corpus triage notes.

Why teams use it

  • Try the analyzer on a real repository before changing its project files.
  • Review suspected false positives with code context in the HTML report.
  • Fail CI only on new findings with SARIF or text baselines.
  • Compare analyzer releases on the same pinned public corpus.

DI Scan HTML report showing DI003, DI006, DI009, DI016, DI019, and DI012b findings with source context

Options

Option Meaning
<path> Solution (.sln or .slnx), project, or directory. Defaults to the current directory.
-o, --sarif <file> Where to write the SARIF 2.1.0 report. Defaults to di-scan.sarif.
-c, --configuration <name> Build configuration, passed to dotnet build.
-f, --framework <tfm> Build one target framework only.
--no-restore Skip the implicit restore.
--rules <ids> Report only these rules, comma-separated, such as DI003,DI016. Repeatable.
--skip-rules <ids> Leave these rules out, comma-separated. Repeatable.
--exclude <glob> Leave out findings in matching files, such as tests/**. Repeatable.
--fail-on <level> Exit with code 1 when a finding is at least this severe: error, warning, or info. Defaults to none.
--baseline <file> A SARIF report or text baseline from an earlier scan. Only findings it does not have are listed and count for --fail-on.
--update-baseline <file> Write the current findings as a text baseline and exit successfully unless the build or a fix failed.
--fix Apply the rules' code fixes with dotnet format before scanning. Edits source files; review the diff.
--html <file> Also write a self-contained HTML report with code around each finding.
--summary <file> Also write the report as Markdown.
--no-github In GitHub Actions, skip the job summary and pull request annotations.
--findings <n\|all> Findings to list under each rule. Defaults to 3.
--context <n> Lines of source above and below each finding. Defaults to 2.
--top <n> Files to list under "Most affected files". Defaults to 10.
-v, --verbose Show the full dotnet build output.
--version Show the scanner version.
-h, --help Show usage.

Put the scanner's arguments after -- when using dnx.

False-positive triage

The HTML report is the fastest review surface:

di-scan ./MyApp.slnx --findings all --html di-review.html

It groups findings by rule, shows the message and a few lines of source around every hit, and provides search and severity filters. For a focused review, limit the scan to one rule:

di-scan ./MyApp.slnx --rules DI003 --html di003.html

The text and Markdown reports show the source line, so a suspected false positive can be checked against the exact code path without opening the solution. Suppressed diagnostics are omitted, just as they are in a normal build.

Baselines

A text baseline is one finding per line, exactly what the scanner prints:

# repository: example/App
# commit: 0123456789abcdef0123456789abcdef01234567
# target: App.sln
# exit: 0
DI003 src/App/Startup.cs:42:17

Pass it with --baseline. A SARIF report from an earlier scan works too; the scanner matches its fingerprints, so a finding that moves down a file stays known.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
3.10.1 111 10/27/2026
3.10.0 99 10/27/2026
3.9.3 99 10/27/2026
3.9.2 89 10/27/2026
3.9.1 95 10/27/2026
3.9.0 95 10/27/2026

Strengthened the shared-resolution-helper mutation gate from 80.00% to 94.92% with direct tests for assignability, constructor selection, and keyed-service extraction. | Refactored the nullable assignability check into explicit guards. No analyzer or scanner behavior changes.