Skip to content

Commit

Permalink
(NuGet#9) Remove empty entries from string list
Browse files Browse the repository at this point in the history
This strips empty entries from a string with multiple entries split
by a separator.

Brought forward from:
chocolatey/nuget-chocolatey@d344d47

Co-Authored-By: Rob Reynolds <[email protected]>
  • Loading branch information
2 people authored and gep13 committed Nov 21, 2022
1 parent 9c264ed commit 5af1170
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ internal void CalculateEffectivePackageSaveMode()
// The PackageSaveMode flag only determines if nuspec and nupkg are saved at the target location.
// For install \ restore, we always extract files.
EffectivePackageSaveMode = Packaging.PackageSaveMode.Files;
foreach (var v in packageSaveModeValue.Split(';'))

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

foreach (var v in packageSaveModeValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////
{
if (v.Equals(Packaging.PackageSaveMode.Nupkg.ToString(), StringComparison.OrdinalIgnoreCase))
{
Expand Down
10 changes: 9 additions & 1 deletion src/NuGet.Clients/NuGet.CommandLine/Common/ResourceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ public static string GetLocalizedString(Type resourceType, string resourceNames)
}

var builder = new StringBuilder();
foreach (var resource in resourceNames.Split(';'))

//////////////////////////////////////////////////////////
// Start - Chocolatey Specific Modification
//////////////////////////////////////////////////////////

foreach (var resource in resourceNames.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
//////////////////////////////////////////////////////////
// End - Chocolatey Specific Modification
//////////////////////////////////////////////////////////
{
var culture = LocalizedResourceManager.GetLanguageName();
string value = resourceManager.GetString(resource + '_' + culture, CultureInfo.InvariantCulture) ??
Expand Down

0 comments on commit 5af1170

Please sign in to comment.