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

XamlX intrinsics parsing should be improved #16389

Open
maxkatz6 opened this issue Jul 21, 2024 · 0 comments
Open

XamlX intrinsics parsing should be improved #16389

maxkatz6 opened this issue Jul 21, 2024 · 0 comments

Comments

@maxkatz6
Copy link
Member

Is your feature request related to a problem? Please describe.

Currently, AvaloniaXamlIlLanguageParseIntrinsics only parses some primitives that were hardcoded into this class.
We need to manually add new types there each time as a yet another switch-case branch (or .Equals()).

In fact, most of our primitives are not covered with intrinsics, which results in runtime parsing and runtime errors.

Describe the solution you'd like

I don't have a good solution yet. I am creating this issue to gather some ideas at least.

Since XamlX compiler can only support build-in types parsing, we can do that by introducing some set of internal attributes to connect Parse/TryParse methods with type constructors.
But another problem is compiler not having visibility of build-in types unless we include each of them within compiler assembly itself. Note - Avalonia.Build.Tasks can't reference Avalonia. Or can it?

Describe alternatives you've considered

Not an alternative, but reflection based XamlX implementation used in Avalonia.Markup.Xaml.Loader (runtime xaml parser), might have a different intrinsics implementation, as we can use reflection more freely there.

Also, if it's not always possible to construct parsed type in compiler time, we should at least throw compile error if it can't be parsed.

Additional context

cc @kekekeks @MrJul for ideas

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

No branches or pull requests

1 participant