dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
489 stars 190 forks source link

Object initializer block indented one more level that in plain .cs file #7933

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


There is very often wrong automatic indentation in C# code in razor files. If I open up an initializer like so :

AFunction(new Something()
{
    Wow = "amazing"
});

It very often ends up that way :

AFunction(new Something()
    {
        Wow = "amazing"
    });

This only happens in razor files.


Original Comments

Feedback Bot on 14/11/2022, 06:02 PM:

(private comment, text removed)


Original Solutions

(no solutions)

davidwengier commented 1 year ago

Note: The formatting issue here is a difference between Roslyn and Razor, but it is worth noting it is stable, unlike previous issues in this area, where repeated formats would cause constant changes.

KieranDevvs commented 1 year ago

This is a massive pain for me as I use automatic formatting when typing. I have to disable it but it then means I cant use the feature within other language files eg .cs

DM-98 commented 9 months ago

It's been over a year. Shouldn't it be easy to fix this issue?

davidwengier commented 9 months ago

If it was easy, I would have fixed it, I promise!