Code Monkey home page Code Monkey logo

xamlstyler's Introduction

XAML Styler

XAML Styler is a visual studio extension that formats XAML source code based on a set of styling rules. This tool can help you/your team maintain a better XAML coding style as well as a much better XAML readability.

Documentation Script Integration Release Notes Contributing

Build Status

Downloads

VS2022

VS2019

JetBrains IntelliJ Plugins

NuGet
View other downloads

Getting Started

Right-click with any file and select "Format XAML" to format your XAML source code.

Context Menu

Join the chat at https://gitter.im/Xavalon/XamlStyler

xamlstyler's People

Contributors

bang0123 avatar bartlannoeye avatar dependabot[bot] avatar ferpegaplain avatar freza-tm avatar grochocki avatar jyn-stago avatar kevindockx avatar lsaudon avatar lysannschlegel avatar maartenba avatar matfillion avatar michael-hawker avatar mrlacey avatar mturczyn avatar nicovermeir avatar pedrolamas avatar polarbeardk avatar randomengy avatar renao avatar saratsin avatar scottisafool avatar sdebruyn avatar sokofromnz avatar tmatz avatar tyrrrz avatar urbancmc avatar xiaotiannetlift avatar yoshihiroito avatar zachdean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xamlstyler's Issues

Feature Request: Project Local Settings

Have XamlStyler look in the root of the project for a .xamlStylerSettings file. If present, these settings would override the default settings.

This would allow consistent styling rules across an entire team for a project when this file is checked in to version control. It also allows different rules for different teams when working on multiple projects with different coding styles.

XamlStyler does not show on right click

I install XamlStyler 2.2 on VS 2015 and its work fine.
Then it stop to show in the context menu when I right click on a Xaml file.
I uninstall and re install and still cen not get it to show on the right click context menu.
Any clue to this bug?
Thanks
Eliezer Kaplansky

Visual Studio 2017 RC not detected by new Installer

My Visual Studio 2017 RC is installed here:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE

2017-01-11 10_17_39-new issue xavalon_xamlstyler

1/11/2017 10:12:18 AM - Microsoft VSIX Installer
1/11/2017 10:12:18 AM - -------------------------------------------
1/11/2017 10:12:18 AM - Initializing Install...
1/11/2017 10:12:18 AM - Extension Details...
1/11/2017 10:12:18 AM - Identifier : a224be3c-88d1-4a57-9804-181dbef68021
1/11/2017 10:12:18 AM - Name : XAML Styler 3
1/11/2017 10:12:18 AM - Author : Xavalon
1/11/2017 10:12:18 AM - Version : 3.0
1/11/2017 10:12:18 AM - Description : XAML Styler is a visual studio extension, which formats XAML source code by sorting the attributes based on their importance. This tool can help you/your team maintain a better XAML coding style as well as a much better XAML readability.
1/11/2017 10:12:18 AM - Locale : en-US
1/11/2017 10:12:18 AM - MoreInfoURL : https://github.com/Xavalon/XamlStyler/
1/11/2017 10:12:18 AM - InstalledByMSI : False
1/11/2017 10:12:18 AM - SupportedFrameworkVersionRange : [0.0,2147483647.2147483647]
1/11/2017 10:12:18 AM -
1/11/2017 10:12:18 AM - SignatureState : Unsigned
1/11/2017 10:12:18 AM - Supported Products :
1/11/2017 10:12:18 AM - Microsoft.VisualStudio.Pro
1/11/2017 10:12:18 AM - Version : [15.0,16.0)
1/11/2017 10:12:18 AM - Microsoft.VisualStudio.Enterprise
1/11/2017 10:12:18 AM - Version : [15.0,16.0)
1/11/2017 10:12:18 AM - Microsoft.VisualStudio.Community
1/11/2017 10:12:18 AM - Version : [15.0,16.0)
1/11/2017 10:12:18 AM -
1/11/2017 10:12:18 AM - References :
1/11/2017 10:12:18 AM - -------------------------------------------------------
1/11/2017 10:12:18 AM - Identifier : Microsoft.VisualStudio.MPF.15.0
1/11/2017 10:12:18 AM - Name : Visual Studio MPF 15.0
1/11/2017 10:12:18 AM - Version : [15.0]
1/11/2017 10:12:18 AM - MoreInfoURL :
1/11/2017 10:12:18 AM - Nested : No
1/11/2017 10:12:18 AM -
1/11/2017 10:12:18 AM - Signature Details...
1/11/2017 10:12:18 AM - Extension is not signed.
1/11/2017 10:12:18 AM -
1/11/2017 10:12:18 AM - Searching for applicable products...
1/11/2017 10:12:18 AM - Found installed product - Microsoft Visual Studio Enterprise 2015
1/11/2017 10:12:18 AM - Found installed product - Microsoft Visual Studio Professional 2015
1/11/2017 10:12:18 AM - Found installed product - Microsoft Visual Studio Community 2015
1/11/2017 10:12:18 AM - Found installed product - Microsoft Visual Studio 2015 Shell (Integrated)
1/11/2017 10:12:18 AM - Found installed product - Global Location
1/11/2017 10:12:18 AM - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
at VSIXInstaller.App.InitializeInstall(Boolean isRepairSupported)
at VSIXInstaller.App.InitializeInstall()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Add ordering rule group setting for property elements and content properties

From @punker76: It would be nice to have Element Ordering Rule Groups like Attribute Ordering Rule Groups e.g. to group style Setters in the same way.

I know, there is already a setting to reorder Setters, but not to (pre)group this like the attribute ordering does. e.g. I would prefer putting Template setters (Template, HeaderTemplate, ContentTemplate...) to the end of a style...

Should also order Style Setters.

Resources:

Settings per project / sln

When working in a team shared formatting rules that can be put in version control with the code would be nice.

I'm thinking something like

Foo.sln
Foo.sln.xamlstyle
  Bar.csproj
  Bar.csproj.xamlstyle

Add option to convert ObjectAnimationUsingKeyFrame to Setters

Visual State Manager Setters were introduced for UWPs in Windows 10:

If you are going to use animation to change the state you can continue to use old approach with Storyboard but in many cases animation is not needed. For example if you want to change your layout because user changed screen orientation, you need to change properties of controls very quickly. So, developers usually used ObjectAnimationUsingKeyFrame in order to make all needed changes in 0 seconds:

<Storyboard>
 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
 <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
 </ObjectAnimationUsingKeyFrames>
</Storyboard>

You can see that this approach is not optimal because it requires using several complex objects with many parameters to make the simple thing. That’s why a new XAML element called Setter can be very useful. For example, you can rewrite the same thing using the Setter element:

<VisualState.Setters>
 <Setter Target="comboBox.Visibility" Value="Collapsed"></Setter>
</VisualState.Setters>

It’s much clearer. Developers need to declare a property’s name and a new value in the selected state.

Adding an option to optionally convert ObjectAnimationUsingKeyFrames to Setters would greatly clean up Visual State Manager code.

Port Fix: Wildcards broken after "*:*, *" attribute ordering rule group.

For example, if options are configured as below:

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
Style, Background, Foreground, Fill, BorderBrush, BorderThickness, Stroke, StrokeThickness, Opacity
FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch
*:*, *
AutomationProperties.*
PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint
mc:Ignorable, d:*

AutomationProperties.* is not respected.

XAML Magic Feature Commit

Format XAML error "&lt;" "&gt;" (version 2.1)

Formating XAML code causes errors

Original XAML code:

<MultiDataTrigger.Conditions> <Condition Binding="{Binding Failed, Converter={StaticResource NumericEqualityToBoolConverter}, ConverterParameter='&lt;'}" Value="True" /> <Condition Binding="{Binding Items.Count, Converter={StaticResource NumericEqualityToBoolConverter}, ConverterParameter='&gt;'}" Value="True" /> </MultiDataTrigger.Conditions>

Formated XAML code (ConverterParameter):

<MultiDataTrigger.Conditions> <Condition Binding="{Binding Failed, Converter={StaticResource NumericEqualityToBoolConverter}, ConverterParameter='<'}" Value="True" /> <Condition Binding="{Binding Items.Count, Converter={StaticResource NumericEqualityToBoolConverter}, ConverterParameter='>'}" Value="True" /> </MultiDataTrigger.Conditions>

Xamarin From XAML

can't format Xamarin Forms XAML File. XAML Styler is not available. #

Attribute identation is broken if using tabs

Attributes are idented with tabs instead of spaces if using keep tabs option in version 2.1 (installed via VS' Extensions and Updates).
In previous version (2.0) attribute identation (relative to tag) was done with spaces.
This behavior is much more preferable.

Console ignores config file if solution file exists

If I use the console app and pass in the location of a config file as one of the command line parameters, the app will still search through the xaml file's parent directories to find one, and if it does, use that instead.

VS2017

I remember when going from 2013 to 2015 it was just a matter of some flag or value needing to be set saying the VSIX was 2015 friendly. Any chance its the same case here? I'd love to use this in the new VS2017

Add ability to easily generate a JSON configuration

Per discussion in #59.

A lightweight web-based or WPF tool to easily generate JSON configurations. The benefits of a WPF tool would be that it could take a dependency on XamlStyler.Core and can be released with each version of XamlStyler (i.e., so you use the correct configuration generator for the release you are on).

Alternatively, per #165, generation could occur from within VS, though it is unknown if this is possible.

Error while formatting a file which has a name containing ":"

Hello,

I recently got this error when trying to format a XAML file I have.

image

I think, this is due to the fact that I'm referencing another assembly in my file (that is in the namespace "utils"). When a property of this assembly is changed inside a setter I call the property using "utils:ClassOfAssembly.PropertyName".
When commenting the setter that uses "utils:..", the formatting worked just fine! But when the setter is uncommented, I get the error message shown previously.

Thank you!

Is it possible to use $(SolutionDir) when setting up the external config file?

Hello,

I'm trying to use XAML Styler with my team and we would like to use the same external config file that would be in our repo. We didn't clone our repos in the same directory on our computers so it is impossible for use to use an absolute path. Is it possible to use $(SolutionDir) when setting up the external config file?

Thank you very much!

Option to remove design-time references

From @kgallaha: This is a feature request to simply remove any design-time references from one or more XAML files.

Some developers disable the VS Designer for some or all of their projects and don't use Blend so they have no need for these references. The default VS templates still include several of these references in new files so they'll likely be spread throughout a project.

The ability to quickly remove the references during the normal cleanup process or as a separate command would be nice.

Examples include:

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"

Add support for ignoring portions of code when formatting based on special region designator

From @xlsupport in #9

I've had an issue with an ultra long Figures attribute in a PathGeometry, where I must keep the linebreaks. (it's a very long string qnd the highlighter goes bananas if it's flattened) I only want this block of lines ignored, but now I had to turn off the SaveOnExit which is a shame for all my other stuff.

It could be done using comment "blocks" similar to the "XAML Regions" extension.

Need common settings across VS and Blend

XAML Styler doesn't share config across VS and Blend. I have to set the same thing twice in two different places. Caused some problems until I figured it out.

Inappropriately converting "&amp;" to "&"

XAML styler v2.1 is converting "&" to "&". There's no setting that seems to indicate XAML styler should be doing this, and it's causing problems because it produces invalid XAML. Here's the full example that fails for me:

Content="{Binding ViewModel.Procedure.InLiveEnvironment, Converter={cui:BooleanToObjectConverter TrueValue='OK', FalseValue='Save &amp; Close'}}"

gets converted to

Content="{Binding ViewModel.Procedure.InLiveEnvironment, Converter={cui:BooleanToObjectConverter TrueValue='OK', FalseValue='Save & Close'}}"

WPF Hyperlink format wrong

I have a textblock like this:

            <TextBlock>
                <Run /><Hyperlink><Run /></Hyperlink><Run /></TextBlock>

but after I use xaml styler format my xaml code.

            <TextBlock>
                <Run />
                <Hyperlink><Run /></Hyperlink><Run /></TextBlock>

Hyperlink is placed to a new line. It will display a space which I don't need.

Attribute Ordering Rule Groups aren't being applied

I may be missing something here, but it doesn't appear that the groups for attribute reordering are being applied. One of the defaults is to group things like Grid.Row and Grid.Column, but this isn't happening when I run XAML Styler on a xaml document. I've attached a screenshot of how my options are currently set up in case I've done something stupid and disabled the attribute groups somehow.

xaml styler options

Error formating Style

I have a style in a dictionary with this Setter :
Setter Property="telerik:StyleManager.Theme" Value="Windows8"

It makes XamlStyler crash

xamlstylererror

XAML Styler deletes {BOM}

Copying @bschoepke's issue from retired XAML Magic repo for investigation:

  1. Create a UserControl with VS2015 Update 2.
  2. Run XAML Magic on it with default config.

[Observed]
3. {BOM} is removed from beginning of file (byte order mark)

[Expected]
3. {BOM} is not removed.

Still seems to build and run fine but it would be safer not to mess with {BOM}.

Setting to disable when there is no config file

Some of the projects I'm working are using XamlStyler while others are not (and introducing it is not possible due to political reasons). It would be nice to have a setting that I can disable XamlStyler by default if there is no external config file available. This way I can support both type of solutions on the same dev machine without too much trouble.

Inline comments get moved to line below rather than line above

Copying @bschoepke's issue from retired XAML Magic repo for investigation:

Example:


<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" /> <!-- Hamburger button -->
    <RowDefinition Height="*" /> <!-- Nav pane -->
  </Grid.RowDefinitions>
</Grid>

Observed output:


<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" /> 
    <!-- Hamburger button -->
    <RowDefinition Height="*" /> 
    <!-- Nav pane -->
  </Grid.RowDefinitions>
</Grid>

Expected output:


<Grid>
  <Grid.RowDefinitions>
    <!-- Hamburger button -->
    <RowDefinition Height="Auto" /> 
    <!-- Nav pane -->
    <RowDefinition Height="*" /> 
  </Grid.RowDefinitions>
</Grid>

Or alternatively, it might be nice to have an option to not touch inline comments at all.

Config:

{
    "AttributesTolerance": 1,
    "KeepFirstAttributeOnSameLine": true,
    "MaxAttributeCharatersPerLine": 0,
    "MaxAttributesPerLine": 1,
    "NewlineExemptionElements": "DataTemplate, SolidColorBrush, StaticResource, RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter, Style, ControlTemplate, VisualTransition, FadeOutThemeAnimation, ObjectAnimationUsingKeyFrames, DiscreteObjectKeyFrame, DoubleAnimationUsingKeyFrames, DiscreteDoubleKeyFrame, EasingDoubleKeyFrame, LinearDoubleKeyFrame, SplineDoubleKeyFrame, PointAnimationUsingKeyFrames, DiscretePointKeyFrame, EasingPointKeyFrame, LinearPointKeyFrame, SplinePointKeyFrame, ColorAnimationUsingKeyFrames, DiscreteColorKeyFrame, EasingColorKeyFrame, LinearColorKeyFrame, SplineColorKeyFrame",
    "SeparateByGroups": 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",
        "Style, Background, Foreground, Fill, BorderBrush, BorderThickness, Stroke, StrokeThickness, Opacity",
        "FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch",
        "*:*, *",
        "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
        "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText"
    ],
    "FirstLineAttributes" : "",
    "OrderAttributesByName": true,
    "PutEndingBracketOnNewLine": false,
    "RemoveEndingTagOfEmptyElement": true,
    "SpaceBeforeClosingSlash": true,
    "RootElementLineBreakRule": 0,
    "ReorderVSM": 0,
    "ReorderGridChildren": false,
    "ReorderCanvasChildren": false,
    "ReorderSetters": 0,
    "FormatMarkupExtension": false,
    "NoNewLineMarkupExtensions": "x:Bind, Binding",
    "ThicknessSeparator": 2,
    "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin",
    "FormatOnSave": true,
    "CommentPadding": 1
}

Attribute ordering rule groups does not save

By editing the default attribute ordering rule groups,
settings do not remain after visual studio is restarted.
Reproduce:
Switch rule 4 with rule 5.
Restart VS.
Now its reset to default

Are External Configurations in options handled as you would expect?

There was an interesting conversation that was started in #46 about how we handle External Configurations in Tools → Options → XAML Styler that we wanted to pull out as to discuss more broadly.

Current Behavior:

  • Specifying an External Configuration overwrites user settings
  • Originally intended to be a global override used by companies/organizations/teams as a distribution mechanism, where personal preferences influence team guidelines
  • Can also be used as an alternate importing mechanism
  • Makes it clear what ruleset is being applied (just open options)
  • Only friendly-view of an external configuration (e.g., enums are difficult to parse to a user unfamiliar with the code by looking at a raw configuration)

Proposed Changed Behavior:

  • Specifying an External Configuration is strictly a runtime override of user settings
  • Removing an External Configuration will revert back to user settings, preventing individual preferences from ever being lost
  • Can make it clear that an external configuration is being applied by displaying a warning in options instead of showing the values that are being applied
  • Lose alternate importing mechanism and friendly-view of external configuration, but potentially more consistent with tools like StyleCop

Is the current behavior confusing? Which behavior is preferred? Are there scenarios that one behavior can handle better than the other?

