From 42566a0790feeba42c1e794c21d4831fb937c8a9 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 30 May 2023 11:40:10 +0100 Subject: [PATCH 1/2] (#1000) Ensure sensitive arguments are detected When the ability to show remembered arguments in Chocolatey GUI was first introduced, code from the set_package_config_for_upgrade (which was renamed to SetConfigFromRememberedArguments) method was borrowed, as it was doing very similar work. However, the code that was brought over to Chocolatey GUI failed to realise that after splitting the arguments on " --", when passed into the arguments_contain_sensitive_information (which was renamed to SensitiveArgumentsProvided) that a sensitive variable would no longer be detected as this method expects that all arguments under test start with a "-". Without a major refactoring of how this works, the simplest way is to put "--" back on the start of each argument, before passing into the arguments_contain_sensitive_information method, that way, it will correctly return whether it is a sensitive argument or not. There is a larger discussion around whether a sensitive argument should be persisted or not, but that is otwith the scope of this change. --- .../Services/PackageArgumentsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs b/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs index 89c5309e8..b68efaf38 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs @@ -82,7 +82,7 @@ public IEnumerable DecryptPackageArgumentsFile(string id, string version foreach (var packageArgument in packageArgumentsSplit.or_empty_list_if_null()) { - var isSensitiveArgument = sensitiveArgs && ArgumentsUtility.arguments_contain_sensitive_information(packageArgument); + var isSensitiveArgument = sensitiveArgs && ArgumentsUtility.arguments_contain_sensitive_information(string.Concat("--", packageArgument)); var packageArgumentSplit = packageArgument.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries); From 47e2093f7bbca1821f556ab4b1e23e80dc97d271 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 30 May 2023 14:07:12 +0100 Subject: [PATCH 2/2] (maint) Remove usage of obsolete methods All of these methods have been marked as obsolete in Chocolatey codebase, so switched to using the newly named versions. --- .../Bootstrapper.cs | 10 ++-- .../Services/ChocolateyService.cs | 48 +++++++++---------- .../Services/PackageArgumentsService.cs | 26 +++++----- .../ViewModels/AdvancedInstallViewModel.cs | 2 +- .../Views/ShellView.xaml.cs | 2 +- .../Commands/ConfigCommand.cs | 10 ++-- .../Commands/FeatureCommand.cs | 4 +- .../Commands/GenericRunner.cs | 4 +- .../Models/AppConfiguration.cs | 2 +- .../ChocolateyConfigurationProvider.cs | 4 +- .../Services/ChocolateyGuiCacheService.cs | 14 +++--- .../Services/ConfigService.cs | 10 ++-- .../Startup/AutoFacConfiguration.cs | 6 +-- 13 files changed, 71 insertions(+), 71 deletions(-) diff --git a/Source/ChocolateyGui.Common.Windows/Bootstrapper.cs b/Source/ChocolateyGui.Common.Windows/Bootstrapper.cs index 671075bbc..183fcf594 100644 --- a/Source/ChocolateyGui.Common.Windows/Bootstrapper.cs +++ b/Source/ChocolateyGui.Common.Windows/Bootstrapper.cs @@ -37,13 +37,13 @@ public class Bootstrapper : BootstrapperBase private static readonly IFileSystem _fileSystem = new DotNetFileSystem(); #pragma warning disable SA1202 - public static readonly string ChocolateyGuiInstallLocation = _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path()); + public static readonly string ChocolateyGuiInstallLocation = _fileSystem.GetDirectoryName(_fileSystem.GetCurrentAssemblyPath()); public static readonly string ChocolateyInstallEnvironmentVariableName = "ChocolateyInstall"; - public static readonly string ChocolateyInstallLocation = System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) ?? _fileSystem.get_directory_name(_fileSystem.get_current_assembly_path()); - public static readonly string LicensedGuiAssemblyLocation = _fileSystem.combine_paths(ChocolateyInstallLocation, "extensions", "chocolateygui", "chocolateygui.licensed.dll"); + public static readonly string ChocolateyInstallLocation = System.Environment.GetEnvironmentVariable(ChocolateyInstallEnvironmentVariableName) ?? _fileSystem.GetDirectoryName(_fileSystem.GetCurrentAssemblyPath()); + public static readonly string LicensedGuiAssemblyLocation = _fileSystem.CombinePaths(ChocolateyInstallLocation, "extensions", "chocolateygui", "chocolateygui.licensed.dll"); - public static readonly string ChocolateyGuiCommonAssemblyLocation = _fileSystem.combine_paths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.dll"); - public static readonly string ChocolateyGuiCommonWindowsAssemblyLocation = _fileSystem.combine_paths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.Windows.dll"); + public static readonly string ChocolateyGuiCommonAssemblyLocation = _fileSystem.CombinePaths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.dll"); + public static readonly string ChocolateyGuiCommonWindowsAssemblyLocation = _fileSystem.CombinePaths(ChocolateyGuiInstallLocation, "ChocolateyGui.Common.Windows.dll"); public static readonly string ChocolateyGuiCommonAssemblySimpleName = "ChocolateyGui.Common"; public static readonly string ChocolateyGuiCommonWindowsAssemblySimpleName = "ChocolateyGui.Common.Windows"; diff --git a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs index 9be15c5db..de9df8649 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs @@ -60,7 +60,7 @@ public ChocolateyService(IMapper mapper, IProgressService progressService, IChoc _configService = configService; _choco = Lets.GetChocolatey(initializeLogging: false).SetCustomLogging(new SerilogLogger(Logger, _progressService), logExistingMessages: false, addToExistingLoggers: true); - _localAppDataPath = _fileSystem.combine_paths(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "Chocolatey GUI"); + _localAppDataPath = _fileSystem.CombinePaths(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "Chocolatey GUI"); } public Task IsElevated() @@ -73,7 +73,7 @@ public async Task> GetInstalledPackages() _choco.Set( config => { - config.CommandName = CommandNameType.list.ToString(); + config.CommandName = CommandNameType.List.ToString(); }); var chocoConfig = _choco.GetConfiguration(); @@ -91,7 +91,7 @@ public async Task> GetInstalledPackages() else { var nugetService = _choco.Container().GetInstance(); - var packages = await Task.Run(() => nugetService.list_run(chocoConfig)); + var packages = await Task.Run(() => nugetService.List(chocoConfig)); return packages .Select(package => GetMappedPackage(_choco, package, _mapper, true)) .ToArray(); @@ -107,7 +107,7 @@ public async Task> GetOutdatedPackages(bool inclu return new List(); } - var outdatedPackagesFile = _fileSystem.combine_paths(_localAppDataPath, "outdatedPackages.xml"); + var outdatedPackagesFile = _fileSystem.CombinePaths(_localAppDataPath, "outdatedPackages.xml"); var outdatedPackagesCacheDurationInMinutesSetting = _configService.GetEffectiveConfiguration().OutdatedPackagesCacheDurationInMinutes; int outdatedPackagesCacheDurationInMinutes = 0; @@ -116,9 +116,9 @@ public async Task> GetOutdatedPackages(bool inclu int.TryParse(outdatedPackagesCacheDurationInMinutesSetting, out outdatedPackagesCacheDurationInMinutes); } - if (_fileSystem.file_exists(outdatedPackagesFile) && (DateTime.Now - _fileSystem.get_file_modified_date(outdatedPackagesFile)).TotalMinutes < outdatedPackagesCacheDurationInMinutes) + if (_fileSystem.FileExists(outdatedPackagesFile) && (DateTime.Now - _fileSystem.GetFileModifiedDate(outdatedPackagesFile)).TotalMinutes < outdatedPackagesCacheDurationInMinutes) { - return _xmlService.deserialize>(outdatedPackagesFile); + return _xmlService.Deserialize>(outdatedPackagesFile); } else { @@ -140,7 +140,7 @@ public async Task> GetOutdatedPackages(bool inclu if (chocoConfig.Sources != null) { var nugetService = choco.Container().GetInstance(); - var packages = await Task.Run(() => nugetService.upgrade_noop(chocoConfig, null)); + var packages = await Task.Run(() => nugetService.UpgradeDryRun(chocoConfig, null)); var results = packages .Where(p => !p.Value.Inconclusive) .Select(p => new OutdatedPackage @@ -154,12 +154,12 @@ public async Task> GetOutdatedPackages(bool inclu // packages, when the serialized file has become old/stale, so we NEED the file to be re-written // when this check is done, so that it isn't always doing the check. Therefore, when we are // getting ready to serialize the list of outdated packages, if the file already exists, delete it. - if (_fileSystem.file_exists(outdatedPackagesFile)) + if (_fileSystem.FileExists(outdatedPackagesFile)) { - _fileSystem.delete_file(outdatedPackagesFile); + _fileSystem.DeleteFile(outdatedPackagesFile); } - _xmlService.serialize(results, outdatedPackagesFile); + _xmlService.Serialize(results, outdatedPackagesFile); } catch (Exception ex) { @@ -189,7 +189,7 @@ public async Task InstallPackage( choco.Set( config => { - config.CommandName = CommandNameType.install.ToString(); + config.CommandName = CommandNameType.Install.ToString(); config.PackageNames = id; config.Features.UsePackageExitCodes = false; @@ -369,7 +369,7 @@ public async Task UninstallPackage(string id, string ver choco.Set( config => { - config.CommandName = CommandNameType.uninstall.ToString(); + config.CommandName = CommandNameType.Uninstall.ToString(); config.PackageNames = id; config.Features.UsePackageExitCodes = false; @@ -392,7 +392,7 @@ public async Task UpdatePackage(string id, Uri source = choco.Set( config => { - config.CommandName = CommandNameType.upgrade.ToString(); + config.CommandName = CommandNameType.Upgrade.ToString(); config.PackageNames = id; config.Features.UsePackageExitCodes = false; }); @@ -409,7 +409,7 @@ public async Task PinPackage(string id, string version) config => { config.CommandName = "pin"; - config.PinCommand.Command = PinCommandType.add; + config.PinCommand.Command = PinCommandType.Add; config.PinCommand.Name = id; config.Version = version; config.Sources = ApplicationParameters.PackagesLocation; @@ -436,7 +436,7 @@ public async Task UnpinPackage(string id, string version config => { config.CommandName = "pin"; - config.PinCommand.Command = PinCommandType.remove; + config.PinCommand.Command = PinCommandType.Remove; config.PinCommand.Name = id; config.Version = version; config.Sources = ApplicationParameters.PackagesLocation; @@ -474,7 +474,7 @@ public async Task SetFeature(ChocolateyFeature feature) config => { config.CommandName = "feature"; - config.FeatureCommand.Command = feature.Enabled ? chocolatey.infrastructure.app.domain.FeatureCommandType.enable : chocolatey.infrastructure.app.domain.FeatureCommandType.disable; + config.FeatureCommand.Command = feature.Enabled ? chocolatey.infrastructure.app.domain.FeatureCommandType.Enable : chocolatey.infrastructure.app.domain.FeatureCommandType.Disable; config.FeatureCommand.Name = feature.Name; }); @@ -497,7 +497,7 @@ public async Task SetSetting(ChocolateySetting setting) config => { config.CommandName = "config"; - config.ConfigCommand.Command = chocolatey.infrastructure.app.domain.ConfigCommandType.set; + config.ConfigCommand.Command = chocolatey.infrastructure.app.domain.ConfigCommandType.Set; config.ConfigCommand.Name = setting.Key; config.ConfigCommand.ConfigValue = setting.Value; }); @@ -514,7 +514,7 @@ public async Task GetSources() var config = await GetConfigFile(); var allSources = config.Sources.Select(_mapper.Map).ToArray(); - var filteredSourceIds = _configSettingsService.source_list(_choco.GetConfiguration()).Select(s => s.Id).ToArray(); + var filteredSourceIds = _configSettingsService.ListSources(_choco.GetConfiguration()).Select(s => s.Id).ToArray(); var mappedSources = allSources.Where(s => filteredSourceIds.Contains(s.Id)).ToArray(); return mappedSources; @@ -528,7 +528,7 @@ public async Task AddSource(ChocolateySource source) config => { config.CommandName = "source"; - config.SourceCommand.Command = SourceCommandType.add; + config.SourceCommand.Command = SourceCommandType.Add; config.SourceCommand.Name = source.Id; config.Sources = source.Value; config.SourceCommand.Username = source.UserName; @@ -560,7 +560,7 @@ public async Task DisableSource(string id) config => { config.CommandName = "source"; - config.SourceCommand.Command = SourceCommandType.disable; + config.SourceCommand.Command = SourceCommandType.Disable; config.SourceCommand.Name = id; }); @@ -573,7 +573,7 @@ public async Task EnableSource(string id) config => { config.CommandName = "source"; - config.SourceCommand.Command = SourceCommandType.enable; + config.SourceCommand.Command = SourceCommandType.Enable; config.SourceCommand.Name = id; }); @@ -611,7 +611,7 @@ public async Task RemoveSource(string id) config => { config.CommandName = "source"; - config.SourceCommand.Command = SourceCommandType.remove; + config.SourceCommand.Command = SourceCommandType.Remove; config.SourceCommand.Name = id; }); @@ -646,7 +646,7 @@ private static Package GetMappedPackage(GetChocolatey choco, PackageResult packa } var packageInfoService = choco.Container().GetInstance(); - var packageInfo = packageInfoService.get_package_information(package.PackageMetadata); + var packageInfo = packageInfoService.Get(package.PackageMetadata); mappedPackage.IsPinned = packageInfo.IsPinned; mappedPackage.IsInstalled = !string.IsNullOrWhiteSpace(package.InstallLocation) || forceInstalled; @@ -714,7 +714,7 @@ private async Task GetConfigFile() var xmlService = _choco.Container().GetInstance(); var config = await Task.Run( - () => xmlService.deserialize(chocolatey.infrastructure.app.ApplicationParameters.GlobalConfigFileLocation)); + () => xmlService.Deserialize(chocolatey.infrastructure.app.ApplicationParameters.GlobalConfigFileLocation)); return config; } } diff --git a/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs b/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs index b68efaf38..07dd6f994 100644 --- a/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs +++ b/Source/ChocolateyGui.Common.Windows/Services/PackageArgumentsService.cs @@ -40,17 +40,17 @@ public PackageArgumentsService( public IEnumerable DecryptPackageArgumentsFile(string id, string version) { - var argumentsPath = _fileSystem.combine_paths(_chocolateyConfigurationProvider.ChocolateyInstall, ".chocolatey", "{0}.{1}".format_with(id, version)); - var argumentsFile = _fileSystem.combine_paths(argumentsPath, ".arguments"); + var argumentsPath = _fileSystem.CombinePaths(_chocolateyConfigurationProvider.ChocolateyInstall, ".chocolatey", "{0}.{1}".FormatWith(id, version)); + var argumentsFile = _fileSystem.CombinePaths(argumentsPath, ".arguments"); string arguments = string.Empty; // Get the arguments decrypted in here and return them try { - if (_fileSystem.file_exists(argumentsFile)) + if (_fileSystem.FileExists(argumentsFile)) { - arguments = _fileSystem.read_file(argumentsFile); + arguments = _fileSystem.ReadFile(argumentsFile); } } catch (Exception ex) @@ -69,25 +69,25 @@ public IEnumerable DecryptPackageArgumentsFile(string id, string version // The following code is borrowed from the Chocolatey codebase, should // be extracted to a separate location in choco executable so we can re-use it. - var packageArgumentsUnencrypted = arguments.contains(" --") && arguments.to_string().Length > 4 + var packageArgumentsUnencrypted = arguments.Contains(" --") && arguments.ToStringSafe().Length > 4 ? arguments - : _encryptionUtility.decrypt_string(arguments); + : _encryptionUtility.DecryptString(arguments); // Lets do a global check first to see if there are any sensitive arguments // before we filter out the values used later. - var sensitiveArgs = ArgumentsUtility.arguments_contain_sensitive_information(packageArgumentsUnencrypted); + var sensitiveArgs = ArgumentsUtility.SensitiveArgumentsProvided(packageArgumentsUnencrypted); var packageArgumentsSplit = packageArgumentsUnencrypted.Split(new[] { " --" }, StringSplitOptions.RemoveEmptyEntries); - foreach (var packageArgument in packageArgumentsSplit.or_empty_list_if_null()) + foreach (var packageArgument in packageArgumentsSplit.OrEmpty()) { - var isSensitiveArgument = sensitiveArgs && ArgumentsUtility.arguments_contain_sensitive_information(string.Concat("--", packageArgument)); + var isSensitiveArgument = sensitiveArgs && ArgumentsUtility.SensitiveArgumentsProvided(string.Concat("--", packageArgument)); var packageArgumentSplit = packageArgument.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries); - var optionName = packageArgumentSplit[0].to_string(); + var optionName = packageArgumentSplit[0].ToStringSafe(); var optionValue = string.Empty; if (packageArgumentSplit.Length == 2 && isSensitiveArgument) @@ -96,14 +96,14 @@ public IEnumerable DecryptPackageArgumentsFile(string id, string version } else if (packageArgumentSplit.Length == 2) { - optionValue = packageArgumentSplit[1].to_string().remove_surrounding_quotes(); + optionValue = packageArgumentSplit[1].ToStringSafe().UnquoteSafe(); if (optionValue.StartsWith("'")) { - optionValue.remove_surrounding_quotes(); + optionValue.UnquoteSafe(); } } - yield return "--{0}{1}".format_with( + yield return "--{0}{1}".FormatWith( optionName, string.IsNullOrWhiteSpace(optionValue) ? string.Empty : "=" + optionValue); } diff --git a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs index e5bd4f42d..524a88e14 100644 --- a/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs +++ b/Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs @@ -440,7 +440,7 @@ private void OnSelectedVersionChanged(string stringVersion) private void BrowseLogFile(object value) { - var filter = "{0}|{1}|{2}".format_with( + var filter = "{0}|{1}|{2}".FormatWith( L(nameof(Resources.FilePicker_LogFiles)) + "|*.log;*.klg", L(nameof(Resources.FilePicker_TextFiles)) + "|*.txt;*.text;*.plain", L(nameof(Resources.FilePicker_AllFiles)) + "|*.*"); diff --git a/Source/ChocolateyGui.Common.Windows/Views/ShellView.xaml.cs b/Source/ChocolateyGui.Common.Windows/Views/ShellView.xaml.cs index 4f36bc87b..db73e89ba 100644 --- a/Source/ChocolateyGui.Common.Windows/Views/ShellView.xaml.cs +++ b/Source/ChocolateyGui.Common.Windows/Views/ShellView.xaml.cs @@ -65,7 +65,7 @@ public ShellView( // Certain things like Cef (our markdown browser engine) get unhappy when GUI is started from a different cwd. // If we're in a different one, reset it to our app files directory. - if (_fileSystem.get_directory_name(Environment.CurrentDirectory) != Bootstrapper.ApplicationFilesPath) + if (_fileSystem.GetDirectoryName(Environment.CurrentDirectory) != Bootstrapper.ApplicationFilesPath) { Environment.CurrentDirectory = Bootstrapper.ApplicationFilesPath; } diff --git a/Source/ChocolateyGui.Common/Commands/ConfigCommand.cs b/Source/ChocolateyGui.Common/Commands/ConfigCommand.cs index 4989381f1..8745f1a66 100644 --- a/Source/ChocolateyGui.Common/Commands/ConfigCommand.cs +++ b/Source/ChocolateyGui.Common/Commands/ConfigCommand.cs @@ -35,11 +35,11 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyGuiCo .Add( "name=", L(nameof(Resources.ConfigCommand_NameOption)), - option => configuration.ConfigCommand.Name = option.remove_surrounding_quotes()) + option => configuration.ConfigCommand.Name = option.UnquoteSafe()) .Add( "value=", L(nameof(Resources.ConfigCommand_ValueOption)), - option => configuration.ConfigCommand.ConfigValue = option.remove_surrounding_quotes()) + option => configuration.ConfigCommand.ConfigValue = option.UnquoteSafe()) .Add( "g|global", L(nameof(Resources.GlobalOption)), @@ -51,7 +51,7 @@ public virtual void HandleAdditionalArgumentParsing(IList unparsedArgume configuration.Input = string.Join(" ", unparsedArguments); var command = ConfigCommandType.Unknown; - var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault().to_string().Replace("-", string.Empty); + var unparsedCommand = unparsedArguments.DefaultIfEmpty(string.Empty).FirstOrDefault().ToStringSafe().Replace("-", string.Empty); Enum.TryParse(unparsedCommand, true, out command); if (command == ConfigCommandType.Unknown) { @@ -87,14 +87,14 @@ public virtual void HandleValidation(ChocolateyGuiConfiguration configuration) if (configuration.ConfigCommand.Command != ConfigCommandType.List && string.IsNullOrWhiteSpace(configuration.ConfigCommand.Name)) { - Logger.Error(L(nameof(Resources.ConfigCommand_MissingNameOptionError), configuration.ConfigCommand.Command.to_string(), "--name")); + Logger.Error(L(nameof(Resources.ConfigCommand_MissingNameOptionError), configuration.ConfigCommand.Command.ToStringSafe(), "--name")); Environment.Exit(-1); } if (configuration.ConfigCommand.Command == ConfigCommandType.Set && string.IsNullOrWhiteSpace(configuration.ConfigCommand.ConfigValue)) { - Logger.Error(L(nameof(Resources.ConfigCommand_MissingValueOptionError), configuration.ConfigCommand.Command.to_string(), "--value")); + Logger.Error(L(nameof(Resources.ConfigCommand_MissingValueOptionError), configuration.ConfigCommand.Command.ToStringSafe(), "--value")); Environment.Exit(-1); } } diff --git a/Source/ChocolateyGui.Common/Commands/FeatureCommand.cs b/Source/ChocolateyGui.Common/Commands/FeatureCommand.cs index de2f91dd7..2c78bfa0a 100644 --- a/Source/ChocolateyGui.Common/Commands/FeatureCommand.cs +++ b/Source/ChocolateyGui.Common/Commands/FeatureCommand.cs @@ -35,7 +35,7 @@ public virtual void ConfigureArgumentParser(OptionSet optionSet, ChocolateyGuiCo .Add( "n=|name=", L(nameof(Resources.FeatureCommand_NameOption)), - option => configuration.FeatureCommand.Name = option.remove_surrounding_quotes()) + option => configuration.FeatureCommand.Name = option.UnquoteSafe()) .Add( "g|global", L(nameof(Resources.GlobalOption)), @@ -72,7 +72,7 @@ public virtual void HandleValidation(ChocolateyGuiConfiguration configuration) { if (configuration.FeatureCommand.Command != FeatureCommandType.List && string.IsNullOrWhiteSpace(configuration.FeatureCommand.Name)) { - Logger.Error(L(nameof(Resources.FeatureCommand_MissingNameOptionError), configuration.FeatureCommand.Command.to_string(), "--name")); + Logger.Error(L(nameof(Resources.FeatureCommand_MissingNameOptionError), configuration.FeatureCommand.Command.ToStringSafe(), "--name")); Environment.Exit(-1); } } diff --git a/Source/ChocolateyGui.Common/Commands/GenericRunner.cs b/Source/ChocolateyGui.Common/Commands/GenericRunner.cs index eddcb26b1..9e424e9dc 100644 --- a/Source/ChocolateyGui.Common/Commands/GenericRunner.cs +++ b/Source/ChocolateyGui.Common/Commands/GenericRunner.cs @@ -33,7 +33,7 @@ public void Run(ChocolateyGuiConfiguration configuration, IContainer container, if (command != null) { - Logger.Debug("_ {0}:{1} - Normal Run Mode _".format_with("Chocolatey GUI", command.GetType().Name)); + Logger.Debug("_ {0}:{1} - Normal Run Mode _".FormatWith("Chocolatey GUI", command.GetType().Name)); command.Run(configuration); } } @@ -44,7 +44,7 @@ private ICommand FindCommand(ChocolateyGuiConfiguration configuration, IContaine var command = commands.Where((c) => { var attributes = c.GetType().GetCustomAttributes(typeof(LocalizedCommandForAttribute), false); - return attributes.Cast().Any(attribute => attribute.CommandName.is_equal_to(configuration.CommandName)); + return attributes.Cast().Any(attribute => attribute.CommandName.IsEqualTo(configuration.CommandName)); }).FirstOrDefault(); if (command == null) diff --git a/Source/ChocolateyGui.Common/Models/AppConfiguration.cs b/Source/ChocolateyGui.Common/Models/AppConfiguration.cs index 5a4619b12..1d1907a18 100644 --- a/Source/ChocolateyGui.Common/Models/AppConfiguration.cs +++ b/Source/ChocolateyGui.Common/Models/AppConfiguration.cs @@ -124,7 +124,7 @@ public override string ToString() HideThisPCSource: {18} PreventUsageOfUpdateAllButton: {19} SkipModalDialogConfirmation: {20} -".format_with( +".FormatWith( OutdatedPackagesCacheDurationInMinutes, DefaultSourceName, UseLanguage, diff --git a/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs b/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs index 3204f62e9..ea5cd36f0 100644 --- a/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs +++ b/Source/ChocolateyGui.Common/Providers/ChocolateyConfigurationProvider.cs @@ -50,9 +50,9 @@ private void GetChocolateyInstallLocation() private void DetermineIfChocolateyExecutableIsBeingUsed() { - var exePath = _fileSystem.combine_paths(ChocolateyInstall, "choco.exe"); + var exePath = _fileSystem.CombinePaths(ChocolateyInstall, "choco.exe"); - if (_fileSystem.file_exists(exePath)) + if (_fileSystem.FileExists(exePath)) { IsChocolateyExecutableBeingUsed = true; } diff --git a/Source/ChocolateyGui.Common/Services/ChocolateyGuiCacheService.cs b/Source/ChocolateyGui.Common/Services/ChocolateyGuiCacheService.cs index 2a447e9c1..0ab387fd0 100644 --- a/Source/ChocolateyGui.Common/Services/ChocolateyGuiCacheService.cs +++ b/Source/ChocolateyGui.Common/Services/ChocolateyGuiCacheService.cs @@ -22,7 +22,7 @@ public ChocolateyGuiCacheService(IFileStorageService fileStorageService, IFileSy _fileStorageService = fileStorageService; _fileSystem = fileSystem; - _localAppDataPath = _fileSystem.combine_paths(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "Chocolatey GUI"); + _localAppDataPath = _fileSystem.CombinePaths(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "Chocolatey GUI"); } public void PurgeIcons() @@ -32,17 +32,17 @@ public void PurgeIcons() public void PurgeOutdatedPackages() { - var outdatedPackagesFile = _fileSystem.combine_paths(_localAppDataPath, "outdatedPackages.xml"); - var outdatedPackagesBackupFile = _fileSystem.combine_paths(_localAppDataPath, "outdatedPackages.xml.backup"); + var outdatedPackagesFile = _fileSystem.CombinePaths(_localAppDataPath, "outdatedPackages.xml"); + var outdatedPackagesBackupFile = _fileSystem.CombinePaths(_localAppDataPath, "outdatedPackages.xml.backup"); - if (_fileSystem.file_exists(outdatedPackagesFile)) + if (_fileSystem.FileExists(outdatedPackagesFile)) { - _fileSystem.delete_file(outdatedPackagesFile); + _fileSystem.DeleteFile(outdatedPackagesFile); } - if (_fileSystem.file_exists(outdatedPackagesBackupFile)) + if (_fileSystem.FileExists(outdatedPackagesBackupFile)) { - _fileSystem.delete_file(outdatedPackagesBackupFile); + _fileSystem.DeleteFile(outdatedPackagesBackupFile); } } } diff --git a/Source/ChocolateyGui.Common/Services/ConfigService.cs b/Source/ChocolateyGui.Common/Services/ConfigService.cs index e4f8d7a46..8eca1249e 100644 --- a/Source/ChocolateyGui.Common/Services/ConfigService.cs +++ b/Source/ChocolateyGui.Common/Services/ConfigService.cs @@ -224,11 +224,11 @@ public void ListFeatures(ChocolateyGuiConfiguration configuration) { if (configuration.RegularOutput) { - Logger.Information("{0} {1} - {2}".format_with(feature.Enabled ? "[x]" : "[ ]", feature.Title, feature.Description)); + Logger.Information("{0} {1} - {2}".FormatWith(feature.Enabled ? "[x]" : "[ ]", feature.Title, feature.Description)); } else { - Logger.Information("{0}|{1}|{2}".format_with(feature.Title, L(!feature.Enabled ? nameof(Resources.FeatureCommand_Disabled) : nameof(Resources.FeatureCommand_Enabled)), feature.Description)); + Logger.Information("{0}|{1}|{2}".FormatWith(feature.Title, L(!feature.Enabled ? nameof(Resources.FeatureCommand_Disabled) : nameof(Resources.FeatureCommand_Enabled)), feature.Description)); } } } @@ -265,11 +265,11 @@ public void ListSettings(ChocolateyGuiConfiguration configuration) { if (configuration.RegularOutput) { - Logger.Information("{0} = {1} - {2}".format_with(setting.Key, setting.Value, setting.Description)); + Logger.Information("{0} = {1} - {2}".FormatWith(setting.Key, setting.Value, setting.Description)); } else { - Logger.Information("{0}|{1}|{2}".format_with(setting.Key, setting.Value, setting.Description)); + Logger.Information("{0}|{1}|{2}".FormatWith(setting.Key, setting.Value, setting.Description)); } } } @@ -313,7 +313,7 @@ public void GetConfigValue(ChocolateyGuiConfiguration configuration) var configProperty = GetProperty(configuration.ConfigCommand.Name, false); var configValue = (string)configProperty.GetValue(chosenAppConfiguration); - Logger.Information("{0}".format_with(configValue ?? string.Empty)); + Logger.Information("{0}".FormatWith(configValue ?? string.Empty)); } public void SetConfigValue(string key, string value) diff --git a/Source/ChocolateyGui.Common/Startup/AutoFacConfiguration.cs b/Source/ChocolateyGui.Common/Startup/AutoFacConfiguration.cs index 616061d0b..c76d701ca 100644 --- a/Source/ChocolateyGui.Common/Startup/AutoFacConfiguration.cs +++ b/Source/ChocolateyGui.Common/Startup/AutoFacConfiguration.cs @@ -25,12 +25,12 @@ public static IContainer RegisterAutoFac(string chocolateyGuiAssemblySimpleName, var builder = new ContainerBuilder(); builder.RegisterAssemblyModules(System.Reflection.Assembly.GetCallingAssembly()); - var license = License.validate_license(); + var license = License.ValidateLicense(); if (license.IsValid) { if (File.Exists(licensedGuiAssemblyLocation)) { - var licensedGuiAssembly = AssemblyResolution.resolve_or_load_assembly( + var licensedGuiAssembly = AssemblyResolution.ResolveOrLoadAssembly( chocolateyGuiAssemblySimpleName, publicKey, licensedGuiAssemblyLocation); @@ -39,7 +39,7 @@ public static IContainer RegisterAutoFac(string chocolateyGuiAssemblySimpleName, { license.AssemblyLoaded = true; license.Assembly = licensedGuiAssembly; - license.Version = VersionInformation.get_current_informational_version(licensedGuiAssembly); + license.Version = VersionInformation.GetCurrentInformationalVersion(licensedGuiAssembly); builder.RegisterAssemblyModules(licensedGuiAssembly.UnderlyingType); }