From ea758248f4b5b11b4fe519dcb9ef9632b9c83f7f Mon Sep 17 00:00:00 2001 From: punker76 Date: Mon, 4 Nov 2024 21:27:14 +0100 Subject: [PATCH] use ReadOnlyDictionary --- .../IconPacks.Avalonia.BoxIcons.csproj | 2 ++ src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj | 2 ++ src/IconPacks.Avalonia.Core/PackIconDataFactory.cs | 5 ++++- src/IconPacks.Avalonia/IconPacks.Avalonia.csproj | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/IconPacks.Avalonia.BoxIcons/IconPacks.Avalonia.BoxIcons.csproj b/src/IconPacks.Avalonia.BoxIcons/IconPacks.Avalonia.BoxIcons.csproj index 21d98ed..f183c16 100644 --- a/src/IconPacks.Avalonia.BoxIcons/IconPacks.Avalonia.BoxIcons.csproj +++ b/src/IconPacks.Avalonia.BoxIcons/IconPacks.Avalonia.BoxIcons.csproj @@ -3,7 +3,9 @@ net8.0;net6.0;netstandard2.0 $(DefineConstants);AVALONIA + latest latest + true disable true diff --git a/src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj b/src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj index 7243f60..12c760a 100644 --- a/src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj +++ b/src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj @@ -3,7 +3,9 @@ net8.0;net6.0;netstandard2.0 $(DefineConstants);AVALONIA + latest latest + true disable true diff --git a/src/IconPacks.Avalonia.Core/PackIconDataFactory.cs b/src/IconPacks.Avalonia.Core/PackIconDataFactory.cs index bfdbf52..9eaf61b 100644 --- a/src/IconPacks.Avalonia.Core/PackIconDataFactory.cs +++ b/src/IconPacks.Avalonia.Core/PackIconDataFactory.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using Avalonia.Platform; namespace IconPacks.Avalonia @@ -16,7 +17,9 @@ static PackIconDataFactory() public static IDictionary Create() { using var iconJsonStream = AssetLoader.Open(new Uri($"avares://{typeof(TEnum).Assembly.GetName().Name}/Resources/Icons.json")); - return System.Text.Json.JsonSerializer.Deserialize>(iconJsonStream); +#pragma warning disable IL2026 + return new ReadOnlyDictionary(System.Text.Json.JsonSerializer.Deserialize>(iconJsonStream) ?? new Dictionary()); +#pragma warning restore IL2026 } } } \ No newline at end of file diff --git a/src/IconPacks.Avalonia/IconPacks.Avalonia.csproj b/src/IconPacks.Avalonia/IconPacks.Avalonia.csproj index fa01fe9..18764a2 100644 --- a/src/IconPacks.Avalonia/IconPacks.Avalonia.csproj +++ b/src/IconPacks.Avalonia/IconPacks.Avalonia.csproj @@ -3,7 +3,9 @@ net8.0;net6.0;netstandard2.0 $(DefineConstants);AVALONIA + latest latest + true disable true