Compare commits

...

2 Commits

Author SHA1 Message Date
Théo Arrouye
d98da47a0f Better application grid flex (#5218) 2023-06-05 00:48:11 +00:00
Isaac Marovitz
306f7e93a0 Dont Error on Invalid Enum Values (#5169)
* Dont Error on Invalid Enum

* Use TryParse

* Log warning
2023-06-05 01:19:46 +02:00
2 changed files with 9 additions and 6 deletions

View File

@@ -32,10 +32,10 @@
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<flex:FlexPanel <flex:FlexPanel
HorizontalAlignment="Stretch" HorizontalAlignment="Center"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
AlignContent="FlexStart" AlignContent="FlexStart"
JustifyContent="Center" /> JustifyContent="FlexStart" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ListBox.ItemsPanel> </ListBox.ItemsPanel>
<ListBox.Styles> <ListBox.Styles>

View File

@@ -1,4 +1,5 @@
#nullable enable #nullable enable
using Ryujinx.Common.Logging;
using System; using System;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -18,12 +19,14 @@ namespace Ryujinx.Common.Utilities
public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{ {
var enumValue = reader.GetString(); var enumValue = reader.GetString();
if (string.IsNullOrEmpty(enumValue))
if (Enum.TryParse(enumValue, out TEnum value))
{ {
return default; return value;
} }
return Enum.Parse<TEnum>(enumValue); 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) public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options)