mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-01-12 01:50:18 +00:00
Removed TypedStringEnumConverter; it exists in .NET now.
As per the remark XMLdoc on the type: Get rid of this converter if dotnet supports similar functionality out of the box.
This commit is contained in:
parent
1e1bcb4a5b
commit
a96f20dca5
23 changed files with 23 additions and 82 deletions
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<AntiAliasing>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<AntiAliasing>))]
|
||||||
public enum AntiAliasing
|
public enum AntiAliasing
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<AspectRatio>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<AspectRatio>))]
|
||||||
public enum AspectRatio
|
public enum AspectRatio
|
||||||
{
|
{
|
||||||
Fixed4x3,
|
Fixed4x3,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<BackendThreading>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<BackendThreading>))]
|
||||||
public enum BackendThreading
|
public enum BackendThreading
|
||||||
{
|
{
|
||||||
Auto,
|
Auto,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<GraphicsBackend>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<GraphicsBackend>))]
|
||||||
public enum GraphicsBackend
|
public enum GraphicsBackend
|
||||||
{
|
{
|
||||||
Vulkan,
|
Vulkan,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<GraphicsDebugLevel>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<GraphicsDebugLevel>))]
|
||||||
public enum GraphicsDebugLevel
|
public enum GraphicsDebugLevel
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid.Controller
|
namespace Ryujinx.Common.Configuration.Hid.Controller
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<GamepadInputId>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<GamepadInputId>))]
|
||||||
public enum GamepadInputId : byte
|
public enum GamepadInputId : byte
|
||||||
{
|
{
|
||||||
Unbound,
|
Unbound,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
|
namespace Ryujinx.Common.Configuration.Hid.Controller.Motion
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<MotionInputBackendType>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<MotionInputBackendType>))]
|
||||||
public enum MotionInputBackendType : byte
|
public enum MotionInputBackendType : byte
|
||||||
{
|
{
|
||||||
Invalid,
|
Invalid,
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid.Controller
|
namespace Ryujinx.Common.Configuration.Hid.Controller
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<StickInputId>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<StickInputId>))]
|
||||||
public enum StickInputId : byte
|
public enum StickInputId : byte
|
||||||
{
|
{
|
||||||
Unbound,
|
Unbound,
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
|
|
||||||
Count,
|
Count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
|
@ -6,7 +5,7 @@ namespace Ryujinx.Common.Configuration.Hid
|
||||||
{
|
{
|
||||||
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
||||||
[Flags]
|
[Flags]
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<ControllerType>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<ControllerType>))]
|
||||||
public enum ControllerType
|
public enum ControllerType
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid
|
namespace Ryujinx.Common.Configuration.Hid
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<InputBackendType>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<InputBackendType>))]
|
||||||
public enum InputBackendType
|
public enum InputBackendType
|
||||||
{
|
{
|
||||||
Invalid,
|
Invalid,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid
|
namespace Ryujinx.Common.Configuration.Hid
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<Key>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<Key>))]
|
||||||
public enum Key
|
public enum Key
|
||||||
{
|
{
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration.Hid
|
namespace Ryujinx.Common.Configuration.Hid
|
||||||
{
|
{
|
||||||
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
// This enum was duplicated from Ryujinx.HLE.HOS.Services.Hid.PlayerIndex and should be kept identical
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<PlayerIndex>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<PlayerIndex>))]
|
||||||
public enum PlayerIndex
|
public enum PlayerIndex
|
||||||
{
|
{
|
||||||
Player1 = 0,
|
Player1 = 0,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<MemoryManagerMode>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<MemoryManagerMode>))]
|
||||||
public enum MemoryManagerMode : byte
|
public enum MemoryManagerMode : byte
|
||||||
{
|
{
|
||||||
SoftwarePageTable,
|
SoftwarePageTable,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Configuration
|
namespace Ryujinx.Common.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<ScalingFilter>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<ScalingFilter>))]
|
||||||
public enum ScalingFilter
|
public enum ScalingFilter
|
||||||
{
|
{
|
||||||
Bilinear,
|
Bilinear,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Logging
|
namespace Ryujinx.Common.Logging
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<LogClass>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<LogClass>))]
|
||||||
public enum LogClass
|
public enum LogClass
|
||||||
{
|
{
|
||||||
Application,
|
Application,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Logging
|
namespace Ryujinx.Common.Logging
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<LogLevel>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<LogLevel>))]
|
||||||
public enum LogLevel
|
public enum LogLevel
|
||||||
{
|
{
|
||||||
Debug,
|
Debug,
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#nullable enable
|
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace Ryujinx.Common.Utilities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Specifies that value of <see cref="TEnum"/> will be serialized as string in JSONs
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Trimming friendly alternative to <see cref="JsonStringEnumConverter"/>.
|
|
||||||
/// Get rid of this converter if dotnet supports similar functionality out of the box.
|
|
||||||
/// </remarks>
|
|
||||||
/// <typeparam name="TEnum">Type of enum to serialize</typeparam>
|
|
||||||
public sealed class TypedStringEnumConverter<TEnum> : JsonConverter<TEnum> where TEnum : struct, Enum
|
|
||||||
{
|
|
||||||
public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
string? enumValue = reader.GetString();
|
|
||||||
|
|
||||||
if (Enum.TryParse(enumValue, out TEnum value))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Configuration, $"Failed to parse enum value \"{enumValue}\" for {typeof(TEnum)}, using default \"{default(TEnum)}\"");
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
writer.WriteStringValue(value.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<AccountState>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<AccountState>))]
|
||||||
public enum AccountState
|
public enum AccountState
|
||||||
{
|
{
|
||||||
Closed,
|
Closed,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.Configuration
|
namespace Ryujinx.Ava.Systems.Configuration
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<AudioBackend>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<AudioBackend>))]
|
||||||
public enum AudioBackend
|
public enum AudioBackend
|
||||||
{
|
{
|
||||||
Dummy,
|
Dummy,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.Configuration.System
|
namespace Ryujinx.Ava.Systems.Configuration.System
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<Language>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<Language>))]
|
||||||
public enum Language
|
public enum Language
|
||||||
{
|
{
|
||||||
Japanese,
|
Japanese,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using Ryujinx.HLE.HOS.SystemState;
|
using Ryujinx.HLE.HOS.SystemState;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.Configuration.System
|
namespace Ryujinx.Ava.Systems.Configuration.System
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<Region>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<Region>))]
|
||||||
public enum Region
|
public enum Region
|
||||||
{
|
{
|
||||||
Japan,
|
Japan,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.Configuration.UI
|
namespace Ryujinx.Ava.Systems.Configuration.UI
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<FocusLostType>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<FocusLostType>))]
|
||||||
public enum FocusLostType
|
public enum FocusLostType
|
||||||
{
|
{
|
||||||
DoNothing,
|
DoNothing,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using Ryujinx.Common.Utilities;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Systems.Configuration.UI
|
namespace Ryujinx.Ava.Systems.Configuration.UI
|
||||||
{
|
{
|
||||||
[JsonConverter(typeof(TypedStringEnumConverter<UpdaterType>))]
|
[JsonConverter(typeof(JsonStringEnumConverter<UpdaterType>))]
|
||||||
public enum UpdaterType
|
public enum UpdaterType
|
||||||
{
|
{
|
||||||
Off,
|
Off,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue