diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-03-21 20:14:46 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-21 20:14:46 -0300 |
| commit | ba95ee54abf4905d38f3563881a1643f102993b3 (patch) | |
| tree | 4a17ec5f209e64e4944b7deceec5dbdf1e0d9dc3 /Ryujinx.Common/Utilities/TypedStringEnumConverter.cs | |
| parent | 4ce4299ca2a6b11332f2341c69f40efd7205282f (diff) | |
Revert "Use source generated json serializers in order to improve code trimming (#4094)" (#4576)
This reverts commit 4ce4299ca2a6b11332f2341c69f40efd7205282f.
Diffstat (limited to 'Ryujinx.Common/Utilities/TypedStringEnumConverter.cs')
| -rw-r--r-- | Ryujinx.Common/Utilities/TypedStringEnumConverter.cs | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/Ryujinx.Common/Utilities/TypedStringEnumConverter.cs b/Ryujinx.Common/Utilities/TypedStringEnumConverter.cs deleted file mode 100644 index c0127dc4..00000000 --- a/Ryujinx.Common/Utilities/TypedStringEnumConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -#nullable enable -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) - { - var enumValue = reader.GetString(); - if (string.IsNullOrEmpty(enumValue)) - { - return default; - } - - return Enum.Parse<TEnum>(enumValue); - } - - public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString()); - } - } -} |
