|
@@ -23,6 +23,11 @@ internal abstract class TargetTypeConverter
|
|
|
|
|
|
|
|
private class DefaultConverter : TargetTypeConverter
|
|
private class DefaultConverter : TargetTypeConverter
|
|
|
{
|
|
{
|
|
|
|
|
+ // TypeDescriptor.GetConverter might require unreferenced code for some generic types.
|
|
|
|
|
+ // But it's normally not the case in Avalonia. Additionally, compiled bindings will preserve referenced types.
|
|
|
|
|
+ [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = TrimmingMessages.TypeConversionSupressWarningMessage)]
|
|
|
|
|
+ [UnconditionalSuppressMessage("Trimming", "IL2067", Justification = TrimmingMessages.TypeConversionSupressWarningMessage)]
|
|
|
|
|
+ [UnconditionalSuppressMessage("Trimming", "IL2072", Justification = TrimmingMessages.TypeConversionSupressWarningMessage)]
|
|
|
public override bool TryConvert(object? value, Type type, CultureInfo culture, out object? result)
|
|
public override bool TryConvert(object? value, Type type, CultureInfo culture, out object? result)
|
|
|
{
|
|
{
|
|
|
if (value?.GetType() == type)
|
|
if (value?.GetType() == type)
|
|
@@ -66,9 +71,6 @@ internal abstract class TargetTypeConverter
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#pragma warning disable IL2026
|
|
|
|
|
-#pragma warning disable IL2067
|
|
|
|
|
-#pragma warning disable IL2072
|
|
|
|
|
// TODO: TypeConverters are not trimming friendly in some edge cases, we probably need
|
|
// TODO: TypeConverters are not trimming friendly in some edge cases, we probably need
|
|
|
// to make compiled bindings emit conversion code at compile-time.
|
|
// to make compiled bindings emit conversion code at compile-time.
|
|
|
var toTypeConverter = TypeDescriptor.GetConverter(t);
|
|
var toTypeConverter = TypeDescriptor.GetConverter(t);
|
|
@@ -122,8 +124,6 @@ internal abstract class TargetTypeConverter
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-#pragma warning restore IL2067
|
|
|
|
|
-#pragma warning restore IL2026
|
|
|
|
|
|
|
|
|
|
if (value is IConvertible convertible)
|
|
if (value is IConvertible convertible)
|
|
|
{
|
|
{
|