From ca898c46894d115fcde717e73fe7f52a0fb1ed6c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 30 Apr 2025 08:55:37 -0400 Subject: [PATCH] Always write full configuration file (fixes #839) --- CHANGELIST.md | 1 + MPF.CLI/Program.cs | 2 +- MPF.Frontend/Tools/OptionsLoader.cs | 29 +++++++++++++---------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index 5ce07d50..6422cb68 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -4,6 +4,7 @@ - Update redumper to build 549 - Allow max speed dumping ("0") - Normalize file path in CLI +- Always write full configuration file ### 3.3.0 (2025-01-03) diff --git a/MPF.CLI/Program.cs b/MPF.CLI/Program.cs index 82d943fd..7544ec0c 100644 --- a/MPF.CLI/Program.cs +++ b/MPF.CLI/Program.cs @@ -26,7 +26,7 @@ namespace MPF.CLI // Reset first run options.FirstRun = false; - OptionsLoader.SaveToConfig(options, saveDefault: true); + OptionsLoader.SaveToConfig(options); } // Try processing the standalone arguments diff --git a/MPF.Frontend/Tools/OptionsLoader.cs b/MPF.Frontend/Tools/OptionsLoader.cs index 8dc6b1c1..116d92ef 100644 --- a/MPF.Frontend/Tools/OptionsLoader.cs +++ b/MPF.Frontend/Tools/OptionsLoader.cs @@ -315,29 +315,26 @@ namespace MPF.Frontend.Tools /// /// Save the current set of options to the application configuration /// - public static void SaveToConfig(Options options, bool saveDefault = false) + public static void SaveToConfig(Options options) { // If no options path can be found if (string.IsNullOrEmpty(ConfigurationPath)) return; - // If default values should be saved as well - if (saveDefault) + // Ensure default values are included + PropertyInfo[] properties = typeof(Options).GetProperties(); + foreach (var property in properties) { - PropertyInfo[] properties = typeof(Options).GetProperties(); - foreach (var property in properties) - { - // Skip dictionary properties - if (property.Name == "Item") - continue; + // Skip dictionary properties + if (property.Name == "Item") + continue; - // Skip non-option properties - if (property.Name == "Settings" || property.Name == "HasRedumpLogin") - continue; + // Skip non-option properties + if (property.Name == "Settings" || property.Name == "HasRedumpLogin") + continue; - var val = property.GetValue(options, null); - property.SetValue(options, val, null); - } + var val = property.GetValue(options, null); + property.SetValue(options, val, null); } // Handle a very strange edge case @@ -368,7 +365,7 @@ namespace MPF.Frontend.Tools // Local folder #if NET20 || NET35 || NET40 || NET452 - string runtimeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string runtimeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); #else string runtimeDir = AppContext.BaseDirectory; #endif