Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AvaloniaList compile time parsing #11073

Merged
merged 6 commits into from
Apr 21, 2023
Merged

AvaloniaList compile time parsing #11073

merged 6 commits into from
Apr 21, 2023

Conversation

maxkatz6
Copy link
Member

What does the pull request do?

Instead of relying on runtime parsing which would bring unsafe AvaloniaListConverter (because of TypeConverters with reflection), attempt to do it compile time for prepared types.

Initially I added this attribute for Classes property, which doesn't use ',' as a separator and ' ' is instead, but @grokys already has redone how Classes are parsed in compile time and it has a way more specific logic now.
This attribute can be removed now, if we define "," as a separator for all AvaloniaLists and not just default.

Fixed issues

Fixes #10109

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0033524-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@kekekeks
Copy link
Member

I wonder if it makes sense to parse into T[] instead of AvaloniaList<T> when property is IList<T>-typed

@maxkatz6
Copy link
Member Author

@kekekeks done, also kekekeks/XamlX#86

Comment on lines +17 to +20
public Polyline()
{
Points = new Points();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but changes nullability of points property to be consistent with PolyLineSegment/Geometry.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0033565-beta. (feed url: https://pkgs.dev.azure.com/AvaloniaUI/AvaloniaUI/_packaging/avalonia-all/nuget/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Apr 21, 2023
Merged via the queue into master with commit f174a1f Apr 21, 2023
@maxkatz6 maxkatz6 deleted the avalonia-list branch April 21, 2023 07:33
@robloo
Copy link
Contributor

robloo commented May 29, 2023

Not a huge fan of going from a clear Points collection to IList<Point>. Seems like a step backwards from an API standpoint. We really shouldn't be passing around IList following other XAML framework conventions.

WPF:
https://learn.microsoft.com/en-us/dotnet/api/system.windows.shapes.polygon.points?view=netframework-4.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve AvaloniaList/List compiler support
4 participants