Add NuGet package analyzer (redundant & conflicting references) with :analyze packages CLI#423
Open
ChrisonSimtian wants to merge 4 commits into
Open
Conversation
…`:analyze packages` CLI Introduces Fallout.NuGet.Analysis, a dependency analyzer that reads the post-restore project.assets.json resolved graph and flags: - direct package references already provided by a referenced project - direct package references already pulled in transitively by another package - the same package resolving to different versions across projects The core library is free of CLI/build coupling so it can be consumed by both. Wires it up as `dotnet fallout :analyze packages [<path>] [--tfm] [--severity] [--exclude]`, emitting findings at a configurable log level and returning a severity-driven exit code. Implements Fallout-build#421. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Targeting a solution now reads real project membership through Fallout.Solutions.ReadSolution() instead of globbing the directory. Adds a `--format table|flat` option (table is the default) rendering findings as Spectre tables; flat keeps the log-line output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…onflicts behind --conflicts Table view now renders redundant references as a per-project tree (the actionable cleanup list) and hides version conflicts unless --conflicts is passed (then a compact counts view, or --verbose for the project lists). Version-conflict detection is now done per target framework, so a multi-targeted project that legitimately pins different versions across its own frameworks is no longer reported as a conflict. Conflict data is exposed structurally via Finding.ConflictVersions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rojects Adds Fallout.NuGet.Analysis + Fallout.NuGet.Analysis.Tests to the generated strongly-typed solution view (and picks up the pre-existing Components.Tests entry the snapshot was missing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
needs rebase onto #394 (stacked) or wait until that PR lands. But it would be cool to have an onboard dependency analyzer. We already walk the dependency path with our topo stuff, might as well spit this out (and keen to get this into a vs code extension as well) |
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.
Implements #421.
What this adds
A NuGet dependency analyzer — a "snitch" done on top of machinery Fallout already owns, available as a CLI command and built so a build target can consume it later.
Fallout.NuGet.Analysisreads the post-restoreproject.assets.json(the resolved dependency graph) and detects:PackageReferencealready provided by a referenced project.PackageReferencealready pulled in transitively by another package you reference.Detections 1 & 2 are one reachability check over the resolved graph: a direct package
Xis redundant when reachable through some other direct dependency (project or package).CLI
<path>— a.csproj, a directory, or a.sln/.slnx(parsed viaFallout.Solutions.ReadSolution()for real project membership). Defaults to the working directory.--conflicts(compact counts;--verbosefor project lists).--severitycontrols the log level findings emit at and whether the command exits non-zero (error→ CI gating).--format flatkeeps plain log lines.:analyzeis introduced as a command namespace so future analyzers slot in alongside.Guardrails
autoReferenced(SDK-implicit) andPrivateAssets=all(suppressParent) refs — can't / shouldn't be removed.Design notes
project.assets.jsondirectly — the post-restore truth that already encodes direct-ref intent (autoReferenced/suppressParent) and the resolved transitive graph with versions. No MSBuild evaluation needed; scales with file-read speed (markedly faster than snitch's per-project design-time builds). Requires a restore to have run.Fallout.NuGet.Analysis→ CLI today, a build target next).net10.0for now (matches the CLI); multi-target when build integration lands.Layout
src/Fallout.NuGet.Analysis/— core analyzer (assets reader + detections + result model).src/Fallout.Cli/Program.Analyze.cs— the:analyze packagescommand + table/flat rendering.tests/Fallout.NuGet.Analysis.Tests/— 6 unit tests over synthetic assets files (transitive redundancy safe + might-downgrade, auto-referenced/private-assets exclusion,--exclude, project-reference redundancy, cross-project version conflicts).Dogfooded
src/and against a large real-world solution (MyFoodBag) — surfaces genuine project-reference and package-transitive redundancies and cross-project version drift.Follow-ups (not in this PR)
LogLevel+ optional fail-on-finding.Directory.Build.props).