-
Notifications
You must be signed in to change notification settings - Fork 698
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
Use OrdinalIgnoreCase for all Source and Package source mapping implementation #4264
Conversation
@@ -754,7 +754,7 @@ private ValueTask PopulateSourceRepoListAsync(IReadOnlyCollection<PackageSourceM | |||
{ | |||
SelectedSource = PackageSources | |||
// if the old active source still exists. Keep it as the active source. | |||
.FirstOrDefault(i => StringComparer.CurrentCultureIgnoreCase.Equals(i.SourceName, selectedSourceName)) |
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 one decides current active source.
@@ -810,7 +810,7 @@ public string[] GetAvailableProjects() | |||
safeAndDisplayName.Add(displayName); | |||
} | |||
// Sort with respect to the DisplayName | |||
var sortedDisplayNames = safeAndDisplayName.OrderBy(i => i.Item2, StringComparer.CurrentCultureIgnoreCase).ToArray(); |
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'm reverting this one, because it's working project names, not related to source.
@@ -708,7 +708,7 @@ private void UpdateActiveSource(string activePackageSource) | |||
else | |||
{ | |||
var s = _packageSources.FirstOrDefault( | |||
p => StringComparer.CurrentCultureIgnoreCase.Equals(p, activePackageSource)); |
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 one let user to choose between encyclopaedia
and encyclopædia
sources.
UI rendering not working correctly so created follow up issue NuGet/Home#11235
@@ -145,7 +145,7 @@ public bool Equals(PackageSource other) | |||
return false; | |||
} | |||
|
|||
return Name.Equals(other.Name, StringComparison.CurrentCultureIgnoreCase) && |
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.
After this change search is done on both encyclopaedia and encyclopædia sources
as separate sources.
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.
Were they treated the same before this change?
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.
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.
Reverting because it's already doing Source
compare with StringComparison.OrdinalIgnoreCase
. Here actually Source
is more important than Name
.
@@ -107,7 +107,7 @@ public static bool IsHttpSource(string source, PackageSourceProvider packageSour | |||
} | |||
|
|||
var packageSource = packageSourceProvider.LoadPackageSources() | |||
.FirstOrDefault(p => p.Name.Equals(source, StringComparison.CurrentCultureIgnoreCase)); |
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 IsHttpSource
method not used anywhere in our code, maybe we can remove it later.
@@ -64,7 +64,7 @@ public IEnumerable<PackageSource> DefaultPackageSources | |||
// In a SettingValue representing a package source, the Key represents the name of the package source and the Value its source | |||
_defaultPackageSources.Add(new PackageSource(source.GetValueAsPath(), | |||
source.Key, | |||
isEnabled: !disabledPackageSources.Any(p => p.Key.Equals(source.Key, StringComparison.CurrentCultureIgnoreCase)), |
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.
It's about adding default sources from NuGetDefaults.config
which exist on C:\Program Files (x86)\NuGet
path on Windows. https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior
Looks not popular feature, not sure how relevant now days.
Maybe we deprecate this one in the future?
@@ -158,8 +158,8 @@ private static void AddDefaultPackageSources(List<PackageSource> loadedPackageSo | |||
|
|||
foreach (var packageSource in defaultPackageSources) | |||
{ | |||
var sourceMatching = loadedPackageSources.Any(p => p.Source.Equals(packageSource.Source, StringComparison.CurrentCultureIgnoreCase)); |
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.
Related to https://github.com/NuGet/NuGet.Client/pull/4264/files#r708797119 on PMUI.
Looks not really relevant anymore.
@@ -302,8 +302,8 @@ private PackageSource GetPackageSource(string key, Dictionary<string, IndexedPac | |||
|
|||
foreach (var packageSource in _configurationDefaultSources) | |||
{ | |||
var isSourceMatch = loadedPackageSources.Any(p => p.Source.Equals(packageSource.Source, StringComparison.CurrentCultureIgnoreCase)); |
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.
Related to https://github.com/NuGet/NuGet.Client/pull/4264/files#r708797119 for nuget.exe.
Triggered for nuget sources Add -Name "MyServer" -Source \\myserver\packages
(https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-sources).
Looks not really relevant anymore.
@@ -48,7 +48,7 @@ public bool Equals(PackageSourceContextInfo other) | |||
return false; | |||
} | |||
|
|||
return Name.Equals(other.Name, StringComparison.CurrentCultureIgnoreCase) && |
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.
After this change search both encyclopaedia and encyclopædia sources as separate sources.
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 one also looks irrelevant change, reverting because it's already doing Source
compare with StringComparison.OrdinalIgnoreCase
. Here actually Source
is more important than Name
.
@@ -416,7 +416,7 @@ private TryUpdateSourceResults TryUpdateSource() | |||
return TryUpdateSourceResults.NotUpdated; | |||
} | |||
|
|||
if (selectedPackageSource.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase) && selectedPackageSource.Source.Equals(source, StringComparison.OrdinalIgnoreCase)) |
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 decided not to make this change in this file, revert the changes. It brings some unwanted side effects, if update existing source encyclopaedia
with Encyclopædia
on PMUI then save it creates duplicate entrees in nuget.config file.
Problem is when saving it check existing using packagesource key but due existing key entry following code it assumes above 2 are different hence creates another entry instead of updating it. Related to bdb3d6f#r709649975
@@ -425,7 +425,7 @@ private TryUpdateSourceResults TryUpdateSource() | |||
|
|||
// check to see if name has already been added | |||
// also make sure it's not the same as the aggregate source ('All') | |||
bool hasName = sourcesList.Any(ps => ps != selectedPackageSource && string.Equals(name, ps.Name, StringComparison.CurrentCultureIgnoreCase)); |
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 decided not to make this change in this file, revert the changes. It brings some unwanted side effects, if update existing source encyclopaedia
with Encyclopædia
on PMUI then save it creates duplicate entrees in nuget.config file.
Problem is when saving it check existing using packagesource key but due existing key entry following code it assumes above 2 are different hence creates another entry instead of updating it. Related to bdb3d6f#r709649975
@@ -77,8 +77,8 @@ public override bool Equals(object other) | |||
return true; | |||
} | |||
|
|||
return string.Equals(Key, source.Key, StringComparison.Ordinal) && |
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 decided to revert this change. For below input:
<packageSources>
<clear />
<add key="encyclopaedia" value="C:\Users\eryondon\Desktop\NamespaceTestPackages\PublicRepository" />
<add key="Encyclopaedia" value="https://api.nuget.org/v3/index.json" />
</packageSources>
Please note source url is quite different and looks breaking change experience for end user.
This reverts commit bdb3d6f.
063a4f4
to
50e2e87
Compare
e974543
to
6803b0e
Compare
|
||
// Create nuget.config with Package namespace filtering rules before project is created. | ||
CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.config"), $@"<?xml version=""1.0"" encoding=""utf-8""?> | ||
<configuration> | ||
<packageSources> | ||
<!--To inherit the global NuGet package sources remove the <clear/> line below --> | ||
<clear /> | ||
<add key=""ExternalRepository"" value=""{externalRepositoryPath}"" /> | ||
<add key=""PrivateRepository"" value=""{privateRepositoryPath}"" /> | ||
<add key=""encyclopaedia"" value=""{externalRepositoryPath}"" /> |
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.
Test "encyclopaedia" and "encyclopædia" sources used together doesn't crash VS PMUI setting.
@NuGet/nuget-client |
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 fact that there's so many culture comparison gives me a pause about the impact this change could have.
@@ -145,7 +145,7 @@ public bool Equals(PackageSource other) | |||
return false; | |||
} | |||
|
|||
return Name.Equals(other.Name, StringComparison.CurrentCultureIgnoreCase) && |
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.
Were they treated the same before this change?
@@ -22,7 +23,7 @@ public void UpdateModel(IItemLoaderState loaderState) | |||
PackageSearchStatus = Convert(loaderState.LoadingStatus); | |||
ItemsFound = loaderState.ItemsCount; | |||
|
|||
var convertedList = new System.Collections.SortedList(); |
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.
Make VS stop crashing NuGet/Home#11241
1ab4aed
to
29583e2
Compare
Bug
Fixes: NuGet/Home#11182
Fixes: NuGet/Home#11241
Regression? Last working version:
Description
@kartheekp-ms noticed we have inconsistent use of string comparison approach, after discussion we decided to use OrdinalIgnoreCase only for "Source and package source mapping", after my current changes I don't see any breaking or big difference after this change.
nuget.config used for my manual testing:
I didn't do changes in following places due to breaking/unwanted change:
See comment Use OrdinalIgnoreCase for all Source and Package source mapping implementation #4264 (comment) https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourcesOptionsControl.cs#L419
See comment Use OrdinalIgnoreCase for all Source and Package source mapping implementation #4264 (comment)
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Configuration/Settings/Items/SourceItem.cs#L80
In Apex tests I moved create nuget.config part before solution create action.
PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation