-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix new resolver when using transitive pinning to resolve subgraphs correctly #6149
Conversation
4ceba0a
to
bac3158
Compare
bac3158
to
bfb9b58
Compare
b9bc2bd
to
34d7faf
Compare
34d7faf
to
e0a77bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine! I definitely don't know much about this area, that method is massive though. A refactor would definitely help make it easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in DependencyGraphResolver look correct.
Still not 100% convinced RestoreCommand_WithPackageDrivenDowngradeAndTransitivePinning_ElevatesTransitiveToDirect_AndDoesNotRaiseWarning is the best solution, despite what the old algorithm did.
I did want to do add some IncludeAssets/ExcludeAssets tests to make sure they're not broken with this change.
Bug
Fixes: NuGet/Home#13938
Description
This fixes the new dependency resolver when transitive pinning is enabled and a package subgraph happens to contain versions that should or should not be eclipsed.
The way eclipsing works is for each subgraph, the first one wins:
In this case,
B 2.0.0
is part of the graph of A which already depends onB 1.0.0
soB 1.0.0
is chosen.However, if a higher version comes in through a different subgraph, a different version of
B
could win:In this case,
B 3.0.0
is not in the subgraph ofA
and its version eclipsesB 1.0.0
.Transitive pinning is supposed to be syntactic sugar for a direct dependency and so if you pinned
C 1.0.0
in the first example, the resolver treats the graph as:Now
B 2.0.0
is not part of the subgraph ofA
and the resolver should pickB 2.0.0
. However, the current implementation of the new resolver only looks to see if the proposedB 2.0.0
and the already chosenB 1.0.0
have the common ancestors. This leads to the new resolver resolving the wrong graph and logging downgrade warnings as described in NuGet/Home#13938The fix is to modify the paths for each item if it is pinned to correctly assess if a package should eclipse another. But when the paths are modified, the resolver must also keep track of the original parent in order to correctly create downgrade warnings if one exists.
PR Checklist