XamlStyler
XamlStyler copied to clipboard
Account for attributes where order matters in default ordering rules
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"
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?
is ItemsSource and SelectedItem necessary? default behavior is sorting by alphabet so it seems that they should end up in this order?
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?
yes, definitely
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
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.