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

XA1003 - Use a logical grouped order instead of an alphabetical order. #1

Open
cmaneu opened this issue May 12, 2014 · 2 comments
Open
Labels

Comments

@cmaneu
Copy link
Owner

cmaneu commented May 12, 2014

The alphabetical order is quick and simple. However, it can leads to harder reading when the number of attributes is important. For example, FontSize and TextAlignment have a close relationship, but can be few attributes (lines) away.

Here are the different groups, and their ordering, proposed.

  • x:Key and x:Name
  • Attached properties
  • Positionning (HorizontalAlignment, VerticalAlignment, margins, z-order, stretch Canvas., Grid.)
  • Box model (width, height)
  • Typography (Font*, Foreground if text item, Text, Content)
  • Visual (background, fill, foreground , borderbrush, borderthickness, Stroke, StrokeThickness opacity, visibility, style)
  • Misc
  • Event handlers

Pros:

  • Code is ordered in a meaningful way,
  • Related attributes are grouped.

Cons:

  • Difficult to maintain without tolling support

Questions:

  • How to handle custom controls attributes ? If you are using a vendor control suite (like Telerik or Infragistics), you may have a ton of "misc" attributes.

Your feedback is welcome.

@cmaneu
Copy link
Owner Author

cmaneu commented May 12, 2014

A plugin exists to get a slightly different result.
https://github.com/nicovermeir/xamlstyler

@cmaneu cmaneu changed the title XA1003 - Use a grouped order instead of an alphabetical order. XA1003 - Use a logical grouped order instead of an alphabetical order. May 12, 2014
@tbayart
Copy link

tbayart commented May 14, 2014

I agreed, sorting can be tricky to read.
Grouping is more logical, ie : I always group Width and Height together.
To automatise the process with a plugin, you need a configuration where you store grouped attributes.
Every time a new attribute is encountered, it is added in the configuration file in a "unsorted" group.
A UI allowing the user the move attributes between groups.

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

No branches or pull requests

2 participants