Skip to content

Commit 853a9ae

Browse files
Remove DynamicallyAccessedMemberTypes to improve trim/aot compatibility (#1211)
* remove the DynamicallyAccessedMemberTypes approach to improve trim compatibility
1 parent 66d63c0 commit 853a9ae

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

Source/DataTypes/SvgAspectRatio.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
1+
using System;
22
using System.ComponentModel;
3-
using System.Diagnostics.CodeAnalysis;
43
using Svg.DataTypes;
54

65
namespace Svg
@@ -55,14 +54,9 @@ public object Clone()
5554
return MemberwiseClone();
5655
}
5756

58-
#if NET6_0_OR_GREATER
59-
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(SvgPreserveAspectRatioConverter))]
60-
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "DynamicDependency keeps converter safe")]
61-
[UnconditionalSuppressMessage("AOT", "IL3050")]
62-
#endif
6357
public override string ToString()
6458
{
65-
return TypeDescriptor.GetConverter(typeof(SvgPreserveAspectRatio)).ConvertToString(this.Align) + (Slice ? " slice" : "");
59+
return Align.ToString() + (Slice ? " slice" : "");
6660
}
6761
}
6862

Source/DataTypes/SvgPoint.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.ComponentModel;
2-
using System.Diagnostics.CodeAnalysis;
3-
using Svg.DataTypes;
1+
using Svg.DataTypes;
42

53
namespace Svg
64
{
@@ -41,13 +39,9 @@ public override int GetHashCode()
4139
return base.GetHashCode();
4240
}
4341

44-
#if NET6_0_OR_GREATER
45-
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(SvgUnitConverter))]
46-
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "DynamicDependency keeps converter safe")]
47-
#endif
4842
public SvgPoint(string x, string y)
4943
{
50-
TypeConverter converter = TypeDescriptor.GetConverter(typeof(SvgUnit));
44+
var converter = new SvgUnitConverter();
5145

5246
this.x = (SvgUnit)converter.ConvertFrom(x)!;
5347
this.y = (SvgUnit)converter.ConvertFrom(y)!;

0 commit comments

Comments
 (0)