Skip to content

Formatting fails if a comment contains 'xmlns:' #426

@CorneliusRupertJackson

Description

@CorneliusRupertJackson

Describe the bug
The formatting fails with an error messagebox with the following content:

Error in StylerPackage:

'<', hexadecimal value 0x3C, is an invalid attribute character.
Line 9, position 5.

This occurs when a comment that contains the string "xmlns:" is located above an XAML element anywhere.
The XAML element needs at least one set property (as in x:Name="Button" or Foreground="Black")

To Reproduce
Steps to reproduce the behavior:

  1. Create a new XAML file (ResourceDictionary in the example)
  2. Add some XAML element and a comment containing 'xmlns:' that is located above the element
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!--  Comment that contains 'xmlns:'  -->

    <Style x:Key="SomeStyle" />

</ResourceDictionary>
  1. Select the right-click option "Format XAML"
  2. The error messagebox appears:
    image

Version Info (please complete the following information):

  • OS: Windows 10 Pro (21H2)
  • Visual Studio: VS2022 (17.5.5)
  • XAML Styler: Extension (3.2208.1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions