Skip to content
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

Add option to ignore design-time reference prefix when reordering #306

Closed
mturczyn opened this issue Oct 26, 2020 · 4 comments · Fixed by #309
Closed

Add option to ignore design-time reference prefix when reordering #306

mturczyn opened this issue Oct 26, 2020 · 4 comments · Fixed by #309

Comments

@mturczyn
Copy link
Contributor

mturczyn commented Oct 26, 2020

I recently started using more often design time properties, which requires to include blend namespace:

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

It leads to having "double" properties, such as:

<Label
    d:Content="Hello design world"
    Content="Hello world from runtime" />

Using styler, it separates the two, if there are other properties, which, by default would go between the two.

But I would like to have this behaviour disabled, i.e. properties which differ only by design time namespace, I want them together as much as possible.

It makes easier to read the XAML code, as I see instantly what property is and if it has design time value set.

I forked the repo and I can try to develop this feature. I think it won't be huge thing to carry out.

mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Nov 19, 2020
Xavalon#306
Corrected options descriptions.
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Nov 19, 2020
Xavalon#306
Code cleanup and corrected version in manifest file.
@grochocki
Copy link
Contributor

grochocki commented Nov 25, 2020

Great idea, @mturczyn! Have you considered tying this to the designated design-time reference namespace prefix? I am imagining something like this:

Display Name: "Ignore Design-Time Reference Prefix"
Property: IgnoreDesignTimeReferencePrefix
Category: Attribute Reordering
Description: Defines whether attributes with the design-time reference namespace prefix are ignored when ordering.
Default: false

@mturczyn
Copy link
Contributor Author

mturczyn commented Nov 26, 2020

@grochocki I don't understand "designated design-time reference namespace prefix" part.

My idea which I implemented, is to:

  1. Take namespaces ignnored in ordering from settings (eg. "http://schemas.microsoft.com/expression/blend/2008")
  2. When styling XAML, first scan file to find defined namespaces in file. This way I get the prefixes denoting those ignored namespaces.
  3. When styling, ignore those attributes, which differ only by found prefixes.

I created pull requests, so you can see it in action :)

@grochocki
Copy link
Contributor

@mturczyn I consulted with a few folks and I like what you are doing to leverage the namespace instead of the prefix (since someone could use something other than the standard/default of 'd'), but exposing a free form option feels heavy when there is a limited set of design namespaces. So, we'd like to propose a hybrid between my original suggestion and your implementation where we keep the exposed option a bool, but derive the prefix from the hardcoded namespace. If there are additional design namespaces added in the future, we can update that list.

When styling XAML, first scan file to find defined namespaces in file. This way I get the prefixes denoting those ignored namespaces.

Are two passes strictly necessary? I am wondering if we can optimize this by looking in the root node for the namespaces upfront.

@grochocki grochocki changed the title Grouping properties which differ only by d: namespace (design time properties) Add option to ignore design-time reference prefix when reordering Jan 3, 2021
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 3, 2021
Corrected descriptions of options of XAML Styler.
@mturczyn
Copy link
Contributor Author

mturczyn commented Jan 3, 2021

@grochocki Hi!
I considered your suggestion and implemeneted accordingly :)
Also found one bug with ordering rules and corrected that :)
You can find all this in my pull request.

mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 5, 2021
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 5, 2021
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 5, 2021
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 6, 2021
…ith ingoring design time namespaces option is set to true
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 6, 2021
… time namespaces, when there is no design time namespace specified in XAML
mturczyn pushed a commit to mturczyn/XamlStyler that referenced this issue Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants