XamlStyler icon indicating copy to clipboard operation
XamlStyler copied to clipboard

Account for attributes where order matters in default ordering rules

Open Janek91 opened this issue 9 years ago • 6 comments
trafficstars

According to this: http://www.nickdarnell.com/xaml-attribute-order-matters/ https://weblogs.asp.net/dixin/the-order-issue-of-xaml-attributes I think, that it should be considered to add new rules to default configuration file - regarding those issues. I got these in mine:

"CommandParameter, Command", "ItemsSource, SelectedItem"

Janek91 avatar Oct 25 '16 11:10 Janek91

Probably a good idea. I have the ItemsSource one in my projects as well. No sense in having everyone discover this issue and add their own custom rules for themselves. Are there any other common Attributes that should be considered?

grochocki avatar Oct 25 '16 17:10 grochocki

is ItemsSource and SelectedItem necessary? default behavior is sorting by alphabet so it seems that they should end up in this order?

NicoVermeir avatar Oct 25 '16 17:10 NicoVermeir

Hmm, good point. I think there was a bug in the past where wildcards did not work as expected. I imagine I should be able to remove the ItemsSource line from my config. I know that there are cases that ordering is significant, though. Perhaps we should use this issue to collect a list of them?

grochocki avatar Oct 25 '16 17:10 grochocki

yes, definitely

NicoVermeir avatar Oct 25 '16 17:10 NicoVermeir

Just to add to this, if you've defined a style and you attempt to override any properties from the style, you have to ensure you add those properties after the style attribute, otherwise it won't work. <BoxView VerticalOptions="Start" Style="{StaticResource StyleBoxViewHorizontalSeperator}" /> versus <BoxView Style="{StaticResource StyleBoxViewHorizontalSeperator}" VerticalOptions="Start" />

I fixed it for our project by adjusting the XamlStyler options and adding Style after Key

Key, x:Key, Uid, x:Uid
Style
Name, x:Name, Title

CliffCawley avatar Apr 07 '17 00:04 CliffCawley

It would be great to be able to account for attributes where order matters, but we also want to make sure we are comprehensive. We need to investigate the definitive list of attributes that are affected as well as check to ensure there are not any special considerations for Xamarin.

grochocki avatar Apr 09 '20 06:04 grochocki