XAML STYLER as a Git-Hook
Issue type
enhancement
Which version of the app?
WinUI 3 Gallery
Description
https://github.com/Xavalon/XamlStyler/wiki/Git-Hook
Additional context
- Do we need a Settings.XamlStyler file? If yes, which settings would be different?
### Tasks
- [ ] ❔ Settings.XamlStyler file
- [ ] prepare <elements> with `space=preserve`
- [ ] let XamlStyler do its magic* 🪄
- [ ] check content of <elements> ... think manual line endings and LineBreaks 🕵🏻♂️
[!NOTE] Need to set
xml:space="preserve"in elements first, in order to prevent the following: In a paragraph of text, a <Hyperlink> or a <Bold> will be stripped of a preceding space. By contrast, a period following a </Hyperlink> or a </Bold> wil be placed on a new line. This will insert a [space] in the UI.
- https://github.com/Xavalon/XamlStyler/wiki/Getting-Started#whitespace
- Q&A https://github.com/Xavalon/XamlStyler/issues/454
I can do this 😇
@chingucoding or @karkarl any thoughts?
Thanks so much for tackling this @Jay-o-Way! As you know already cleaning up the XAML is in the backlog as part of the efforts to clean up the codebase.
I like the idea of a Settings.XamlStyler file should we have future customizations, and so it's easier to reference implemented rules.
Thanks for the positive comment @karkarl :) Imma need a bit more specific answers to adress this, mainly the choice between a one-time (manual) execution or the workflow solution. (easy versus not-so-easy, resp.)
Sorry for hoping on this topic so late, I think if we don't do it as part of the CI or a git hook (if that is an option), slowly this would diverge again. I think having a config for this is also necessary to avoid mixed formatting based on who is doing it.
The issue you linked though is a bit worrysome, is there a way to work around that formatting of text?
I think having a config for this is also necessary to avoid mixed formatting based on who is doing it.
If it's done via a central hook, this is a non-issue, because the changes are not made by people. :) Default settings should be fine (to start with)
is there a way to work around that formatting of text?
You mean the unintended changes with spaces? I believe setting the space=preserve is the solution. I adressed this in issue https://github.com/Xavalon/XamlStyler/issues/454
@niels9001 Currently, there are a lot of RichTextBlock + Paragraph constructions. Mostly used for formatting text and including Hyperlinks. Adjusting them to add space=preserve, is a huge p.i.t.a. and the resulting xaml is not pretty. Because text needs to be on one line.
I think it would be a lot more efficient - and pretty - to use a MarkdownTextblock. Even though rewriting the code is a lot of work too... ⚖️ wdyt?
(totally random example)
<RichTextBlock xml:space="preserve">
<Paragraph>To use the keyboard with a control, the control must have focus. The most common way to receive focus is via <Bold>Tab navigation</Bold>, which cycles through controls that are <Bold>tab stops</Bold>. The order of these tab stops is called the <Bold>tab order</Bold>.</Paragraph>
<Paragraph>All interactive controls, like buttons, should be tab stops (unless they are in a group that's accessible in some other way), but non-interactive controls, like labels, should not. Try to put initial focus on the most useful or logical element.</Paragraph>
<Paragraph>See <Hyperlink NavigateUri="https://learn.microsoft.com/windows/apps/design/input/keyboard-interactions">Keyboard interactions</Hyperlink> and <Hyperlink NavigateUri="https://learn.microsoft.com/windows/apps/design/accessibility/keyboard-accessibility">Keyboard accessibility</Hyperlink>.</Paragraph>
</RichTextBlock>
Also, cases like the following might be too much XAML for simple text
<RichTextBlock
x:Name="ErrorTextBlock"
Grid.Row="1"
Margin="0,0,0,12"
Foreground="{ThemeResource SystemFillColorCriticalBrush}"
IsTextSelectionEnabled="True"
Visibility="Collapsed">
<Paragraph xml:space="preserve">
This sample requires a later version of Windows to be fully functional.
</Paragraph>
</RichTextBlock>
Linking this to this task in backlog #1279
Alternatively, we could add XAML Styler to .vsconfig?
Example of pr: https://github.com/files-community/Files/pull/15115