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

Design time type converters are needed #18383

Closed
etvorun opened this issue Oct 26, 2023 · 7 comments
Closed

Design time type converters are needed #18383

etvorun opened this issue Oct 26, 2023 · 7 comments
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging p/3 Work that is nice to have partner/hot-reload-xaml Issues impacting XAML Hot Reload experiences partner/platform-tools Client Experiences Platform Tools proposal/open s/needs-info Issue needs more info from the author

Comments

@etvorun
Copy link
Contributor

etvorun commented Oct 26, 2023

Description

[update] alternative approach is to update RegisterMetadata to use netsandart 2.0 type converters, the ones used during msbuild. We would need to make sure that NS2 assemblies are loaded into VS/VSCode process. Without XAML parser dealing with assembly loading.

MAUI provides a handful of type converters used by VS to validate XAML while user edits it, e.g. see ColorDesignTypeConverter. The converters are exposed to VS via RegisterMetadata class. Ideally all runtime type converters should have matching design time type converter. Here is a list of most important type converters which should have design time counterparts:

Microsoft.Maui.Controls.AcceleratorTypeConverter
Microsoft.Maui.Controls.Button.ButtonContentTypeConverter
Microsoft.Maui.Controls.BindablePropertyConverter
Microsoft.Maui.Controls.BoundsTypeConverter
Microsoft.Maui.Converters.ConstraintTypeConverter
Microsoft.Maui.Converters.CornerRadiusTypeConverter
Microsoft.Maui.Controls.FileImageSourceConverter
Microsoft.Maui.Controls.FontAttributesConverter
Microsoft.Maui.Controls.FontTypeConverter
Microsoft.Maui.Controls.ImageSourceConverter
Microsoft.Maui.Controls.ListStringTypeConverter
Microsoft.Maui.Graphics.Converters.PointTypeConverter
Microsoft.Maui.Graphics.Converters.RectTypeConverter
Microsoft.Maui.Controls.RDSourceTypeConverter
Microsoft.Maui.Controls.TextAlignmentConverter
Microsoft.Maui.Controls.TextDecorationConverter
Microsoft.Maui.Converters.ThicknessTypeConverter
Microsoft.Maui.Controls.UriTypeConverter
Microsoft.Maui.Controls.VisualElement.VisibilityConverter
Microsoft.Maui.Controls.WebViewSourceTypeConverter

Public API Changes

Implement and register design time type converters

Intended Use-Case

To be used by VS XAML editor as well as C# DevKit XAML editor

@etvorun etvorun added proposal/open partner/platform-tools Client Experiences Platform Tools partner/hot-reload-xaml Issues impacting XAML Hot Reload experiences labels Oct 26, 2023
@jonathanpeppers
Copy link
Member

I would suggest we don't do this.

And instead start using the runtime converters at design-time. So for example, we could unify:

The runtime one has a lot of performance work done, such as f8a272d. I would think the Regex-based design-time one is fairly slow in comparison.

It feels a bit odd to implement 2x of every XAML converter.

@etvorun
Copy link
Contributor Author

etvorun commented Oct 26, 2023

@jonathanpeppers Using runtime converters is fine as long as they behave correctly in "developer environment" processes like VS, VS Code LSP process, etc. Invoking TypeConverter.IsValid and CanConvertFrom should not throw and return correct result. If calling IsValid triggers loading MAUI netstandard 2.0 assemblies into "developer environment" process, then there should be guarantee that assemblies properly load without additional help from devenv process. Finally, those converters should still be exposed via RegisterMetadata as that is the only way to opt into loading arbitrary type converters.

@jonathanpeppers
Copy link
Member

Invoking TypeConverter.IsValid and CanConvertFrom should not throw and return correct result

If the runtime converters don't work, that is even worse. That means it wouldn't work at runtime in a developer's app!

IsValid triggers loading MAUI netstandard 2.0 assemblies into "developer environment" process, then there should be guarantee that assemblies properly load without additional help from devenv process

Can you explain this? Do we have documentation on how VS loads Microsoft.Maui.Controls.Xaml.DesignTools.dll? This file could be in the NuGet cache or a workload pack in C:\Program Files\dotnet. How is it located?

@Eilon Eilon added the area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging label Oct 30, 2023
@PureWeen
Copy link
Member

PureWeen commented Nov 6, 2023

Invoking TypeConverter.IsValid and CanConvertFrom should not throw and return correct result

If the runtime converters don't work, that is even worse. That means it wouldn't work at runtime in a developer's app!

IsValid triggers loading MAUI netstandard 2.0 assemblies into "developer environment" process, then there should be guarantee that assemblies properly load without additional help from devenv process

Can you explain this? Do we have documentation on how VS loads Microsoft.Maui.Controls.Xaml.DesignTools.dll? This file could be in the NuGet cache or a workload pack in C:\Program Files\dotnet. How is it located?

@etvorun thoughts?

@PureWeen PureWeen added the s/needs-info Issue needs more info from the author label May 7, 2024
Copy link
Contributor

Hi @etvorun. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@dotnet-policy-service dotnet-policy-service bot added the s/no-recent-activity Issue has had no recent activity label May 13, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@spadapet spadapet added the p/3 Work that is nice to have label May 15, 2024
@dotnet-policy-service dotnet-policy-service bot added s/no-recent-activity Issue has had no recent activity and removed s/no-recent-activity Issue has had no recent activity labels May 15, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2024
@dotnet-policy-service dotnet-policy-service bot removed the s/no-recent-activity Issue has had no recent activity label Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging p/3 Work that is nice to have partner/hot-reload-xaml Issues impacting XAML Hot Reload experiences partner/platform-tools Client Experiences Platform Tools proposal/open s/needs-info Issue needs more info from the author
Projects
None yet
Development

No branches or pull requests

5 participants