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

Extension will not alphabetize #444

Closed
rhayhurst opened this issue Oct 23, 2023 · 4 comments
Closed

Extension will not alphabetize #444

rhayhurst opened this issue Oct 23, 2023 · 4 comments

Comments

@rhayhurst
Copy link

The XamlStyler for Visual Studio will not alphabetize. No error message, no feedback in any way. Everything else works, in that it formats the file.

I get the same behavior regardless of what file/framework I'm using. I tried it on several .NET (7) MAUI project .xml files and a Xamarin.Forms project .xml file. The files are about as pedestrian as it can get.

I'm using Visual Studio Version 17.7.5, version 4.8.09032.
The extension I'm using is "XAML Styler for Visual Studio 2022" version 3.2208.1.
Here is a SO question I posted in case there's something I leave out.

The lack-of-alphabetization happened out of the box. I didn't touch anything in Tools >> Options >> XAML Styler, though just to be sure I changed a setting and then hit the "reset to default" option, and the setting did indeed reset to the default.

There must be something on my machine that isn't playing well with your software, possibly another extension that I have installed? Here are the extensions that I currently have installed:

  • XAML Styler for Visual Studio 2022
  • Visual Studio 25th Anniversary Theme Pack (preview), v 17.3.0.2
  • Visual Studio Code Themes, v 0.0.2
  • Visual Studio Them Pack, v 1.2
  • Incredibuild Build Acceleration, v 1.6.0.2
  • ML.NET Model Builder 2022 (disabled), v 16.13.9.2235601
  • Single-project MSIX Packaging Tools for VS 2022, v 1.3.0.23.3161
  • Live Share 2022, v 1.0.5875.1
  • Xamarin.Android.SDK, v 13.2.1.2

Finally, there's another weird thing about my computer which probably isn't relevant: I have two Android SDKs installed, as .NET Maui wants Android SDK to be installed at location A and Android Studio wants Android SDK installed at location B, and neither one will compromise (in case your software needs to know the location for some unknown reason, this could be messing it up).

@rhayhurst rhayhurst added the Bug label Oct 23, 2023
@rhayhurst
Copy link
Author

Oh, sorry, should've mentioned this:
I'm on Windows 11, specifically:
Windows 11 Pro version 22H2, OS build 22621.2428

@grochocki grochocki added VS VS2022 and removed VS labels Nov 2, 2023
@grochocki
Copy link
Contributor

By default, attributes are not ordered strictly alphabetical, but rather by a set of Attribute Ordering Rule Groups. Wildcards within rule groups will be alphabetized. Strict alphabetization of all attributes is not something that would be generally accepted as a best practice in XAML, but you should still be able to achieve this by changing Attribute Ordering Rule Groups from:

"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",
"Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"

to

"*:*, *"

@rhayhurst
Copy link
Author

Why wouldn't strict alphabetization not be considered a best practice in Xaml? I don't see how it hurts anything. When I read the description of the XamlStyler, I was under the direct impression that alphabetizing attributes was kind of what it did -- other stuff, too, but that was one of the main functions. It's why I downloaded it.

Anyways, I'll give your instructions a shot. Thanks!

@grochocki
Copy link
Contributor

There are certain logical groupings of attributes that sometimes makes it easier when adjusting them. For example, Width, Height, MaxWidth, MaxHeight, etc., so you will typically see certain attributes next to each other. In the default rule ordering groups, we separate these out, leaving everything else to the middle alphabetized catch all group *:*, *.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants