Conversation
martinrrm
left a comment
There was a problem hiding this comment.
LGTM. I agree that old behavior is weird. Name has the key attribute in XML element, using protocolVersion as a second key feels wrong.
jebriede
left a comment
There was a problem hiding this comment.
This is a good change since the protocol version shouldn't make the entry unique from one that doesn't have that attribute specified. @zivkan: What happens when a package source has a protocolVersion="3" and a user opens the Tools -> Options -> Package Source page, then just clicks OK? With this change, it should no longer be adding a second entry in the nuget.config, but will it update the package source item and remove the protocolVersion attribute? Or will it leave that attribute alone? It would be good to know what is happening in that scenario to see if it's expected behavior or if we have to make changes there as well.
I just tested this branch with a nuget.config that has just nuget.org with protocolVersion="3" and if I make an unrelated change in the Package Source Options dialog, such as adding another package source and click OK, it removes protocolVersion="3" from the nuget.org entry in the nuget.config. This feels wrong to me. If we aren’t supporting the PackageVersion property in the Package Sources UI, we should probably not be removing it either then unless this was a conscious design decision we made at some point. |
There was a problem hiding this comment.
I just tested this branch with a nuget.config that has just nuget.org with protocolVersion="3" and if I make an unrelated change in the Package Source Options dialog, such as adding another package source and click OK, it removes protocolVersion="3" from the nuget.org entry in the nuget.config. This feels wrong to me. If we aren’t supporting the PackageVersion property in the Package Sources UI, we should probably not be removing it either then unless this was a conscious design decision we made at some point.
Looks like we need a CompareTo method for PackageSource so we can safely ignore the ProtocolVersion in this case as part of the comparison.
|
Unfortunately, a new The package source options page ultimately calls into To fix this, we'd have to at the very minimum make the VS options page remember the I'll investigate having options just remember the previous |
c747bc0 to
86d3881
Compare
| ~override sealed NuGet.Configuration.AddItem.Equals(object other) -> bool | ||
| override sealed NuGet.Configuration.AddItem.GetHashCode() -> int |
There was a problem hiding this comment.
These are breaking changes in the Client SDK, with comments in AddItem.cs explaining why it's important. The bug prevented by making these methods sealed is subtle and these methods need to be implemented in a specific way that goes against normal coding conventions, hence the risk of defects is high (especially when the person implementing tests validate buggy behaviour 🤦)
...NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageSourceContextInfo.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Services/NuGetSourcesService.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Services/NuGetSourcesService.cs
Outdated
Show resolved
Hide resolved
86d3881 to
e0e743e
Compare
Bug
Fixes: NuGet/Home#12776
Fixes: NuGet/Home#10015
Regression? no
Description
When updating nuget.config's package sources (for example, to disable package one), the "name" should be a "key" used to match two SourceItems. Same name, then update the source, whether it's a change in
valueorprotocolVersion.Changed some tests, because in my opinion the old behaviour didn't make any sense.
Deleted
IPackageSourceProvider2and related code, because it was a codespaces change that 1. didn't work and 2. the people working on it marked it as obsolete rather than deleting it, and then never got around to deleting it as they had planned. This seems like a good a time as any to delete it, since it's impacting this PR's other changes.PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation