Open wieslawsoltes opened 2 weeks ago
It seems compiler has problem when list has generic type float, when you change to string type it works.
Change from:
public class numbers : AvaloniaList<float>
to:
public class numbers : AvaloniaList<string>
[TypeConverter(typeof(numbersTypeConverter))]
public class numbers : AvaloniaList<float>
{
}
public class numbersTypeConverter : TypeConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
{
return destinationType == typeof(numbers);
}
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string);
}
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
var numbers = (numbers)value;
return string.Concat(numbers.OfType<float>().Select(x => x));
}
public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
return new numbers();
}
}
Describe the bug
To Reproduce
Set property value to: baseFrequency="0 0.000001"
Expected behavior
Compiler does not throw System.FormatException and uses provided [TypeConverter(typeof(SvgNumberCollectionConverter))] instead trying to parse property value by itself.
Avalonia version
11.0.11, 11.1.4, 11.2.0
OS
macOS
Additional context
No response