Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Summary of the changes

Adds IndentByTwo to AttributeIndentStyle enum, enabling users to indent component attributes by two levels instead of one, visually distinguishing them from child elements.

Changes:

  • Added IndentByTwo enum value to AttributeIndentStyle.cs
  • Updated CSharpFormattingPass.CSharpDocumentGenerator.cs to handle three indent styles using explicit if-else logic
  • Added "Indent by two levels" resource string to VSPackage.resx
  • Extended VS configuration in razor.registration.json to expose the new option
  • Added test coverage in DocumentFormattingTest.cs

Example:

<TheNameOfMyComponent Param1="One"
        Param2="Two"
        Param3="Three">
    <Child1/>
    <Child2/>
</TheNameOfMyComponent>

Attributes indent 2 levels (8 spaces), children indent 1 level (4 spaces).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mobile.events.data.microsoft.com
    • Triggering command: /home/REDACTED/work/razor/razor/.dotnet/dotnet /home/REDACTED/work/razor/razor/.dotnet/dotnet exec --depsfile /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.deps.json --runtimeconfig /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.runtimeconfig.json /home/REDACTED/.nuget/packages/xunit.REDACTED.console/2.9.2/tools/netcoreapp2.0/xunit.console.dll /home/REDACTED/work/razor/razor/artifacts/bin/Microsoft.VisualStudioCode.RazorExtension.Test/Debug/net10.0/Microsoft.VisualStudioCode.RazorExtension.Test.dll -noautoreporters -xml /home/REDACTED/work/razor/razor/artifacts/TestResults/Debug/Microsoft.VisualStudioCode.RazorExtension.Test_net10.0_x64.xml -html /home/REDACTED/work/razor/razor/artifacts/TestResults/Debug/Microsoft.VisualStudioCode.RazorExtension.Test_net10.0_x64.html .VisualStudio.RazorExtension/xlf/VSPackage.de.xlf (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Desired Razor formatting changes</issue_title>
<issue_description>As per this suggestion by @davidwengier this issue is to request the ability to specify how much indentation to use for Blazor component's Parameters in razor markup when they are on a new line.

I like to format my code like this

<TheNameOfMyComponent Param1="One"
        Param2="Two"
        Param2="Three">
    <Child1/>
    <Child2/>
</TheNameOfMyComponent>

Children are indented with 1 tab, and parameters on subsequent lines indented with 2 tabs (to differentiate them from child components).

Could we please have an option to enable us to specify indentation size for parameters on new lines?</issue_description>

<agent_instructions>Add a new attribute indent option for "IndentByTwo" and implement
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 18, 2026 01:33
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Co-authored-by: davidwengier <754264+davidwengier@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new indentation option for Blazor parameters Add IndentByTwo attribute indent style option for Razor formatting Jan 18, 2026
Copilot AI requested a review from davidwengier January 18, 2026 01:54
@davidwengier davidwengier marked this pull request as ready for review January 18, 2026 23:44
@davidwengier davidwengier requested a review from a team as a code owner January 18, 2026 23:44
@davidwengier davidwengier requested a review from a team January 18, 2026 23:53
if (_attributeIndentStyle == AttributeIndentStyle.AlignWithFirst)
if (_attributeIndentStyle == AttributeIndentStyle.IndentByOne)
{
// Indent attributes by one level to differentiate them from child elements.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to differentiate them from child elements.

comment needs updating

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@davidwengier davidwengier merged commit 56e0aaa into main Jan 21, 2026
10 checks passed
@davidwengier davidwengier deleted the copilot/add-indent-option-for-parameters branch January 21, 2026 02:44
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 21, 2026
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.

Desired Razor formatting changes

3 participants