XamlStyler
XamlStyler copied to clipboard
Not the same results in "attribute ordering" between Visual Studio and Rider
Describe the bug I'm using Visual Studio 2022 (Version 17.3.1) and Rider 2022.2.2 with Xaml styler extension: VS : 3.2208.1 Rider : 3.2208.0.0 OS: Windows 10 and 11
In a WPF .net 6 application, I want to format the xaml and i have not the same results when using VS and Rider. I kept the default settings after the plugin installation.
Bug 1: In VS case:
In Rider case: all attributes are ordered by name, but it seems the the rules are not applied:
to fix the behavior and move x:Attribute on first location in the xml tag, I have to uncheck in settings "Enable attribute reordering", save options, and go back to the same menu and enable the checkbox. and now ordering is ok.
Bug2 (with the same xaml styler options):
VS case : when formatting xaml, visual sutio keep some attributes in the same line:

Rider case : when formatting, some properties are in a different line.

Is there any other options to have the same formatting behavior between this two editors ?
Thanks.
@wlaroche to confirm, you are observing this with the default settings in the extension (i.e., no external settings configuration file)?
To help debug, can you try using the default settings as an external configuration to see if that resolves the differences?
OK, i'm just seing that i have a Settings.XamlStyler near my solution with this content:
{
"AttributesTolerance": 2,
"KeepFirstAttributeOnSameLine": false,
"MaxAttributeCharactersPerLine": 60,
"MaxAttributesPerLine": 3,
"NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
"SeparateByGroups": true,
"AttributeIndentation": 0,
"AttributeIndentationStyle": 1,
"RemoveDesignTimeReferences": false,
"EnableAttributeReordering": true,
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
"xmlns:*",
"x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
"Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan",
"Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
"Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
"HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment",
"Margin, Padding",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
"FirstLineAttributes": "x:Key, Key, x:Name, Name",
"OrderAttributesByName": true,
"PutEndingBracketOnNewLine": false,
"RemoveEndingTagOfEmptyElement": true,
"SpaceBeforeClosingSlash": true,
"RootElementLineBreakRule": 0,
"ReorderVSM": 2,
"ReorderGridChildren": false,
"ReorderCanvasChildren": false,
"ReorderSetters": 0,
"FormatMarkupExtension": true,
"NoNewLineMarkupExtensions": "x:Bind, Binding",
"ThicknessSeparator": 2,
"ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin",
"FormatOnSave": true,
"CommentPadding": 2,
}
I tried 2 cases: When I I set in VS and Rider the exact path of Settings.XamlStyler file in settings, the formatting results is the same in each editor => OK.
In my case, I would not set a specific file, because in the team, each developer has its own workspace. I tried with just settings the filename, not the complete path and it does not work. => formatting results are different.
I would like to use this option: "Search in drive root" When activating this option in each editors, I have not the same formatting results. I confirm I have only one config file in all my solution.