forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-format our XAML files and enforce in CI (microsoft#9589)
This adds [`XamlStyler.Console`] to our solution, and calls it when we format the code, to also format our .xaml files. * `XamlStyler.Console` is a dotnet tool so it needs to be restored with `dotnet tool restore` * I've added a set of rules to approximately follow [@cmaneu's XAML guidelines]. Those guidelines also recommend things based on the code-behind, which this tool can't figure out, but also _don't matter that much_. * There's an extra step to strip BOMs from the output, since Xaml Styler adds a BOM by default. Some had them before and others didn't. BOMs have been nothing but trouble though. [`XamlStyler.Console`]: https://github.com/Xavalon/XamlStyler [@cmaneu's XAML guidelines]: https://github.com/cmaneu/xaml-coding-guidelines
- Loading branch information
1 parent
c19aa89
commit 3323dc5
Showing
38 changed files
with
2,863 additions
and
2,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"XamlStyler.Console": { | ||
"version": "3.2008.4", | ||
"commands": [ | ||
"xstyler" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,4 @@ SUMS$ | |
^\.github/actions/spelling/ | ||
^\.gitignore$ | ||
^doc/reference/master-sequence-list.csv$ | ||
^\XamlStyler.json$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="vswhere" version="2.6.7" /> | ||
</packages> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"AttributesTolerance": 1, | ||
"KeepFirstAttributeOnSameLine": true, | ||
"MaxAttributeCharactersPerLine": 0, | ||
"MaxAttributesPerLine": 1, | ||
"NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransform, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter", | ||
"SeparateByGroups": false, | ||
"AttributeIndentation": 0, | ||
"AttributeIndentationStyle": 1, | ||
"RemoveDesignTimeReferences": 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, | ||
"CommentPadding": 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
".wrn", | ||
".rec", | ||
".err", | ||
"XamlStyler.json", | ||
".xlsx" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<Application x:Class="GUIConsole.Wpf.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> | ||
<Application x:Class="GUIConsole.Wpf.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources /> | ||
</Application> |
184 changes: 100 additions & 84 deletions
184
samples/ConPTY/GUIConsole/GUIConsole.WPF/MainWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,100 @@ | ||
<Window x:Class="GUIConsole.Wpf.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
|
||
Title="MainWindow" Height="450" Width="800" | ||
Background="#C7000000" | ||
AllowsTransparency="True" | ||
WindowStyle="None" | ||
MouseDown="Window_MouseDown" | ||
BorderThickness="1" | ||
BorderBrush="LightSlateGray" | ||
|
||
KeyDown="Window_KeyDown" | ||
Loaded="Window_Loaded"> | ||
<Window.Resources> | ||
<Style x:Key="TitleBarButtonStyle" TargetType="{x:Type Button}"> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/> | ||
<Setter Property="FontSize" Value="14"/> | ||
<Setter Property="Height" Value="32"/> | ||
<Setter Property="Width" Value="46"/> | ||
<Setter Property="Background" Value="Transparent"/> | ||
<Setter Property="Foreground" Value="White"/> | ||
<Setter Property="BorderThickness" Value="0"/> | ||
</Style> | ||
|
||
<Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource TitleBarButtonStyle}"> | ||
<Setter Property="Content" Value=""/> | ||
<!--Remove the default Button template's Triggers, otherwise they'll override our trigger below.--> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Button.Background" Value="Red"/> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Window.Resources> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid Grid.Row="0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*"/> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock x:Name="TitleBarTitle" Grid.Column="0" VerticalAlignment="Center" Padding="10 0" Foreground="White"> | ||
GUIConsole | ||
</TextBlock> | ||
<StackPanel x:Name="TitleBarButtons" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Top"> | ||
<Button x:Name="MinimizeButton" | ||
Click="MinimizeButton_Click" | ||
Content="" | ||
Style="{StaticResource TitleBarButtonStyle}"/> | ||
<Button x:Name="MaximizeRestoreButton" | ||
Click="MaximizeRestoreButton_Click" | ||
Content="" | ||
FontSize="12" | ||
Style="{StaticResource TitleBarButtonStyle}"/> | ||
<Button x:Name="CloseButton" | ||
Click="CloseButton_Click" | ||
FontSize="12" | ||
Style="{StaticResource CloseButtonStyle}"/> | ||
</StackPanel> | ||
</Grid> | ||
<ScrollViewer x:Name="TerminalHistoryViewer" Grid.Row="1" ScrollChanged="ScrollViewer_ScrollChanged"> | ||
<TextBlock x:Name="TerminalHistoryBlock" FontFamily="Consolas" TextWrapping="Wrap" Foreground="White"/> | ||
</ScrollViewer> | ||
</Grid> | ||
</Window> | ||
<Window x:Class="GUIConsole.Wpf.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Title="MainWindow" | ||
Width="800" | ||
Height="450" | ||
AllowsTransparency="True" | ||
Background="#C7000000" | ||
BorderBrush="LightSlateGray" | ||
BorderThickness="1" | ||
KeyDown="Window_KeyDown" | ||
Loaded="Window_Loaded" | ||
MouseDown="Window_MouseDown" | ||
WindowStyle="None" | ||
mc:Ignorable="d"> | ||
<Window.Resources> | ||
<Style x:Key="TitleBarButtonStyle" | ||
TargetType="{x:Type Button}"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" /> | ||
<Setter Property="FontSize" Value="14" /> | ||
<Setter Property="Height" Value="32" /> | ||
<Setter Property="Width" Value="46" /> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="Foreground" Value="White" /> | ||
<Setter Property="BorderThickness" Value="0" /> | ||
</Style> | ||
|
||
<Style x:Key="CloseButtonStyle" | ||
BasedOn="{StaticResource TitleBarButtonStyle}" | ||
TargetType="{x:Type Button}"> | ||
<Setter Property="Content" Value="" /> | ||
<!-- Remove the default Button template's Triggers, otherwise they'll override our trigger below. --> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border Background="{TemplateBinding Background}"> | ||
<ContentPresenter HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Button.Background" Value="Red" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</Window.Resources> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid Grid.Row="0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBlock x:Name="TitleBarTitle" | ||
Grid.Column="0" | ||
Padding="10,0" | ||
VerticalAlignment="Center" | ||
Foreground="White"> | ||
GUIConsole | ||
</TextBlock> | ||
<StackPanel x:Name="TitleBarButtons" | ||
Grid.Column="1" | ||
VerticalAlignment="Top" | ||
Orientation="Horizontal"> | ||
<Button x:Name="MinimizeButton" | ||
Click="MinimizeButton_Click" | ||
Content="" | ||
Style="{StaticResource TitleBarButtonStyle}" /> | ||
<Button x:Name="MaximizeRestoreButton" | ||
Click="MaximizeRestoreButton_Click" | ||
Content="" | ||
FontSize="12" | ||
Style="{StaticResource TitleBarButtonStyle}" /> | ||
<Button x:Name="CloseButton" | ||
Click="CloseButton_Click" | ||
FontSize="12" | ||
Style="{StaticResource CloseButtonStyle}" /> | ||
</StackPanel> | ||
</Grid> | ||
<ScrollViewer x:Name="TerminalHistoryViewer" | ||
Grid.Row="1" | ||
ScrollChanged="ScrollViewer_ScrollChanged"> | ||
<TextBlock x:Name="TerminalHistoryBlock" | ||
FontFamily="Consolas" | ||
Foreground="White" | ||
TextWrapping="Wrap" /> | ||
</ScrollViewer> | ||
</Grid> | ||
</Window> |
13 changes: 5 additions & 8 deletions
13
src/cascadia/LocalTests_TerminalApp/TestHostApp/UnitTestApp.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
<Application | ||
x:Class="TestHostApp.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TestHostApp" | ||
RequestedTheme="Dark"> | ||
|
||
</Application> | ||
<Application x:Class="TestHostApp.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TestHostApp" | ||
RequestedTheme="Dark" /> |
Oops, something went wrong.