Add/Update Settings Documentation

There are a number of settings names and descriptions in options that are not clear. Additionally, documentation should be added to provide more information on the effects of each option, including conflicts that may arise when setting conflicting options.

Option for column limit

From @kgallaha: I'd like a Hard Column Limit added to the Attribute Formatting section. It would usually be set to 80 - 120 which represents the limits typically set when formatting C#.

This limit would force attributes to be broken onto separate lines (assuming they were originally within an attribute tolerance >1), followed by enforcement of the Max Attributes Per Line rule. This would prevent attributes from trailing off the visible area of editors (thus requiring horizontal scrolling) while still allowing for an attribute tolerance greater than 1 (in the event there are several short attributes which could fit within the column limit).

Since the Characters Per Line limit doesn't include indentation and requires Max Attributes Per Line >1 it serves a different (somewhat niche) purpose. It doesn't prevent code from trailing off the screen and requires you to set the Max Attributes Per Line at 2 or more.

My main desire for XAML elements is to have them reside on a single line until they leave the visible area (break a column limit) in which case I want all of the attributes on separate lines.

In the event one attribute breaks the column limit then I wouldn't worry about trying to introduce any line breaks inside of it - I imagine this could get messy very quickly. This is the simple solution and would be the least confusing to users as a single setting.

If you'd like to include a checkbox to wrap long attributes as well then I imagine someone might appreciate it. I don't know how much extra work would go into that (considering all the edge cases) and would be plenty happy with just to first option. It would be further complicated if someone wanted splitting on commas and/or spaces.

Exported settings vs Expected external settings

Currently, there seems to be a massive disconnect between the settings that are exported from VS, and the external configuration file that the plugin expects.

  • For a start, VS exports the settings in XML, yet the external config file expects JSON.
  • The settings that are exported, don't match what's expected. For example, AttributeIndentationStyle exports as "spaces", external config file expects 2.
  • AttributeOrderingRuleGroups exported as a literal dump of the attributes, expected is a list of the different rows.

Is there another way to export this? Or do I have to a) manually create this file and put all the settings in, and b) go through the code to find the corresponding enum values for some of the settings?

Format Selection

It would be great if I could use this for selected blocks of XAML instead of the whole file.
We have some custom stuff in our XAML and don't want the formatter to look at that. The VS formatter has support for format selection so it would be cool to have that for XamlStyler!

Attached Property in Style

Hello,

When I used an attached property in the Setter.Property I've an error.

