You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Right now, when developer sets a string value to the AvaloniaList property, compiler will emit "AvaloniaListConverter".
Which in runtime will use TypeUtilities.TryConvert marked as unsafe for reflection, as it can fallback to it in some code paths.
Instead, compiler should attempt to parse the list in compile time, and if it was successful, emit pre-constructed collection.
Describe the solution you'd like
To have a flexible support, we should add an attribute, which will work as a hint for the compiler, how to separate items in the collection.
I.e., Control.Classes is separated by spaces, while AvaloniaListConverter expects comma separated items.
We can expect something like:
// ShapepublicAvalonia.Collections.AvaloniaList<double>?StrokeDashArray{ get {thrownull;} set {}}// TickBar/Sliderpublic Avalonia.Collections.AvaloniaList<double>Ticks{ get {thrownull;} set {}}// BorderpublicAvalonia.Collections.AvaloniaList<double>?BorderDashArray{ get {thrownull;} set {}}// DashStylepublicAvalonia.Collections.AvaloniaList<double>?Dashes{ get {thrownull;} set {}}// PolylineGeometrypublic Avalonia.Points Points{ get {thrownull;} set {}}
Right now, we already do the same for Control.Classes property and Grid row/column definitions as a special case. It can be generalized.
Currently Avalonia.Themes.Fluent has exactly one usage of AvaloniaListConverter which can be avoided completely.
The text was updated successfully, but these errors were encountered:
Also, there was an interesting idea to introduce markup extension - kekekeks/XamlX#28. Which, in my opinion, should be a separated feature, because we already have support for string-to-array parsing in runtime using converter.
maxkatz6
changed the title
AvaloniaList/List compiler support
Improve AvaloniaList/List compiler support
Jan 28, 2023
Is your feature request related to a problem? Please describe.
Right now, when developer sets a string value to the AvaloniaList property, compiler will emit "AvaloniaListConverter".
Which in runtime will use TypeUtilities.TryConvert marked as unsafe for reflection, as it can fallback to it in some code paths.
Instead, compiler should attempt to parse the list in compile time, and if it was successful, emit pre-constructed collection.
Describe the solution you'd like
To have a flexible support, we should add an attribute, which will work as a hint for the compiler, how to separate items in the collection.
I.e., Control.Classes is separated by spaces, while AvaloniaListConverter expects comma separated items.
We can expect something like:
Additional context
It improves following APIs:
Right now, we already do the same for Control.Classes property and Grid row/column definitions as a special case. It can be generalized.
Currently Avalonia.Themes.Fluent has exactly one usage of AvaloniaListConverter which can be avoided completely.
The text was updated successfully, but these errors were encountered: