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
Option for configuring newline exemptions for attributes #408
Comments
Interesting idea! Your example works out nicely, but I am curious what expected behavior might be under less ideal scenarios. For instance, in your example, let's say you've specified <Button
x:Key="MyCustomButton"
Grid.Column="2"
Style="{StaticResource MyCustomStyle}"/> |
@grochocki yeah, I was thinking about that a bit more as well. There's definitely some complications. Easy for us humans to look at and know what we want, harder to quantify to the machines. 😋 I think the common piece here with a lot of these types of attributes and scenarios is that they're really tied to groups/sets of properties, e.g. you want your canvas attached properties or grid ones together. Since So, the newline exemption would only apply if the attribute is paired with another one of its partner attributes in that collection? For example, typically we have this:
So if the
Then if one of these is encountered, say So in your example: <Button
x:Key="MyCustomButton"
Grid.Column="2"
Style="{StaticResource MyCustomStyle}"/> Since there's no <Button
x:Key="MyCustomButton"
Grid.Row="1" Grid.Column="2"
Style="{StaticResource MyCustomStyle}"/> Even if the developer put them in different spots (before formatting): <Button
x:Key="MyCustomButton"
Grid.Column="2"
Style="{StaticResource MyCustomStyle}"
Grid.Row="1"/> Since they'd get ordered first by the attribute ordering rules, then it should be able to flow the logic and be consistent, right? |
Leveraging So, with this (abridged) config: "AttributeOrderingRuleGroups": [
...
0 "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
1 "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
2 "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
...
],
"NewlineExemptionAttributeGroups": ["1"], You would get: <Button
x:Key="MyCustomButton"
Grid.Row="1" Grid.Column="2"
Style="{StaticResource MyCustomStyle}"/> If you wanted to, say, only exempt "AttributeOrderingRuleGroups": [
...
0 "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
1 "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan",
2 "Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
3 "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
...
],
"NewlineExemptionAttributeGroups": ["1"], Or both, but on separate lines: "AttributeOrderingRuleGroups": [
...
0 "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
1 "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan",
2 "Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
3 "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
...
],
"NewlineExemptionAttributeGroups": ["1", "2"], |
Yeah, that could work too. Only issue with the index-based approach is that if someone changes the order of their attribute rule groups that can have unintended/adverse effects they don't expect, if they forgot they set the other property (or weren't aware of it with multiple contributors). |
Is your feature request related to a problem? Please describe.
I like to have attributes split out, but there are some pairs that I like to keep on the same line together like
Grid.Row
andGrid.Column
or theX1
,Y1
points of a Line on one line andX2
,Y2
on another.NewlineExceptionElements
only allows to completely ignore ordering on a parent element, but sometimes I really want to be more granular than that.Describe the solution you'd like
A collection like
NewlineExemptionElements
, butNewlineExemptionAttributes
which will ignore those attributes and leave them on the line with the previous attribute (according to the ordering rules).For instance adding
Grid.Column
as an exempted attribute value, would do this:vs. the default behavior:
Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: