Skip to content

Commit

Permalink
use ReadOnlyDictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Nov 4, 2024
1 parent 91ab449 commit ea75824
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);AVALONIA</DefineConstants>
<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<Nullable>disable</Nullable>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);AVALONIA</DefineConstants>
<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<Nullable>disable</Nullable>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
</PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion src/IconPacks.Avalonia.Core/PackIconDataFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Avalonia.Platform;

namespace IconPacks.Avalonia
Expand All @@ -16,7 +17,9 @@ static PackIconDataFactory()
public static IDictionary<TEnum, string> Create()
{
using var iconJsonStream = AssetLoader.Open(new Uri($"avares://{typeof(TEnum).Assembly.GetName().Name}/Resources/Icons.json"));
return System.Text.Json.JsonSerializer.Deserialize<Dictionary<TEnum, string>>(iconJsonStream);
#pragma warning disable IL2026
return new ReadOnlyDictionary<TEnum, string>(System.Text.Json.JsonSerializer.Deserialize<Dictionary<TEnum, string>>(iconJsonStream) ?? new Dictionary<TEnum, string>());
#pragma warning restore IL2026
}
}
}
2 changes: 2 additions & 0 deletions src/IconPacks.Avalonia/IconPacks.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);AVALONIA</DefineConstants>
<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<Nullable>disable</Nullable>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
</PropertyGroup>
Expand Down

0 comments on commit ea75824

Please sign in to comment.