From 886e42fb19b5d69a6a256e20bd1b948124f790a3 Mon Sep 17 00:00:00 2001 From: Thog Date: Thu, 30 Apr 2020 14:07:41 +0200 Subject: Use the official JSON parser (#1151) This remove Utf8son and JsonPrettyPrinter dependencies. NOTE: the standard JSON parser doesn't support configurable indentation, as a result, all the pretty printed JSON are indented with 2 spaces. --- Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs | 43 +--------------------- 1 file changed, 2 insertions(+), 41 deletions(-) (limited to 'Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs') diff --git a/Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs b/Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs index e0842f2e..73ef8f55 100644 --- a/Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs +++ b/Ryujinx.Debugger/Profiler/ProfilerConfiguration.cs @@ -1,8 +1,5 @@ -using Gdk; -using System; +using Ryujinx.Common.Utilities; using System.IO; -using Utf8Json; -using Utf8Json.Resolvers; namespace Ryujinx.Debugger.Profiler { @@ -21,48 +18,12 @@ namespace Ryujinx.Debugger.Profiler /// The path to the JSON configuration file public static ProfilerConfiguration Load(string path) { - var resolver = CompositeResolver.Create( - new[] { new ConfigurationEnumFormatter() }, - new[] { StandardResolver.AllowPrivateSnakeCase } - ); - if (!File.Exists(path)) { throw new FileNotFoundException($"Profiler configuration file {path} not found"); } - using (Stream stream = File.OpenRead(path)) - { - return JsonSerializer.Deserialize(stream, resolver); - } - } - - private class ConfigurationEnumFormatter : IJsonFormatter - where T : struct - { - public void Serialize(ref JsonWriter writer, T value, IJsonFormatterResolver formatterResolver) - { - formatterResolver.GetFormatterWithVerify() - .Serialize(ref writer, value.ToString(), formatterResolver); - } - - public T Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) - { - if (reader.ReadIsNull()) - { - return default(T); - } - - string enumName = formatterResolver.GetFormatterWithVerify() - .Deserialize(ref reader, formatterResolver); - - if (Enum.TryParse(enumName, out T result)) - { - return result; - } - - return default(T); - } + return JsonHelper.DeserializeFromFile(path); } } } -- cgit v1.2.3