Skip to content

Commit 5af58b3

Browse files
committed
Fix IL errors
1 parent c5b265c commit 5af58b3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Plugins/Flow.Launcher.Plugin.WindowsSettings/Helper/JsonSettingsListHelper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,10 @@ internal static IEnumerable<WindowsSetting> ReadAllPossibleSettings()
3939
throw new Exception("stream is null");
4040
}
4141

42-
var options = new JsonSerializerOptions();
43-
options.Converters.Add(new JsonStringEnumConverter());
44-
4542
using var reader = new StreamReader(stream);
4643
var text = reader.ReadToEnd();
4744

48-
settingsList = JsonSerializer.Deserialize<IEnumerable<WindowsSetting>>(text, options);
45+
settingsList = JsonSerializer.Deserialize(text, MyJsonContext.Default.IEnumerableWindowsSetting);
4946
}
5047
catch (Exception exception)
5148
{
@@ -55,4 +52,13 @@ internal static IEnumerable<WindowsSetting> ReadAllPossibleSettings()
5552
return settingsList ?? Enumerable.Empty<WindowsSetting>();
5653
}
5754
}
55+
56+
[JsonSourceGenerationOptions(
57+
Converters = new[] { typeof(JsonStringEnumConverter) },
58+
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase
59+
)]
60+
[JsonSerializable(typeof(IEnumerable<WindowsSetting>))]
61+
internal partial class MyJsonContext : JsonSerializerContext
62+
{
63+
}
5864
}

0 commit comments

Comments
 (0)