From 5af1170a364931bd5cae3cf3f302ec3ba7b6331e Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Wed, 13 Jul 2022 15:55:37 -0500 Subject: [PATCH] (#9) Remove empty entries from string list 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 <63502+ferventcoder@users.noreply.github.com> --- .../NuGet.CommandLine/Commands/DownloadCommandBase.cs | 10 +++++++++- .../NuGet.CommandLine/Common/ResourceHelper.cs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs b/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs index be92b1d1f96..90336f912f1 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs @@ -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)) { diff --git a/src/NuGet.Clients/NuGet.CommandLine/Common/ResourceHelper.cs b/src/NuGet.Clients/NuGet.CommandLine/Common/ResourceHelper.cs index db46a6e81c3..6e1f8d11aa6 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Common/ResourceHelper.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Common/ResourceHelper.cs @@ -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) ??