Skip to content

Commit

Permalink
SourceGeneration update
Browse files Browse the repository at this point in the history
  • Loading branch information
SeRi0uS007 committed Jul 14, 2024
1 parent 64e8a6c commit 1183f26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion BlumAutoBot/BlumBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>BlumAutoBot</AssemblyName>
<PublishTrimmed>False</PublishTrimmed>
<PublishTrimmed>True</PublishTrimmed>
<Title>BlumAutoBot</Title>
<Authors>Andrii Lavrenko</Authors>
<Copyright>Copyright (c) 2024 Andrii Lavrenko</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/SeRi0uS007/BlumAutoBot</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>1.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion BlumAutoBot/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace BlumBot;

Expand Down Expand Up @@ -31,7 +32,7 @@ public class Settings
Settings? settings;
try
{
settings = JsonSerializer.Deserialize<Settings>(file);
settings = JsonSerializer.Deserialize(file, SourceGenerationContext.Default.Settings);
}
catch (JsonException)
{
Expand Down Expand Up @@ -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
{
}

0 comments on commit 1183f26

Please sign in to comment.