diff --git a/ReCodeItCLI/Commands/AutoMatcher.cs b/ReCodeItCLI/Commands/AutoMatcher.cs index cb979b6..bf30724 100644 --- a/ReCodeItCLI/Commands/AutoMatcher.cs +++ b/ReCodeItCLI/Commands/AutoMatcher.cs @@ -1,5 +1,5 @@ // Uncomment this to have the application wait for a debugger to attach before running. -#define WAIT_FOR_DEBUGGER +//#define WAIT_FOR_DEBUGGER using System.Diagnostics; using CliFx; diff --git a/RecodeItLib/Remapper/AutoMatcher.cs b/RecodeItLib/Remapper/AutoMatcher.cs index 567558f..dd725ce 100644 --- a/RecodeItLib/Remapper/AutoMatcher.cs +++ b/RecodeItLib/Remapper/AutoMatcher.cs @@ -123,6 +123,7 @@ public class AutoMatcher(List mappings, string mappingPath) if (remapModel.Succeeded) { ProcessEndQuestions(remapModel, assemblyPath); + return; } } @@ -402,7 +403,7 @@ public class AutoMatcher(List mappings, string mappingPath) } mappings.Add(remapModel); - DataProvider.UpdateMapping(mappingPath, mappings); + DataProvider.UpdateMapping(mappingPath, mappings, false); } Logger.LogSync("Would you like to run the remap process?... (y/n)", ConsoleColor.Yellow); diff --git a/RecodeItLib/Utils/DataProvider.cs b/RecodeItLib/Utils/DataProvider.cs index 8bcbd86..67adcce 100644 --- a/RecodeItLib/Utils/DataProvider.cs +++ b/RecodeItLib/Utils/DataProvider.cs @@ -41,7 +41,7 @@ public static class DataProvider return remaps ?? []; } - public static void UpdateMapping(string path, List remaps, bool ignoreNull = true) + public static void UpdateMapping(string path, List remaps, bool respectNullableAnnotations = true) { if (!File.Exists(path)) { @@ -51,7 +51,9 @@ public static class DataProvider JsonSerializerOptions settings = new() { WriteIndented = true, - RespectNullableAnnotations = ignoreNull, + RespectNullableAnnotations = !respectNullableAnnotations, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, }; var jsonText = JsonSerializer.Serialize(remaps, settings); diff --git a/RecodeItLib/Utils/Logger.cs b/RecodeItLib/Utils/Logger.cs index 6fd4764..015d463 100644 --- a/RecodeItLib/Utils/Logger.cs +++ b/RecodeItLib/Utils/Logger.cs @@ -1,5 +1,6 @@ using System.Collections.Concurrent; -using Newtonsoft.Json; +using System.Text.Json; +using System.Text.Json.Serialization; using ReCodeItLib.Models; namespace ReCodeItLib.Utils; @@ -123,12 +124,13 @@ public static class Logger public static void LogRemapModel(RemapModel remapModel) { - var settings = new JsonSerializerSettings() + JsonSerializerOptions settings = new() { - NullValueHandling = NullValueHandling.Ignore + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, }; - var str = JsonConvert.SerializeObject(remapModel, Formatting.Indented, settings); + var str = JsonSerializer.Serialize(remapModel, settings); LogSync(str, ConsoleColor.Blue); }