0
0
mirror of https://github.com/sp-tarkov/assembly-tool.git synced 2025-02-12 15:10:44 -05:00

Fix AutoMatcher to work with System.Text

This commit is contained in:
Cj 2025-01-11 22:31:58 -05:00
parent ceb7bf8b39
commit 94f68148e1
4 changed files with 13 additions and 8 deletions

View File

@ -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;

View File

@ -123,6 +123,7 @@ public class AutoMatcher(List<RemapModel> mappings, string mappingPath)
if (remapModel.Succeeded)
{
ProcessEndQuestions(remapModel, assemblyPath);
return;
}
}
@ -402,7 +403,7 @@ public class AutoMatcher(List<RemapModel> 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);

View File

@ -41,7 +41,7 @@ public static class DataProvider
return remaps ?? [];
}
public static void UpdateMapping(string path, List<RemapModel> remaps, bool ignoreNull = true)
public static void UpdateMapping(string path, List<RemapModel> 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);

View File

@ -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);
}