Formatting of Razor code in Blazor app is not consistent
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 737
- Avg merge
- 17h 56m
- Merged PRs (30d)
- 21
Description
## Issue Description ##
Formatting of Blazor razor code is very inconsistent. Look at the strings in the screenshot below. Why is every other work colored differently? Why is the formatting as it is (not indented)?
Also lots and lots of errors in the OmniSharp and Razor logs.

## Steps to Reproduce ##
Paste the code below in a new Blazor app. Try and format the code.
```
public record Round(int RoundId, string Name);
IQueryable Rounds = new[]
{
new Round(1, "First Second Third Fourth Fifth"),
new Round(2, "First Second Third Fourth Fifth"),
new Round(3, "First Second Third Fourth Fifth"),
new Round(4, "First Second Third Fourth Fifth"),
new Round(5, "First Second Third Fourth Fifth"),
new Round(6, "First Second Third Fourth Fifth"),
}.AsQueryable();
```
## Expected Behavior ##
Correct formatting
## Actual Behavior ##
Bad formatting
## Logs ##
### OmniSharp log ###
Starting OmniSharp server at 6/25/2022, 10:23:41 PM
Target: /Users/john/Developer/DotNet/BlazorApp
OmniSharp server started with .NET 6.0.301
.
Path: /Users/john/.vscode-insiders/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 23305
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.301 17.2.0 - "/usr/local/share/dotnet/sdk/6.0.301/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/john/Developer/DotNet/BlazorApp/BlazorApp.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/john/Developer/DotNet/BlazorApp/BlazorApp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/john/Developer/DotNet/BlazorApp'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/john/Developer/DotNet/BlazorApp' on host 23257.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/john/Developer/DotNet/BlazorApp/BlazorApp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/john/Developer/DotNet/BlazorApp/BlazorApp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/john/Developer/DotNet/BlazorApp/BlazorApp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: BlazorApp
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 16.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/getcodeactions but could not find request.
[warn]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 161,
"Command": "/close",
"Arguments": {
"FileName": "/Users/john/Developer/DotNet/BlazorApp/_Imports.razor__virtual.cs"
}
}
[fail]: OmniSharp.Stdio.Host
************ Response (12.8701ms) ************
{
"Request_seq": 161,
"Command": "/close",
"Running": true,
"Success": false,
"Message": "\"System.ArgumentException: '_Imports.razor__bg__virtual.cs' is not open.\\n at Microsoft.CodeAnalysis.Workspace.CheckDocumentIsOpen(DocumentId documentId)\\n at Microsoft.CodeAnalysis.Workspace.OnDocumentClosed(DocumentId documentId, TextLoader reloader, Boolean updateActiveContext)\\n at OmniSharp.OmniSharpWorkspace.CloseDocument(DocumentId documentId) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs:line 106\\n at OmniSharp.Roslyn.CSharp.Services.Files.FileCloseService.Handle(FileCloseRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Files/FileCloseService.cs:line 25\\n at OmniSharp.Endpoint.EndpointHandler`2.AggregateResponsesFromLanguageHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 191\\n at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
"Body": null,
"Seq": 238,
"Type": "response"
}
[warn]: OmniSharp.Stdio.Host
************ Request ************
{
"Type": "request",
"Seq": 247,
"Command": "/close",
"Arguments": {
"FileName": "/Users/john/Developer/DotNet/BlazorApp/Pages/Index.razor__virtual.cs"
}
}
[fail]: OmniSharp.Stdio.Host
************ Response (0.9248ms) ************
{
"Request_seq": 247,
"Command": "/close",
"Running": true,
"Success": false,
"Message": "\"System.ArgumentException: '' is not part of the workspace.\\n at Microsoft.CodeAnalysis.Workspace.CheckDocumentIsInCurrentSolution(DocumentId documentId)\\n at Microsoft.CodeAnalysis.Workspace.OnDocumentClosed(DocumentId documentId, TextLoader reloader, Boolean updateActiveContext)\\n at OmniSharp.OmniSharpWorkspace.CloseDocument(DocumentId documentId) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs:line 106\\n at OmniSharp.Roslyn.CSharp.Services.Files.FileCloseService.Handle(FileCloseRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Files/FileCloseService.cs:line 25\\n at OmniSharp.Endpoint.EndpointHandler`2.AggregateResponsesFromLanguageHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 191\\n at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
"Body": null,
"Seq": 348,
"Type": "response"
}
### C# log ###
Empty
## Environment information ##
**VSCode version**: 1.69.0-insider
**C# Extension**: 1.25.0
Mono Information
OmniSharp using mono :6.12.0
Dotnet Information
.NET SDK (reflecting any global.json):
Version: 6.0.301
Commit: 43f9b18481
Runtime Environment:
OS Name: Mac OS X
OS Version: 12.4
OS Platform: Darwin
RID: osx.12-arm64
Base Path: /usr/local/share/dotnet/sdk/6.0.301/
Host (useful for support):
Version: 6.0.6
Commit: 7cca709db2
.NET SDKs installed:
6.0.301 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|Angular2|johnpapa|13.0.0|
|csharp|ms-dotnettools|1.25.0|
|csharpextensions|kreativ-software|1.7.0|
|EditorConfig|EditorConfig|0.16.4|
|githistory|donjayamanne|0.6.19|
|hexeditor|ms-vscode|1.9.7|
|js-debug-nightly|ms-vscode|2022.6.2417|
|mads|mirao|0.0.5|
|material-icon-theme|PKief|4.18.1|
|msbuild-project-tools|tintoy|0.4.3|
|ng-template|Angular|14.0.1|
|night-owl|sdras|2.0.1|
|open-in-browser|techer|2.0.0|
|ossaction|pgarcia|1.0.0|
|output-colorizer|IBM|0.1.2|
|path-intellisense|christian-kohler|2.8.1|
|quicktype|quicktype|12.0.46|
|rails|bung87|0.17.8|
|slim|sianglim|0.1.2|
|TabOut|albert|0.2.1|
|vscode-eslint|dbaeumer|2.2.2|
|vscode-gemfile|bung87|0.4.2|
|vscode-svgviewer|cssho|2.0.0|
|vscode-thunder-client|rangav|1.16.5|
|vscode-typescript-next|ms-vscode|4.8.20220625|
|vscodeintellicode|VisualStudioExptTeam|1.2.21|
|winteriscoming|johnpapa|1.4.4|;
Contributor guide
Assessment
This issue has not been assessed yet.