<Style> <Setter Property="local:MyBehavior.IsEnabled" Value="True" /> </Style>

In this case the error is :

The ':' character, hexadecimal value 0x3A, cannot be included in a name.

Enhance XXXAnimation tag format

I try to format my xaml code, and I think the result is not good.
before:

<Storyboard>
    <DoubleAnimation Storyboard.Target="MyImage"
                     Storyboard.TargetProperty="Opacity"
                     From="0"
                     To="1"
                     Duration="0:0:0.3">
    </DoubleAnimation>
</Storyboard>

after:

<Storyboard>
    <DoubleAnimation Duration="0:0:0.3"
                     From="0"
                     Storyboard.Target="MyImage"
                     Storyboard.TargetProperty="Opacity"
                     To="1" />
</Storyboard>

I think let Storyboard attached property at first will be better.

Proposed changes to default settings

We are considering changing some of the default settings for XamlStyler and wanted to solicit feedback from the community. The changes are summarized below and would only affect new users, since existing users settings will restore properly on launch.

Position first attribute on same line as start tag
Current Default:True
Proposed Default: False
Reasoning: Width considerations. It is common for teams/projects to have column limits. This would allow more XAML to more cleanly fit on a line before hitting that limit.

Reorder Canvas panel children by left/top/right/bottom
Current Default: True
Proposed Default: False
Reasoning: Ordering of children in a canvas matters. True by default will break some XAML that depends on this.

Reorder Grid panel children by row/column
Current Default: True
Proposed Default: False
Reasoning: Ordering of children in a grid matters. True by default will break some XAML that depends on this.

Keep markup extensions of these types on one line
Current Default: x:Bind
Proposed Default: x:Bind, Binding
Reasoning: Bindings should be treated the same as x:Bind.

Thickness style
Default: None
Proposed Default: Comma
Reasoning: This is consistent with XAML coming out of MS (samples, generic.xaml, etc.).

Attribute Ordering Rule Group
"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",
"Style, Background, Foreground, Fill, BorderBrush, BorderThickness, Stroke, StrokeThickness, Opacity",
"FontFamily, FontSize, LineHeight, FontWeight, FontStyle, FontStretch",
"
:_, *",
"PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint",
"mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText"

Markup extension formatting does work as expected when nested

Supposed you have two markup extensions, {Binding} and {LogicalAnd}.
In your Xaml Styler settings {Binding} is set to be kept on a single line.

If you format the given XAML, the result would be this:

<TextBox Text="Some Value"
         IsEnabled="{LogicalAnd {Binding IsWritable},
                                {Binding ElementName=CheckBox,
                                         Path=IsChecked}}" />

But the correct format would be:


<TextBox Text="Some Value"
         IsEnabled="{LogicalAnd {Binding IsWritable},
                                {Binding ElementName=CheckBox, Path=IsChecked}}" />

since {Binding} should be on a single line even if it is nested.

Currently the most outer markup extension defines the format for the whole attribute value.

This issue is fixed with: #33

Document setting IndentSize for Console Exe?

First of all, props on a great tool, really helping our team to standardize property ordering. 👍

Because we were making whole sale changes to all of our project's XAML files, I decided to run a batch file to process all the XAML files at once. Which I'll detail below for anyone else that needs to do this. 😄

An edge case issue I ran into was we use 4 space indentations in our XAML, so while this works fine in the VS Extension since you can read that value prior to saving. The console application defaults to 2 space indentation (no VS to read the setting from).

So in the end I cloned the repository and discovered that there is a JSON property IndentSize which I can set manually, specifically to support the console app. Which I did and resolves my problem.

Be happy to make a pull request to the Wiki if that'll be helpful.

Thanks,
Bill

Steps to Run XAML Styler on all project files (on Win Machine)

  • Run on a command prompt: dir /S /B *.xaml > allxaml.bat
  • Modify the batch file and insert the xstyler.exe call with a format like so:
    .\xstyler.exe -f "abc.xaml"
  • Execute the batch file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.