From ba95ee54abf4905d38f3563881a1643f102993b3 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 21 Mar 2023 20:14:46 -0300 Subject: Revert "Use source generated json serializers in order to improve code trimming (#4094)" (#4576) This reverts commit 4ce4299ca2a6b11332f2341c69f40efd7205282f. --- Ryujinx.Ui.Common/Configuration/AudioBackend.cs | 6 +----- Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs | 12 ++++++------ .../Configuration/ConfigurationFileFormatSettings.cs | 9 --------- .../Configuration/ConfigurationJsonSerializerContext.cs | 10 ---------- Ryujinx.Ui.Common/Configuration/ConfigurationState.cs | 5 ++--- Ryujinx.Ui.Common/Configuration/System/Language.cs | 6 +----- Ryujinx.Ui.Common/Configuration/System/Region.cs | 6 +----- 7 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 Ryujinx.Ui.Common/Configuration/ConfigurationFileFormatSettings.cs delete mode 100644 Ryujinx.Ui.Common/Configuration/ConfigurationJsonSerializerContext.cs (limited to 'Ryujinx.Ui.Common/Configuration') diff --git a/Ryujinx.Ui.Common/Configuration/AudioBackend.cs b/Ryujinx.Ui.Common/Configuration/AudioBackend.cs index 1f9bd0ba..99111ea6 100644 --- a/Ryujinx.Ui.Common/Configuration/AudioBackend.cs +++ b/Ryujinx.Ui.Common/Configuration/AudioBackend.cs @@ -1,9 +1,5 @@ -using Ryujinx.Common.Utilities; -using System.Text.Json.Serialization; - -namespace Ryujinx.Ui.Common.Configuration +namespace Ryujinx.Ui.Common.Configuration { - [JsonConverter(typeof(TypedStringEnumConverter))] public enum AudioBackend { Dummy, diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs index 14c03957..e9aec04b 100644 --- a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs +++ b/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormat.cs @@ -5,7 +5,7 @@ using Ryujinx.Common.Utilities; using Ryujinx.Ui.Common.Configuration.System; using Ryujinx.Ui.Common.Configuration.Ui; using System.Collections.Generic; -using System.Text.Json.Nodes; +using System.IO; namespace Ryujinx.Ui.Common.Configuration { @@ -321,14 +321,14 @@ namespace Ryujinx.Ui.Common.Configuration /// /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions) /// TODO: Remove this when those older versions aren't in use anymore. - public List KeyboardConfig { get; set; } + public List KeyboardConfig { get; set; } /// /// Legacy controller control bindings /// /// Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions) /// TODO: Remove this when those older versions aren't in use anymore. - public List ControllerConfig { get; set; } + public List ControllerConfig { get; set; } /// /// Input configurations @@ -354,12 +354,11 @@ namespace Ryujinx.Ui.Common.Configuration /// Loads a configuration file from disk /// /// The path to the JSON configuration file - /// Parsed configuration file public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat) { try { - configurationFileFormat = JsonHelper.DeserializeFromFile(path, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); + configurationFileFormat = JsonHelper.DeserializeFromFile(path); return configurationFileFormat.Version != 0; } @@ -377,7 +376,8 @@ namespace Ryujinx.Ui.Common.Configuration /// The path to the JSON configuration file public void SaveConfig(string path) { - JsonHelper.SerializeToFile(path, this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); + using FileStream fileStream = File.Create(path, 4096, FileOptions.WriteThrough); + JsonHelper.Serialize(fileStream, this, true); } } } diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormatSettings.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormatSettings.cs deleted file mode 100644 index 6ce2ef01..00000000 --- a/Ryujinx.Ui.Common/Configuration/ConfigurationFileFormatSettings.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Ryujinx.Common.Utilities; - -namespace Ryujinx.Ui.Common.Configuration -{ - internal static class ConfigurationFileFormatSettings - { - public static readonly ConfigurationJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions()); - } -} \ No newline at end of file diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationJsonSerializerContext.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationJsonSerializerContext.cs deleted file mode 100644 index bb8dfb49..00000000 --- a/Ryujinx.Ui.Common/Configuration/ConfigurationJsonSerializerContext.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Ryujinx.Ui.Common.Configuration -{ - [JsonSourceGenerationOptions(WriteIndented = true)] - [JsonSerializable(typeof(ConfigurationFileFormat))] - internal partial class ConfigurationJsonSerializerContext : JsonSerializerContext - { - } -} \ No newline at end of file diff --git a/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs b/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs index 82a331c1..bcdd2e70 100644 --- a/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs +++ b/Ryujinx.Ui.Common/Configuration/ConfigurationState.cs @@ -9,7 +9,6 @@ using Ryujinx.Ui.Common.Configuration.Ui; using Ryujinx.Ui.Common.Helper; using System; using System.Collections.Generic; -using System.Text.Json.Nodes; namespace Ryujinx.Ui.Common.Configuration { @@ -632,8 +631,8 @@ namespace Ryujinx.Ui.Common.Configuration EnableKeyboard = Hid.EnableKeyboard, EnableMouse = Hid.EnableMouse, Hotkeys = Hid.Hotkeys, - KeyboardConfig = new List(), - ControllerConfig = new List(), + KeyboardConfig = new List(), + ControllerConfig = new List(), InputConfig = Hid.InputConfig, GraphicsBackend = Graphics.GraphicsBackend, PreferredGpu = Graphics.PreferredGpu diff --git a/Ryujinx.Ui.Common/Configuration/System/Language.cs b/Ryujinx.Ui.Common/Configuration/System/Language.cs index 404f8063..3d2dc991 100644 --- a/Ryujinx.Ui.Common/Configuration/System/Language.cs +++ b/Ryujinx.Ui.Common/Configuration/System/Language.cs @@ -1,9 +1,5 @@ -using Ryujinx.Common.Utilities; -using System.Text.Json.Serialization; - -namespace Ryujinx.Ui.Common.Configuration.System +namespace Ryujinx.Ui.Common.Configuration.System { - [JsonConverter(typeof(TypedStringEnumConverter))] public enum Language { Japanese, diff --git a/Ryujinx.Ui.Common/Configuration/System/Region.cs b/Ryujinx.Ui.Common/Configuration/System/Region.cs index 7dfac638..fb51e08e 100644 --- a/Ryujinx.Ui.Common/Configuration/System/Region.cs +++ b/Ryujinx.Ui.Common/Configuration/System/Region.cs @@ -1,9 +1,5 @@ -using Ryujinx.Common.Utilities; -using System.Text.Json.Serialization; - -namespace Ryujinx.Ui.Common.Configuration.System +namespace Ryujinx.Ui.Common.Configuration.System { - [JsonConverter(typeof(TypedStringEnumConverter))] public enum Region { Japan, -- cgit v1.2.3