Skip to content

Commit e37426d

Browse files
authored
AOT compatibility for winui3 package (#554)
1 parent 0443b1e commit e37426d

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

Lottie-Windows/Lottie-Windows-WinUI3/Lottie-Windows-WinUI3.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net7.0-windows10.0.18362.0</TargetFramework>
5+
<IsAotCompatible>true</IsAotCompatible>
56
<OutputType>Library</OutputType>
67

78
<PackageId>CommunityToolkit.WinUI.Lottie</PackageId>

source/UIData/Tools/Properties.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,38 @@ namespace CommunityToolkit.WinUI.Lottie.UIData.Tools
1313
{
1414
static class Properties
1515
{
16-
static IReadOnlyDictionary<string, PropertyId>? s_propertyIdFromNameMap;
16+
static IReadOnlyDictionary<string, PropertyId> s_propertyIdFromNameMap = new Dictionary<string, PropertyId>
17+
{
18+
{ "BorderMode", PropertyId.BorderMode},
19+
{ "CenterPoint", PropertyId.CenterPoint},
20+
{ "Children", PropertyId.Children},
21+
{ "Clip", PropertyId.Clip},
22+
{ "Color", PropertyId.Color},
23+
{ "Comment", PropertyId.Comment},
24+
{ "IsVisible", PropertyId.IsVisible},
25+
{ "Offset", PropertyId.Offset},
26+
{ "Opacity", PropertyId.Opacity},
27+
{ "Path", PropertyId.Path},
28+
{ "Position", PropertyId.Position},
29+
{ "Progress", PropertyId.Progress},
30+
{ "Properties", PropertyId.Properties},
31+
{ "RotationAngleInDegrees", PropertyId.RotationAngleInDegrees},
32+
{ "RotationAxis", PropertyId.RotationAxis},
33+
{ "Scale", PropertyId.Scale},
34+
{ "Size", PropertyId.Size},
35+
{ "StrokeEndCap", PropertyId.StrokeEndCap},
36+
{ "StrokeDashCap", PropertyId.StrokeDashCap},
37+
{ "StrokeLineJoin", PropertyId.StrokeLineJoin},
38+
{ "StrokeMiterLimit", PropertyId.StrokeMiterLimit},
39+
{ "StrokeStartCap", PropertyId.StrokeStartCap},
40+
{ "TransformMatrix", PropertyId.TransformMatrix},
41+
{ "TrimEnd", PropertyId.TrimEnd},
42+
{ "TrimOffset", PropertyId.TrimOffset},
43+
{ "TrimStart", PropertyId.TrimStart},
44+
};
1745

1846
internal static PropertyId PropertyIdFromName(string value)
1947
{
20-
if (s_propertyIdFromNameMap is null)
21-
{
22-
s_propertyIdFromNameMap =
23-
Enum.GetValues(typeof(PropertyId)).Cast<PropertyId>()
24-
.Where(p => p != PropertyId.None)
25-
.ToDictionary(p => Enum.GetName(typeof(PropertyId), p)!);
26-
}
27-
2848
return s_propertyIdFromNameMap.TryGetValue(value, out var result)
2949
? result
3050
: PropertyId.None;

source/UIData/Tools/PropertyId.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ enum PropertyId
3939
TrimEnd = TransformMatrix << 1,
4040
TrimOffset = TrimEnd << 1,
4141
TrimStart = TrimOffset << 1,
42+
43+
// Any new value should also be added to UIData/Tools/Properties.cs
44+
// This is needed to omit Enum.GetValues usage to be AOT compatible.
4245
}
4346
}

0 commit comments

Comments
 (0)