Skip to content

Add snitch why reverse dependency lookup#6

Merged
Cellcote merged 1 commit into
masterfrom
feature/why-command
May 16, 2026
Merged

Add snitch why reverse dependency lookup#6
Cellcote merged 1 commit into
masterfrom
feature/why-command

Conversation

@Cellcote
Copy link
Copy Markdown
Owner

Summary

  • New snitch why <package> [project|solution] command that walks each project's project.assets.json and prints every path from a direct reference (PackageReference or ProjectReference) down to the requested package. Output is a per-project Spectre tree with shared prefixes merged; project-ref hops are tagged (project) so they're easy to distinguish from NuGet packages.
  • Replaces running dotnet nuget why per project when chasing a vulnerable or unwanted transitive package — one command covers the whole solution.
  • Reuses the existing ProjectBuilder so --tfm, --skip, and solution/project discovery all behave the same as snitch analyze.

Example

> snitch why Newtonsoft.Json src/Snitch.Tests.Fixtures/Baz/Baz.csproj

Baz (netstandard2.0)
└── Bar 1.0.0 (project)
    └── Foo 1.0.0 (project)
        └── Newtonsoft.Json 12.0.1

Found 1 path(s) to Newtonsoft.Json across 1 project(s).

Test plan

  • dotnet test src/Snitch.Tests/Snitch.Tests.csproj — all 18 tests pass (6 new + 12 existing)
  • snitch why Newtonsoft.Json Foo.csproj shows direct ref
  • snitch why Newtonsoft.Json Baz.csproj walks Baz → Bar → Foo → Newtonsoft.Json via project refs
  • snitch why Microsoft.NETCore.Platforms Foo.csproj walks NETStandard.Library → Microsoft.NETCore.Platforms
  • snitch why System.Text.Json Foo.csproj reports "No dependency paths"
  • snitch why newtonsoft.json … matches case-insensitively
  • snitch why Newtonsoft.Json Snitch.Tests.Fixtures.sln finds paths in Foo, Zap, Thud, Thuuud

🤖 Generated with Claude Code

@Cellcote Cellcote changed the title Add reverse dependency lookup Add snitch why reverse dependency lookup May 15, 2026
@Cellcote Cellcote force-pushed the feature/why-command branch 2 times, most recently from 0daa926 to 395b2c3 Compare May 15, 2026 19:27
Adds a `why <package>` command that walks the project.assets.json graph
for every project in a solution and prints each dependency path from a
direct reference (PackageReference or ProjectReference) down to the
requested package. Replaces running `dotnet nuget why` per project when
chasing a vulnerable or unwanted transitive package.

Paths are merged into a per-project tree so shared prefixes collapse,
and project-reference hops are tagged so they're easy to distinguish
from NuGet packages.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Cellcote Cellcote force-pushed the feature/why-command branch from 395b2c3 to 9e55b70 Compare May 15, 2026 20:08
@Cellcote Cellcote merged commit 9cd5be0 into master May 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant