In my team, the code style in .xaml files are currently not very consistent. We looked over the Visual Studio auto formatter to make it format the code into something we like. However, for one option we lack an extra condition. The options Im talking about are found under Tools -> Options -> Text Editor -> XAML -> Formatting.
We want each attribute on a separate line. Initially, we also wanted the first attribute on a new line (below the start of the tag) like so:
<MyFooBarButton
Attrib1="a"
Attrib2="b" />
But we quickly realized that running with those rules would make tags that only set one attribute look horrible, especially if the were nested:
<MyFooBarButton
Attrib1="a" />
<NestedFoo
Attrib="b" />
<NestedFoo2
Attrib="c" />
So we tried positioning the first attribute on the same line as the start tag. While still keeping the two important rules (one attribute per line, vertically aligned). It looked decent in both cases:
<MyFooBarButton Attrib1="a"
Attrib2="b" />
<MyFooBarButton Attrib1="a" />
<NestedFoo Attrib="b" />
<NestedFoo2 Attrib="c" />
The problem now is that Visual Studio seems to lack the condition to have both. I.e.:
- If only one attribute is set: keep it on one line.
- If more than one attribute is set: place first attribute on a new line, one attribute per line and align them vertically.
Can Visual Studio 2008 be made to do this? And if not, could the code formatter in ReSharper do it (might make it worth the cost)?