From 1183f26e03d702cd828cd58a82da5039265fbefe Mon Sep 17 00:00:00 2001 From: Andrii Lavrenko Date: Sun, 14 Jul 2024 16:01:46 +0300 Subject: [PATCH] SourceGeneration update --- BlumAutoBot/BlumBot.csproj | 3 ++- BlumAutoBot/Settings.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BlumAutoBot/BlumBot.csproj b/BlumAutoBot/BlumBot.csproj index be4d8b6..e0e9a85 100644 --- a/BlumAutoBot/BlumBot.csproj +++ b/BlumAutoBot/BlumBot.csproj @@ -6,13 +6,14 @@ enable enable BlumAutoBot - False + True BlumAutoBot Andrii Lavrenko Copyright (c) 2024 Andrii Lavrenko README.md https://github.com/SeRi0uS007/BlumAutoBot LICENSE + 1.0.1 diff --git a/BlumAutoBot/Settings.cs b/BlumAutoBot/Settings.cs index 3d680a4..572f1ac 100644 --- a/BlumAutoBot/Settings.cs +++ b/BlumAutoBot/Settings.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using System.Text.Json.Serialization; namespace BlumBot; @@ -31,7 +32,7 @@ public class Settings Settings? settings; try { - settings = JsonSerializer.Deserialize(file); + settings = JsonSerializer.Deserialize(file, SourceGenerationContext.Default.Settings); } catch (JsonException) { @@ -59,3 +60,9 @@ public static Settings[] ReadSettings() return Directory.GetFiles(settingsPath).Select(x => ReadSettings(x)).Where(x => x != null).ToArray()!; } } + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(Settings))] +internal partial class SourceGenerationContext: JsonSerializerContext +{ +}