feat: try to fix trimming compatibility.
This commit is contained in:
parent
09d23f8eaa
commit
724a528b16
@ -1,6 +1,6 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="SC-Single" type="DotNetFolderPublish" factoryName="Publish to folder">
|
||||
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="win-x64" self_contained="true" target_folder="$PROJECT_DIR$/demo/Semi.Avalonia.Demo.Desktop/bin/Release/net7.0/win-x64/publish" target_framework="net7.0" uuid_high="3088527218258560748" uuid_low="-8649338673481336678" />
|
||||
<riderPublish configuration="Release" include_native_libs_for_self_extract="true" platform="Any CPU" produce_single_file="true" runtime="win-x64" self_contained="true" target_folder="$PROJECT_DIR$/demo/Semi.Avalonia.Demo.Desktop/bin/Release/net8.0/win-x64/publish" target_framework="net8.0" uuid_high="3088527218258560748" uuid_low="-8649338673481336678" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -11,6 +11,11 @@
|
||||
-->
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||
<IsTrimmable>true</IsTrimmable>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
|
@ -1,5 +0,0 @@
|
||||
<linker>
|
||||
<!-- Can be removed if CompiledBinding and no reflection are used -->
|
||||
<assembly fullname="Semi.Avalonia.Demo" preserve="All" />
|
||||
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
|
||||
</linker>
|
@ -7,7 +7,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
<TrimmerRootDescriptor Include="Roots.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net8.0;netstandard2.0</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>11.1.0-rc2</Version>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.ColorPicker/Light.axaml" />
|
||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.ColorPicker/Dark.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.ColorPicker/Light.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.ColorPicker/Dark.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://Semi.Avalonia.ColorPicker/Controls/ColorPicker.axaml" />
|
||||
|
@ -7,6 +7,10 @@
|
||||
<PackageReleaseNotes>Update to Avalonia 11.1-rc1</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)"/>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.DataGrid/Light.axaml" />
|
||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.DataGrid/Dark.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia.DataGrid/Light.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia.DataGrid/Dark.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://Semi.Avalonia.DataGrid/DataGrid.axaml" />
|
||||
|
@ -7,6 +7,10 @@
|
||||
<PackageReleaseNotes>Update to Avalonia 11.1-rc1</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)"/>
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)"/>
|
||||
|
@ -14,6 +14,10 @@
|
||||
<AvaloniaVersion>11.0.0</AvaloniaVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Controls.TreeDataGrid" Version="$(AvaloniaVersion)"/>
|
||||
<None Include="irihi.png" Pack="true" PackagePath=""/>
|
||||
|
8
src/Semi.Avalonia/Locale/en-us.axaml.cs
Normal file
8
src/Semi.Avalonia/Locale/en-us.axaml.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Semi.Avalonia.Locale;
|
||||
|
||||
public class en_us: ResourceDictionary
|
||||
{
|
||||
|
||||
}
|
8
src/Semi.Avalonia/Locale/zh-cn.axaml.cs
Normal file
8
src/Semi.Avalonia/Locale/zh-cn.axaml.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Semi.Avalonia.Locale;
|
||||
|
||||
public class zh_cn: ResourceDictionary
|
||||
{
|
||||
|
||||
}
|
@ -5,6 +5,9 @@
|
||||
<PropertyGroup>
|
||||
<Title>Semi.Avalonia</Title>
|
||||
<PackageReleaseNotes>Update to Avalonia 11.1-rc1</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
|
||||
<IsAotCompatible>true</IsAotCompatible>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
||||
|
@ -2,8 +2,8 @@
|
||||
<Styles.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<MergeResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||
<MergeResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||
<ResourceInclude x:Key="Default" Source="avares://Semi.Avalonia/Themes/Light/_index.axaml" />
|
||||
<ResourceInclude x:Key="Dark" Source="avares://Semi.Avalonia/Themes/Dark/_index.axaml" />
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="avares://Semi.Avalonia/Controls/_index.axaml" />
|
||||
|
@ -4,15 +4,16 @@ using System.Globalization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Styling;
|
||||
using Semi.Avalonia.Locale;
|
||||
|
||||
namespace Semi.Avalonia;
|
||||
|
||||
public class SemiTheme: Styles
|
||||
{
|
||||
private static readonly Dictionary<CultureInfo, string> _localeToResource = new()
|
||||
private static readonly Dictionary<CultureInfo, ResourceDictionary> _localeToResource = new()
|
||||
{
|
||||
{ new CultureInfo("zh-cn"), "avares://Semi.Avalonia/Locale/zh-cn.axaml" },
|
||||
{ new CultureInfo("en-us"), "avares://Semi.Avalonia/Locale/en-us.axaml" },
|
||||
{ new CultureInfo("zh-cn"), new zh_cn() },
|
||||
{ new CultureInfo("en-us"), new en_us() },
|
||||
};
|
||||
|
||||
private readonly IServiceProvider? sp;
|
||||
@ -30,22 +31,20 @@ public class SemiTheme: Styles
|
||||
{
|
||||
_locale = value;
|
||||
var resource = TryGetLocaleResource(value);
|
||||
var d = AvaloniaXamlLoader.Load(sp, new Uri(resource)) as ResourceDictionary;
|
||||
if (d is null) return;
|
||||
foreach (var kv in d)
|
||||
if(resource is null) return;
|
||||
foreach (var kv in resource)
|
||||
{
|
||||
this.Resources.Add(kv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string TryGetLocaleResource(CultureInfo? locale)
|
||||
private static ResourceDictionary? TryGetLocaleResource(CultureInfo? locale)
|
||||
{
|
||||
if (locale is null)
|
||||
{
|
||||
return _localeToResource[new CultureInfo("zh-cn")];
|
||||
}
|
||||
|
||||
if (_localeToResource.TryGetValue(locale, out var resource))
|
||||
{
|
||||
return resource;
|
||||
|
Loading…
x
Reference in New Issue
Block a user