Skip to content

Conversation

@Koichi-Kobayashi
Copy link

@Koichi-Kobayashi Koichi-Kobayashi commented Jan 4, 2026

Description:

Inserted line breaks between the opening and closing comment tags.

2026-01-04_19h37_49

Summary

Adds TreatCommentWithTagAsMultiline option to format comments starting with XML tags as multiline, ensuring --> is placed on a new line.

Changes

  • New option TreatCommentWithTagAsMultiline (default: false)
  • Modified CommentDocumentProcessor to handle comments starting with < after <!--
  • Added unit tests for both enabled and disabled scenarios

Details

  • Before
<Root>
  <!--
  <copyright>
    etc etc
  </copyright>
  -->
  <!--<copyright>
    etc etc
  </copyright>-->
  <!--  regular comment  -->
  <!--
    multiline comment
    without tags
  -->
  <Window x:Class="Test.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:system="clr-namespace:System;assembly=mscorlib"
                  Title="{Binding Title}"
    Height="350" Width="525" Padding="3,2 ">
    <Window.Resources>
      <Style TargetType="TextBox">
        <Setter Property="Text" Value="Default Text &amp;&lt;" />
        <Style.Triggers>
          <Trigger Property="IsEnabled" Value="false">
			<!--
            <Setter Property="Margin" Value=" 2" />
			-->
            <!--<Setter Property="Padding" Value=" 2,4 " />-->
            <!--<Setter Property="Padding"
                        Value=" 2,4 " />-->
            <!--<Setter 
                    Property="Padding"
                    Value=" 2,4 " />-->
		  </Trigger>
        </Style.Triggers>
      </Style>
    </Window.Resources>
    <DockPanel Grid.Row="0" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="1" Width="Auto" Height="Auto" Margin="0,0,0,0"
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
      <StackPanel>
        <!--<TextBox Margin="4"></TextBox>-->
        <TextBox Margin="1 2 3 4"></TextBox>
        <!--<Image
            Width="20" Height="20" Margin="4,0,12,0" VerticalAlignment="Center" RenderOptions.BitmapScalingMode="HighQuality"
            Source="{Binding FullPath, Converter={StaticResource FileIconConverter}, Mode=OneWay}" />-->
      </StackPanel>
    </DockPanel>
  </Window>
</Root>
  • After
<Root>
  <!--
  <copyright>
    etc etc
  </copyright>
  -->
  <!--
  <copyright>
    etc etc
  </copyright>
  -->
  <!--  regular comment  -->
  <!--
    multiline comment
    without tags
  -->
  <Window x:Class="Test.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:system="clr-namespace:System;assembly=mscorlib"
          xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
          Title="{Binding Title}"
          Width="525"
          Height="350"
          Padding="3,2 ">
    <Window.Resources>
      <Style TargetType="TextBox">
        <Setter Property="Text" Value="Default Text &amp;&lt;" />
        <Style.Triggers>
          <Trigger Property="IsEnabled" Value="false">
            <!--
            <Setter Property="Margin" Value=" 2" />
            -->
            <!--
            <Setter Property="Padding" Value=" 2,4 " />
            -->
            <!--
            <Setter Property="Padding"
                    Value=" 2,4 " />
            -->
            <!--
            <Setter Property="Padding"
                    Value=" 2,4 " />
            -->
          </Trigger>
        </Style.Triggers>
      </Style>
    </Window.Resources>
    <DockPanel Grid.Row="0"
               Grid.RowSpan="1"
               Grid.Column="0"
               Grid.ColumnSpan="1"
               Width="Auto"
               Height="Auto"
               Margin="0,0,0,0"
               HorizontalAlignment="Stretch"
               VerticalAlignment="Stretch">
      <StackPanel>
        <!--
        <TextBox Margin="4"></TextBox>
        -->
        <TextBox Margin="1 2 3 4" />
        <!--
        <Image Width="20"
               Height="20"
               Margin="4,0,12,0"
               VerticalAlignment="Center"
               RenderOptions.BitmapScalingMode="HighQuality"
               Source="{Binding FullPath, Converter={StaticResource FileIconConverter}, Mode=OneWay}" />
        -->
      </StackPanel>
    </DockPanel>
  </Window>
</Root>

Backward Compatibility

Defaults to false to preserve existing behavior.

Fixes #380

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested my changes by running the extension in VS2017
  • I have tested my changes by running the extension in VS2019
  • I have tested my changes by running the extension in VS2022
  • I have tested my changes by running the extension in VS2026
  • If changes to the documentation are needed, I have noted this in the description above

)

Add new option `TreatCommentWithTagAsMultiline` that when enabled,
treats XAML comments starting with '<' after '<!--' as multiline
comments, ensuring '-->' appears on a new line.
- Add TestTreatCommentWithTagAsMultiline test method with true/false cases
- Add test files: TestTreatCommentWithTagAsMultiline.testxaml
- Add expected output files for both true and false scenarios
- Test covers comments starting with XML tags after <!-- delimiter
- Verify that --> closing tag is placed on a new line when option is enabled
@Koichi-Kobayashi Koichi-Kobayashi marked this pull request as draft January 5, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for empty lines above and below multiline comments

1 participant