-
Notifications
You must be signed in to change notification settings - Fork 701
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
Rename types/variables in the product/test code to reflect package source mapping #4281
Rename types/variables in the product/test code to reflect package source mapping #4281
Conversation
|
||
namespace NuGet.Configuration | ||
{ | ||
internal class PackageNamespacesProvider |
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.
I meant to rename this file but I forgot what user actions in the IDE lead to deleting this file and creating a new one with the name PackageSourceMappingProvider.cs
...Get.Clients/NuGet.PackageManagement.PowerShellCmdlets/Utility/PackageSourceMappingUtility.cs
Show resolved
Hide resolved
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 pretty thorough to me.
Some minor feedback.
@@ -7,7 +7,7 @@ | |||
|
|||
namespace NuGet.Configuration | |||
{ | |||
public class PackageNamespacesConfiguration | |||
public class PackageSourceMappingConfiguration |
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.
naming: Should this simply be PackageSourceMapping
?
Configuration might be superfluous?
Hoping @zivkan can provide some feedback as well.
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.
PackageSourceMappingConfiguration
is too long, so above suggestion is good for me. If we do above then need to do same for PackageSourceMappingConfigurationUtility
and other variables too.
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.
Yes, I like PackageSourceMapping
. Pretending that I'm working on something in restore, unrelated to the package source mapping feature, I feel like it should be sufficiently obvious it's a class that holds a mapping between package prefixes are package sources. Therefore, I don't think the name Configuration
adds clarification. I also can't think why there'd be any PackageSourceMapping
class in any assembly other than NuGet.Configuration
, so I think it passes all the naming tests I can think of.
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.
I renamed the type to PackageSourceMapping
in the latest commit which already passed all CI checks.
src/NuGet.Core/NuGet.Configuration/Settings/SettingElementType.cs
Outdated
Show resolved
Hide resolved
@@ -121,11 +121,11 @@ | |||
<value>The feed '{0}' lists package '{1}' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.</value> | |||
</data> | |||
<data name="Log_MatchingSourceFoundForPackage" xml:space="preserve"> | |||
<value>Package namespace matches found for package ID '{0}' are: '{1}'.</value> | |||
<value>Package source mapping pattern matches found for package ID '{0}' are: '{1}'.</value> |
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.
You might've already done it, but I'd rather provide the feedback than risk us missing something.
Consider search for the word namespace
in all resx files in our repo.
My guess is that we shouldn't have any hits.
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.
I did search for namespace
in all the files in the repo (that includes resx files) and could not find a keyword namespaces
in the context of source mapping
feature.
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.
Awesome! Thanks for being so thorough! Very important with a PR like this.
<comment>{0} - Package id {1} - list of sources</comment> | ||
</data> | ||
<data name="Log_NoMatchingSourceFoundForPackage" xml:space="preserve"> | ||
<value>Package namespace match not found for package ID '{0}'.</value> | ||
<value>Package source mapping pattern match not found for package ID '{0}'.</value> |
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.
Is pattern still necessary here?
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.
removed the pattern from the log message
<data name="PackageNamespaceNoMatchFound" xml:space="preserve"> | ||
<value>Package namespace match not found for package ID '{0}'</value> | ||
<data name="PackageSourceMappingPatternNoMatchFound" xml:space="preserve"> | ||
<value>Package source mapping pattern match not found for package ID '{0}'</value> |
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.
If you agree with my feedback on removing pattern above, it'd apply here as well.
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.
removed pattern from the log message.
|
||
foreach (PackageNamespacesSourceItem packageSourceNamespaceItem in packageNamespacesProvider.GetPackageSourceNamespaces()) | ||
foreach (PackageSourceMappingSourceItem packageSourceNamespaceItem in packageSourceMappingProvider.GetPackageSourceMappingItems()) |
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.
Maybe GetPackageSourceMappingPatterns
could be better description of what it does?
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.
PackageSourceMappingProvider
is an internal type. I think GetPackageSourceMappingItems
is more apt because it returns a list of type PackageSourceMappingSourceItem
. Please let me know if you disagree.
/// </summary> | ||
public IList<NamespaceItem> Namespaces { get; } | ||
public IList<PackagePatternItem> Patterns { get; } |
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.
public IList<PackagePatternItem> Patterns { get; } | |
public IList<PackagePatternItem> SourcePatterns { get; } |
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.
Given that the type name PackageSourceMappingSourceItem
has Source
word twice, I think just Patterns
seems okay to me. Earlier it was Namespaces
and I just replaced it with Patterns
because the XML element <packageSource>
contains a list of patterns. Please let me know your feedback. cc @nkolev92
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.
I like Patterns
.
If we were going to make it verbose, I'd argue PackagePatterns is the right name over SourcePatterns.
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.
I like Patterns
too. If I use PackagePatterns
the term Package
may be repeated twice once in the type name and in the property name.
test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceMappingConfigurationTests.cs
Outdated
Show resolved
Hide resolved
test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceMappingConfigurationTests.cs
Outdated
Show resolved
Hide resolved
...uGet.Core/NuGet.Commands/RestoreCommand/RequestFactory/DependencyGraphSpecRequestProvider.cs
Outdated
Show resolved
Hide resolved
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.
1 important comment and a bunch of little ones.
@@ -382,9 +382,9 @@ private async Task<IReadOnlyList<RestoreSummary>> PerformNuGetV2RestoreAsync(Pac | |||
cacheContext.NoCache = NoCache; | |||
cacheContext.DirectDownload = DirectDownload; | |||
|
|||
PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(Settings); | |||
PackageSourceMapping packageSourceMappingConfiguration = PackageSourceMapping.GetPackageSourceMappingConfiguration(Settings); |
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.
nit: var name. Not critical.
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.
This applies in many spots. You can consider changing these.
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.
fixed it in all the places using find and replace.
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 like there's still a bunch of these instances. Can you please double check that you committed those changes?
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.
Bumping this.
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.
I think I got it right this time and fixed in other places too.
/// <exception cref="ArgumentNullException"> if <paramref name="settings"/> is null.</exception> | ||
public static PackageNamespacesConfiguration GetPackageNamespacesConfiguration(ISettings settings) | ||
public static PackageSourceMapping GetPackageSourceMappingConfiguration(ISettings settings) |
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.
This should be GetPackageSourceMapping
.
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.
I thought about it when I renamed PackageSourceMappingConfiguration
type to PackageSourceMapping
but forgot to update the method name. thanks, Nikolche. Fixed in the next commit.
/// </summary> | ||
public IList<NamespaceItem> Namespaces { get; } | ||
public IList<PackagePatternItem> Patterns { get; } |
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.
I like Patterns
.
If we were going to make it verbose, I'd argue PackagePatterns is the right name over SourcePatterns.
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.
I looked only at the PublicAPI txt files, as they're more or less the only breaking changes. Everything else we can refactor in the future without API changes.
NuGet.Configuration.PackagePatternItem.PackagePatternItem(string pattern) -> void | ||
NuGet.Configuration.PackagePatternItem.Pattern.get -> string | ||
NuGet.Configuration.PackageSourceMapping | ||
NuGet.Configuration.PackageSourceMapping.GetConfiguredPackageSources(string term) -> System.Collections.Generic.IReadOnlyList<string> |
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.
I think packageId
makes more sense than term
.
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.
Fixed in the latest commit.
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.
Actually mostly packagePrefix than packageId, but I'm ok with packageId
.
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.
Isn't that API the package id exactly?
It's getting the sources for a specific package.
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.
Yes Nikolche that is correct, exact packageId is passed as parameter to this method to find out package sources associated with the longest matching prefix.
NuGet.Configuration.PackageSourceMapping.IsEnabled.get -> bool | ||
NuGet.Configuration.PackageSourceMappingSourceItem | ||
NuGet.Configuration.PackageSourceMappingSourceItem.PackageSourceMappingSourceItem(string name, System.Collections.Generic.IEnumerable<NuGet.Configuration.PackagePatternItem> packagePatternItems) -> void | ||
NuGet.Configuration.PackageSourceMappingSourceItem.Patterns.get -> System.Collections.Generic.IList<NuGet.Configuration.PackagePatternItem> |
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.
Does the order of patterns matter? If not, then ICollection<T>
might be a more minimalist interface for how the result is used.
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.
Fixed in the latest commit.
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.
I disagree with this.
Using too generic interfaces like that can lead to lots of accidental and unnecessary enumerations.
We should stick with IList imo.
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.
reverted the last commit where I changed the Patterns type
to ICollection
cc2cf41
to
779e31f
Compare
…eSourceMappingUtility
@@ -371,9 +371,9 @@ private CommandLineSourceRepositoryProvider GetSourceRepositoryProvider() | |||
resolutionContext.SourceCacheContext.NoCache = NoCache; | |||
resolutionContext.SourceCacheContext.DirectDownload = DirectDownload; | |||
|
|||
PackageNamespacesConfiguration packageNamespacesConfiguration = PackageNamespacesConfiguration.GetPackageNamespacesConfiguration(Settings); | |||
var packageSourceMappingConfiguration = PackageSourceMapping.GetPackageSourceMapping(Settings); |
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.
nit: var naming.
Note that searching for packageSourceMappingConfiguration
reveals 27 hits just on GitHub.
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.
I didn't change the variable names but focused on using var
keyword to avoid breaking references to it. I will create a follow-up PR and fix the variable names, if needed.
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.
My comment is not about the var
keyword, it's about the naming.
It's var packageSourceMappingConfiguration
, but should be var packageSourceMapping
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.
sure. I will fix the variable naming in the follow-up issue. https://github.com/NuGet/Client.Engineering/issues/1219
Bug
Fixes: NuGet/Home#11216
Regression? Last working version:
Description
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
This is a follow-up PR to address Rename packageNamespaces to packageSourceMapping, namespace to package and id to pattern #4234 (review) comment. Renamed all the types, variables, and comments to the best of my search capability in the product/test code to reflect package source mapping instead of package namespaces.
Tests
Documentation