Add snitch why reverse dependency lookup#6
Merged
Conversation
snitch why reverse dependency lookup
4 tasks
0daa926 to
395b2c3
Compare
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>
395b2c3 to
9e55b70
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
snitch why <package> [project|solution]command that walks each project'sproject.assets.jsonand 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.dotnet nuget whyper project when chasing a vulnerable or unwanted transitive package — one command covers the whole solution.ProjectBuilderso--tfm,--skip, and solution/project discovery all behave the same assnitch analyze.Example
Test plan
dotnet test src/Snitch.Tests/Snitch.Tests.csproj— all 18 tests pass (6 new + 12 existing)snitch why Newtonsoft.Json Foo.csprojshows direct refsnitch why Newtonsoft.Json Baz.csprojwalksBaz → Bar → Foo → Newtonsoft.Jsonvia project refssnitch why Microsoft.NETCore.Platforms Foo.csprojwalksNETStandard.Library → Microsoft.NETCore.Platformssnitch why System.Text.Json Foo.csprojreports "No dependency paths"snitch why newtonsoft.json …matches case-insensitivelysnitch why Newtonsoft.Json Snitch.Tests.Fixtures.slnfinds paths in Foo, Zap, Thud, Thuuud🤖 Generated with Claude Code