KEMBAR78
Adds FlowDirection Design TypeConverter by Redth · Pull Request #6384 · dotnet/maui · GitHub
Skip to content

Conversation

@Redth
Copy link
Member

@Redth Redth commented Apr 21, 2022

Fixes #6343

Adds a Design TypeConverter for FlowDirection so that XAML editor/intellisense can report the values and invalid values correctly.

@Redth Redth added this to the 6.0.300-rc.3 milestone Apr 21, 2022
@Redth Redth self-assigned this Apr 21, 2022
@Redth
Copy link
Member Author

Redth commented Apr 21, 2022

@mgoertz-msft does this look correct?

@mgoertz-msft
Copy link
Contributor

@Redth Looks good, but it begs the question why we wouldn't just add the new values to the enum and remove the runtime TypeConverter?

There also still seems to be a slight difference in what the runtime TC accepts. The new values are case insensitive whereas the enum values and this DT converter I believe do check the case.

@Redth
Copy link
Member Author

Redth commented Apr 21, 2022

Adding duplicate values seemed off to me...

@StephaneDelcroix thoughts ?

@jsuarezruiz jsuarezruiz added the area-xaml XAML, CSS, Triggers, Behaviors label Apr 22, 2022
@StephaneDelcroix
Copy link
Contributor

ltr, rtl and inherit aren't valid values for FlowDirection in Xaml. The reason they're there is to be able to reuse the same type converter for both Xaml and CSS, but we have precedent where the runtime type converter tolerates CSS values and the compiled one does not.

also, as @mgoertz-msft said, Xaml syntax is case-sensitive, where CSS is not.

Depending on what's our goal here, there are multiple courses of action:
1/ Xaml is opinionated, dare entering a non-valid value, you get error and squiggles => don't do anything
2/ Xaml attributes values should accept CSS values and be case insensitive, oh, and maybe a mix of both => really ? list separator in xaml is ',' and ' ' in CSS. borders are expressed ltrb in one dialect, trbl in the other, ...
3/ Make an exception, just for this one => then add, as proposed by @mgoertz-msft, alias values to the enum 'rtl = RightToLeft`, and we could almost get rid of the converter if it wasn't for case insensitivity
4/ The current situation is confusing => split Xaml and CSS converters codes
5/ a mix of those...

The right path forward is 4/ (imho), and in the meantime I could create a Compiled version of this converter that will fail at compile time

@Redth Redth marked this pull request as draft April 22, 2022 14:41
@Redth Redth marked this pull request as ready for review April 22, 2022 19:21
@Redth Redth merged commit 8c8359b into main Apr 25, 2022
@Redth Redth deleted the dev/redth/flowdirection-design-converter branch April 25, 2022 14:58
AddMemberAttributes("Microsoft.Maui.Controls.VisualElement", "Visual",
new TypeConverterAttribute(typeof(VisualDesignTypeConverter)));

AddMemberAttributes("Microsoft.Maui.Controls.VisualElement", "FlowDirection",
Copy link
Contributor

Choose a reason for hiding this comment

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

side question, why do we have a [TypeConverter] on the Property, and not on the Type ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably because the real type converter is also on the property.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably because the real type converter is also on the property.

that was my question. Why are we doing this at the Core and Controls level. I understand we have to mimic it here

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that I don't know. @Redth?

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 sure, I was mostly just following what had been done for similar cases previously.

Copy link
Contributor

Choose a reason for hiding this comment

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

What this means is that the FlowDirection enum will only behave this way for the VisualElement.FlowDirection property. If that type is used for any other property, by 3rd party control vendors for example, then it will behave just like the regular enum and not allow those CSS values to be used.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@samhouts samhouts added the fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors fixed-in-6.0.300-rc.3 Look for this fix in 6.0.300-rc.3!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

There should be parse error when setting invalid value to FlowDirection property

6 participants