[XAML] XAML Styler でコードフォーマットする
XAML Styler というXAML のコード整形ツールを使用します。インデント、閉じタグ、属性の並び順までフォーマットすることが可能です。
拡張機能でインストールしたり、NuGet パッケージから dotnet tool として CLI で使用することができます。
XAML Styler for Visual Studio 2022 - Visual Studio Marketplace
NuGet Gallery | XamlStyler.Console
使用方法は単純なので、設定ファイルについて調べてみました。
環境
- XAML Styler 3.2404.2
- .NET 9.0.9 (SDK 9.0.101)
- C# 13.0
- Visual Studio 2022 Version 17.12.3
- Windows 11 Pro 23H2 22631.4460
プロパティ一覧
設定できるプロパティを一覧にしました。
- Wiki: https://github.com/Xavalon/XamlStyler/wiki/Configuration
- 設定クラス: https://github.com/Xavalon/XamlStyler/blob/master/src/XamlStyler/Options/StylerOptions.cs
Attribute Formatting
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
AttributeIndentation | Attribute indentation | int | 0 |
AttributeIndentationStyle | Attribute indentation style | Mixed = 0 ,Spaces = 1 | Spaces |
AttributesTolerance | Attribute tolerance | int | 2 |
KeepFirstAttributeOnSameLine | Keep first attribute on same line | bool | false |
MaxAttributeCharactersPerLine | Max attribute characters per line | int | 0 |
MaxAttributesPerLine | Max attributes per line | int | 1 |
NewlineExemptionElements | Newline exemption elements | string | 後述 |
RemoveDesignTimeReferences | Remove design-time references | bool | false |
SeparateByGroups | Separate by groups | bool | false |
Attribute Reordering
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
EnableAttributeReordering | Enable Attribute Reordering | bool | true |
AttributeOrderingRuleGroups | Attribute ordering rule groups | string[] | 後述 |
FirstLineAttributes | First-line attributes | string | "" |
OrderAttributesByName | Order attributes by name | bool | true |
IgnoreDesignTimeReferencePrefix | Ignore Design-Time Reference Prefix | bool | false |
Element Formatting
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
PutEndingBracketOnNewLine | Put ending brackets on new line | bool | false |
RemoveEndingTagOfEmptyElement | Remove ending tag of empty elements | bool | true |
SpaceBeforeClosingSlash | Space before ending slash in self-closing elements | bool | true |
RootElementLineBreakRule | Root element line breaks between attributes | Default = 0 ,Always = 1 ,Never = 2 | Default |
Element Reordering
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
ReorderVSM | Reorder visual state manager | None = 0 ,First = 1 ,Last = 2 | Last |
ReorderGridChildren | Reorder grid panel children | bool | false |
ReorderCanvasChildren | Reorder canvas panel children | bool | false |
ReorderSetters | Reorder setters | None = 0 ,Property = 1 ,TargetName = 2 ,TargetNameThenProperty = 3 | None |
Markup Extension Handling
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
FormatMarkupExtension | Enable markup extension formatting | bool | true |
NoNewLineMarkupExtensions | Keep markup extensions of these types on one line | string | x:Bind, Binding |
Miscellaneous
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
FormatOnSave | Format XAML on Save | bool | true |
SaveAndCloseOnFormat | Automatically save and close documents opened by XAML Styler | bool | true |
CommentPadding | Comment padding | int | 2 |
Thickness Formatting
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
ThicknessSeparator | Thickness separator | None = 0 ,Space = 1 ,Comma = 2 | Comma |
ThicknessAttributes | Thickness attributes | string | Margin, Padding, BorderThickness, ThumbnailClipMargin |
XAML Styler Configuration
JsonProperty | DisplayName | Type | Default |
---|---|---|---|
SearchToDriveRoot | Search to drives root | bool | false |
ResetToDefault | Reset to default | bool | false |
ConfigPath | External configuration file | string | "" |
xstyler.exe 専用
JsonProperty | Type | Default |
---|---|---|
IndentSize | int | 4 |
IndentWithTabs | bool? | false |
デフォルト値
ここにデフォルト値の JSON が記載されています。
- https://github.com/Xavalon/XamlStyler/wiki/External-Configurations#default-configuration
- https://github.com/Xavalon/XamlStyler/blob/master/src/XamlStyler/Options/DefaultSettings.json
全てデフォルト値を設定した Settings.XamlStyler
ファイルは次の通りです。
上記の JSON を元に作成していますが、一部変更しています (差分は後述)。
{
"AttributesTolerance": 2,
"KeepFirstAttributeOnSameLine": false,
"MaxAttributeCharactersPerLine": 0,
"MaxAttributesPerLine": 1,
"NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
"SeparateByGroups": false,
"AttributeIndentation": 0,
"AttributeIndentationStyle": 1,
"RemoveDesignTimeReferences": false,
"IgnoreDesignTimeReferencePrefix": 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",
"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"
],
"FirstLineAttributes": "",
"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,
"SaveAndCloseOnFormat": true,
"CommentPadding": 2,
"SearchToDriveRoot": false,
"IndentSize": 4,
"IndentWithTabs": false
}
Wiki の JSON に対しての変更差分です。設定可能なプロパティを追記しました。
+ "SaveAndCloseOnFormat": true,
+ "SearchToDriveRoot": false,
+ "IndentSize": 4,
+ "IndentWithTabs": false
カスタム設定
好みが分かれそうなプロパティを確認してみます。GitHub で path:**/*.xamlstyler を検索して、適当にピックアップしました。
デフォルト設定に対して変更している設定値の一覧です。
Repo | Star | AttributesTolerance | KeepFirstAttributeOnSameLine | AttributeIndentationStyle | EnableAttributeReordering | OrderAttributesByName | PutEndingBracketOnNewLine | RootElementLineBreakRule | ReorderVSM | ReorderGridChildren | ReorderSetters | FormatMarkupExtension | ThicknessSeparator | CommentPadding |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
デフォルト | 2 | FALSE | 1 | TRUE | TRUE | FALSE | 0 | 2 | FALSE | 0 | TRUE | 2 | 2 | |
Uno.Themes | 170 | 1 | TRUE | 0 | FALSE | FALSE | 0 | 1 | ||||||
Uno.Gallery | 156 | 1 | TRUE | 0 | FALSE | FALSE | 0 | 1 | ||||||
Fluent.Ribbon | 2569 | 1 | TRUE | 1 | 3 | 1 | ||||||||
snoopwpf | 2224 | 1 | TRUE | 1 | 3 | 1 | 1 | |||||||
Graph-Controls | 155 | 1 | TRUE | |||||||||||
Material.Avalonia | 851 | TRUE | ||||||||||||
Prism.Avalonia | 315 | TRUE | ||||||||||||
WolvenKit | 945 | 1 | FALSE | 1 | TRUE | 3 | 1 | |||||||
Lottie-Windows | 639 | 1 | TRUE | |||||||||||
PSAppDeployToolkit | 1879 | 1 | FALSE | 0 | 1 | |||||||||
MahApps.Metro | 9345 | TRUE | 1 | 3 | 1 | |||||||||
IconPacks.Browser | 149 | TRUE | 1 | 3 | 1 | |||||||||
WindowsCommunityToolkit | 5904 | 1 | TRUE | 1 | ||||||||||
XamlFlair | 818 | 1 | TRUE | 1 | ||||||||||
audio-band | 660 | TRUE | ||||||||||||
H.NotifyIcon | 574 | 1 | FALSE | TRUE | 1 | |||||||||
Character-Map-UWP | 634 | 0 | FALSE | 0 | ||||||||||
Sharpnado.MaterialFrame | 504 | TRUE | ||||||||||||
Vulnerator | 206 | 1 | TRUE | TRUE | 3 |
個人的には以下のように設定値を変更しようと思います。
- "AttributesTolerance": 2,
+ "AttributesTolerance": 1,
- "KeepFirstAttributeOnSameLine": false,
+ "KeepFirstAttributeOnSameLine": true,
- "ReorderSetters": 0,
+ "ReorderSetters": 3,
- "CommentPadding": 2,
+ "CommentPadding": 1,
カスタム順序
以下のプロパティは属性順が定義されています。
- NewlineExemptionElements
- AttributeOrderingRuleGroups
- NoNewLineMarkupExtensions
- ThicknessAttributes
デフォルト設定に対して変更している差分をピックアップしました。
Uno.Themes/Settings.XamlStyler at master
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, StaticResource",
Fluent.Ribbon/Settings.XAMLStyler at develop
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, MultiTrigger, DataTrigger, MultiDataTrigger, Condition, Setter, SolidColorBrush, Pen",
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
"xmlns:*",
- "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
+ "x:Key, Key, x:Name, Name, x:Uid, Uid, Title, Header",
+ "TargetType, BasedOn, Style",
"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",
+ "Background, Foreground, FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch",
+ "SmallIcon, Icon, MediumIcon, LargeIcon",
"*:*, *",
- "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
- "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
+ "PageSource, PageIndex, Color, Opacity, Offset, TargetName, Property, Value, StartPoint, EndPoint",
+ "*:Freeze, mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
- "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "NoNewLineMarkupExtensions": "x:Bind, Binding, TemplateBinding, x:Static, DynamicResource, ComponentResourceKey, RelativeSource",
Material.Avalonia/Settings.XamlStyler at master · AvaloniaCommunity/Material.Avalonia
"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",
"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"
+ "Storyboard.*, From, To, Duration",
+ "CommandParameter, Command",
+ "ItemsSource, SelectedItem"
],
snoopwpf/Settings.XAMLStyler at develop · snoopwpf/snoopwpf
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, MultiTrigger, DataTrigger, MultiDataTrigger, Condition, Setter, SolidColorBrush, Pen",
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
"xmlns:*",
- "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
+ "x:Key, Key, x:Name, Name, x:Uid, Uid, Title, Header",
+ "TargetType, BasedOn, Style",
"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",
+ "PageSource, PageIndex, Color, Opacity, Offset, TargetName, Property, Value, StartPoint, EndPoint",
+ "*:Freeze, mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
- "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "NoNewLineMarkupExtensions": "x:Bind, Binding, TemplateBinding, x:Static, DynamicResource, ComponentResourceKey, RelativeSource",
WolvenKit/Settings.XamlStyler at main · WolvenKit/WolvenKit
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, ColumnDefinition, RowDefinition, SolidColorBrush, KeyBinding",
"AttributeOrderingRuleGroups": [
"x:Class",
+ "x:TypeArguments",
"xmlns, xmlns:x",
"xmlns:*",
+ "mc:Ignorable",
+ "d:*",
"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",
+ "IconPack, Kind",
"Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
"Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
+ "Size",
+ "Background, BorderBrush, BorderThickness, CornerRadius",
+ "Foreground, FontSize, FontWeight, FontFamily",
+ "Style",
+ "BasedOn, TargetType",
+ "Visibility, IsEnabled",
+ "HeaderRowHeight, RowHeight, ColumnSizer",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
- "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "NoNewLineMarkupExtensions": "",
Lottie-Windows/settings.xamlstyler at main · CommunityToolkit/Lottie-Windows
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, ColumnDefinition, RowDefinition, SolidColorBrush, KeyBinding",
"AttributeOrderingRuleGroups": [
"x:Class",
+ "x:TypeArguments",
"xmlns, xmlns:x",
"xmlns:*",
+ "mc:Ignorable",
+ "d:*",
"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"
],
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "
+ RadialGradientBrush,
+ GradientStop,
+ LinearGradientBrush,
+ ScaleTransfom,
+ SkewTransform,
+ RotateTransform,
+ TranslateTransform,
+ Trigger,
+ EventTrigger,
+ Condition,
+ Setter,
+ Style,
+ SolidColorBrush,
+ ControlTemplate,
+ VisualState,
+ VisualTransition,
+ DoubleAnimationUsingKeyFrames,
+ DiscreteDoubleKeyFrame,
+ LinearDoubleKeyFrame,
+ EasingDoubleKeyFrame,
+ SplineDoubleKeyFrame,
+ ObjectAnimationUsingKeyFrames,
+ DiscreteObjectKeyFrame,
+ BooleanAnimationUsingKeyFrames,
+ DiscreteBooleanKeyFrame,
+ Int32AnimationUsingKeyFrames,
+ DiscreteInt32KeyFrame,
+ ThicknessAnimationUsingKeyFrames,
+ DiscreteThicknessKeyFrame,
+ ScaleTransform,
+ DataTrigger,
+ RowDefinition,
+ ColumnDefinition,
+ primitives:CornerRadiusFilterConverter,
+ ui:CornerRadiusFilterConverter,
+ StaticResource,
+ m:StaticResource,
+ ui:StaticResource,
+ Controls:HamburgerMenuItemStyleSelector,
+ ui:AppBarButton,
+ ui:AppBarToggleButton,
+ Binding,
+ local:RatingItemFontInfo,
+ animation:CubicBezierEase,
+ CommandBinding,
+ ui:VisualStateGroupListener,
+ ImageBrush,
+ ui:BitmapIcon,
+ Storyboard
+ ",
- "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "NoNewLineMarkupExtensions": "x:Bind, Binding, TemplateBinding",
MahApps.Metro/Settings.XAMLStyler at develop · MahApps/MahApps.Metro
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, MultiTrigger, DataTrigger, MultiDataTrigger, Condition, Setter, SolidColorBrush, Pen",
"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",
"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",
+ "*:Freeze, mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
- "NoNewLineMarkupExtensions": "x:Bind, Binding",
+ "NoNewLineMarkupExtensions": "x:Bind, Binding, TemplateBinding, x:Static, DynamicResource, ComponentResourceKey, iconPacks:Modern, iconPacks:Material",
IconPacks.Browser/Settings.XAMLStyler at main · MahApps/IconPacks.Browser
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, MultiTrigger, DataTrigger, MultiDataTrigger, Condition, Setter, SolidColorBrush, Pen",
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
"xmlns:*",
- "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
+ "x:Key, Key, x:Name, Name, x:Uid, Uid, Title, Header",
+ "TargetType, BasedOn, Style",
"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",
+ "Background, Foreground, FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch",
"*:*, *",
- "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
- "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
+ "PageSource, PageIndex, Color, Opacity, Offset, TargetName, Property, Value, StartPoint, EndPoint",
+ "*:Freeze, mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
Vulnerator/Settings.XamlStyler at master · Vulnerator/Vulnerator
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, Color, SolidColorBrush",
"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",
"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"
+ "Storyboard.*, From, To, Duration",
+ "HorizontalScrollBarVisibility, VerticalScrollBarVisibility",
+ "ElementName, Path, RelativeSource"
],
- "FirstLineAttributes": "",
+ "FirstLineAttributes": "x:Name",
XamlFlair/Settings.XamlStyler at master · XamlFlair/XamlFlair
"AttributeOrderingRuleGroups": [
"x:Class",
"xmlns, xmlns:x",
+ "xmlns:mc",
+ "xmlns:d",
"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",
+ "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
+ "x:Key, Key, x:Name, Name",
+ "PlaceholderText, Text, x:Uid",
+ "Style",
+ "Foreground, FontSize, FontFamily, FontWeight, FontStyle, TextAlignment, TextWrapping, TextTrimming",
"Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
- "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
- "*:*, *",
+ "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"
+ "Storyboard.*, From, To, Duration",
+ "*",
+ "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom, Panel.ZIndex",
+ "*:*"
],
Character-Map-UWP/CharacterMap/Settings.XamlStyler at master · character-map-uwp/Character-Map-UWP
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Style, Setter, SplineDoubleKeyFrame, KeySpline, EasingDoubleKeyFrame",
"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",
+ "x:Key, Key, x:Name, x:Load, x:DeferLoadStrategy, Name, x:Uid, Uid, Title",
+ "x:*",
+ "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom, ColumnSpacing, RowSpacing",
"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",
+ "mc:Ignorable, d:*",
"Storyboard.*, From, To, Duration"
],
Prism.Avalonia/Settings.XamlStyler at develop · AvaloniaCommunity/Prism.Avalonia
"AttributeOrderingRuleGroups": [
- "x:Class",
"xmlns, xmlns:x",
"xmlns:*",
+ "x:Class",
- "x:Key, Key, x:Name, Name, x:Uid, Uid, Title",
+ "x:Key, Key, x:Name, Name, x:Uid, Uid, Title, Text",
"Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom",
+ "Content",
"Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight",
"Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex",
+ "Source",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
- "FirstLineAttributes": "",
+ "FirstLineAttributes": "Text",
Uno.Gallery/Settings.XamlStyler at master · unoplatform/Uno.Gallery
- "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, StaticResource",
+ "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, StaticResource, utu:Shadow, d:Shadow",
"AttributeOrderingRuleGroups": [
"x:Class",
- "xmlns, xmlns:x",
+ "xmlns, xmlns:x, xmlns:d, xmlns:mc, mc:Ignorable",
"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",
+ "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, AbsoluteLayout.LayoutFlags, AbsoluteLayout.LayoutBounds",
+ "Style, WidthRequest, HeightRequest, MinimumWidthRequest, MinimumHeightRequest",
+ "Margin, Padding, HorizontalOptions, VerticalOptions, HorizontalTextAlignment, VerticalTextAlignment",
"*:*, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText",
"Storyboard.*, From, To, Duration"
],
CLI による自動フォーマット実行
https://github.com/Xavalon/XamlStyler/wiki/Script-Integration#install-as-a-local-tool
VS でターミナルを開き、以下のコマンドを実行します。
dotnet new tool-manifest
.config/dotnet-tools.json
が作成されます。
{
"version": 1,
"isRoot": true,
"tools": {}
}
以下のコマンドでインストールします。
dotnet tool install XamlStyler.Console
{
"version": 1,
"isRoot": true,
"tools": {
"xamlstyler.console": {
"version": "3.2404.2",
"commands": [
"xstyler"
]
}
}
}
以下のようなコマンドで実行します。
dotnet xstyler --directory "SampleApp1" -recursive --config "../Settings.XamlStyler"
--config
は指定した方が効率的です。
https://github.com/Xavalon/XamlStyler/blob/Release-3.2404.2/src/XamlStyler.Console/XamlStylerConsole.cs#L253-L279
また、ビルド時に自動的にフォーマットすることもできると思います。
SampleApp1.csproj
(⚠️このコードは未検証です)
<Target Name="MyXAMLStyler_Restore" BeforeTargets="Restore;CollectPackageReferences">
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High"/>
</Target>
<Target Name="MyXAMLStyler_BeforeBuild" BeforeTargets="BeforeBuild">
<!-- <Exec Command="dotnet tool restore" /> -->
<Exec Command="dotnet xstyler --directory '$(ProjectDir)' -recursive --config '../Settings.XamlStyler'" />
</Target>
別のPCでは一度 dotnet tool restore を実行する必要がある点に注意してください。
感謝
関連記事
新着記事