Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting a .cshtml document fails with an error #8684

Closed
jtsom opened this issue May 11, 2023 · 1 comment
Closed

Formatting a .cshtml document fails with an error #8684

jtsom opened this issue May 11, 2023 · 1 comment

Comments

@jtsom
Copy link

jtsom commented May 11, 2023

Is this a Bug or Feature request?:

Bug

Steps to reproduce

------------------- Please fill in this section -------------------------
Attempt to Format Document of a .cshtml file.

Description of the problem:

------------------- Please fill in this section -------------------------
Does not format, and generates an error

Expected behavior:

Actual behavior:
Error displayed.
image

ntering method textDocument/codeAction.
Entering method textDocument/formatting.
[Error - 3:15:29 PM] [null]
[Error - 3:15:29 PM] Request textDocument/formatting failed.
  Message: Specified argument was out of the range of valid values. (Parameter 'Range end line 22 matches or exceeds SourceText boundary 22.')
  Code: -32000 
[object Object]

Logs

OmniSharp

------------------- Please fill in this section -------------------------
To find the OmniSharp log, open VS Code's "Output" pane, then in the dropdown choose "OmniSharp Log".
Starting OmniSharp server at 5/11/2023, 3:15:17 PM
Target: d:\source\EF-API\EF-API

OmniSharp server started with .NET 7.0.203
.
Path: c:\Users\jtsombakos.vscode-insiders\extensions\ms-dotnettools.csharp-1.25.7-win32-x64.omnisharp\1.39.6-net6.0\OmniSharp.dll
PID: 2100

Starting OmniSharp on Windows 10.0.22621.0 (x64)
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 5 MSBuild instance(s)
1: .NET Core SDK 7.0.203 17.5.1 - "C:\Program Files\dotnet\sdk\7.0.203"
2: .NET Core SDK 7.0.105 17.4.3 - "C:\Program Files\dotnet\sdk\7.0.105"
3: .NET Core SDK 6.0.408 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.408"
4: .NET Core SDK 6.0.311 17.2.2 - "C:\Program Files\dotnet\sdk\6.0.311"
5: .NET Core SDK 6.0.116 17.0.1 - "C:\Program Files\dotnet\sdk\6.0.116"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 7.0.203 17.5.1 - "C:\Program Files\dotnet\sdk\7.0.203"
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'd:\source\EF-API\EF-API'.
info: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'd:\source\EF-API\EF-API'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\source\EF-API\EF-API\EF-API.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'd:\source\EF-API\EF-API'.
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 'd:\source\EF-API\EF-API' on host 17780.
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\source\EF-API\EF-API\EF-API.csproj
info: OmniSharp.OmniSharpWorkspace
Miscellaneous file: d:\source\EF-API\EF-API\Slices\Hello.cshtml__virtual.cs added to workspace
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\source\EF-API\EF-API\EF-API.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project 'd:\source\EF-API\EF-API\EF-API.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: EF-API
info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Solution initialized -> queue all documents for code analysis. Initial document count: 341.

Razor

Expand

[Client - 3:15:24 PM] -- Starting Issue Data Collection-- 
[Client - 3:15:31 PM] -- Stopping Issue Data Collection-- 

Workspace information

Razor document:

Expand

@using EF_API.Models
@inherits RazorSliceHttpResult<List<GetUserLoginLocations>>
<html>
    <head>
        <link href="/Content/bootstrap.css" rel="stylesheet" />
        <title>

        </title>
    </head>
    <body>
        <div class="panel panel-primary panel-blue">
    @{
        foreach (var l in Model)
        {
            <div >@(l.SiteName)</div>
            <div>@l.CustomThemeColor</div>
        }
    }
    </div>
    </body>
</html>

Projected CSharp document:

Expand

////////////////////// Projected CSharp as seen by extension ///////////////////////
// <auto-generated/>
#pragma warning disable 1591
namespace AspNetCore
{
    #line hidden
    using TModel = global::System.Object;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Rendering;
    using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 3 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using System.Globalization;

#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using Microsoft.AspNetCore.Razor;

#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using Microsoft.AspNetCore.Http.HttpResults;

#line default
#line hidden
#nullable disable
#nullable restore
#line 1 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
using EF_API.Models;

#line default
#line hidden
#nullable disable
    #nullable restore
    public class Slices_Hello : RazorSliceHttpResult<List<GetUserLoginLocations>>
    #nullable disable
    {
        #pragma warning disable 219
        private void __RazorDirectiveTokenHelpers__() {
        ((global::System.Action)(() => {
#nullable restore
#line 2 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
RazorSliceHttpResult<List<GetUserLoginLocations>> __typeHelper = default!;

#line default
#line hidden
#nullable disable
        }
        ))();
        }
        #pragma warning restore 219
        #pragma warning disable 0414
        private static object __o = null;
        #pragma warning restore 0414
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#nullable restore
#line 12 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
      
        foreach (var l in Model)
        {
            

#line default
#line hidden
#nullable disable
#nullable restore
#line 15 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
              __o = l.SiteName;

#line default
#line hidden
#nullable disable
#nullable restore
#line 15 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
                                     
            

#line default
#line hidden
#nullable disable
#nullable restore
#line 16 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
            __o = l.CustomThemeColor;

#line default
#line hidden
#nullable disable
#nullable restore
#line 16 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
                                          
        }
    

#line default
#line hidden
#nullable disable
        }
        #pragma warning restore 1998
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; } = default!;
        #nullable disable
    }
}
#pragma warning restore 1591



////////////////////// Projected CSharp as seen by VSCode ///////////////////////
// <auto-generated/>
#pragma warning disable 1591
namespace AspNetCore
{
    #line hidden
    using TModel = global::System.Object;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Rendering;
    using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 3 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using System.Globalization;

#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using Microsoft.AspNetCore.Razor;

#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "d:/source/EF-API/EF-API/Slices/_ViewImports.cshtml"
using Microsoft.AspNetCore.Http.HttpResults;

#line default
#line hidden
#nullable disable
#nullable restore
#line 1 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
using EF_API.Models;

#line default
#line hidden
#nullable disable
    #nullable restore
    public class Slices_Hello : RazorSliceHttpResult<List<GetUserLoginLocations>>
    #nullable disable
    {
        #pragma warning disable 219
        private void __RazorDirectiveTokenHelpers__() {
        ((global::System.Action)(() => {
#nullable restore
#line 2 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
RazorSliceHttpResult<List<GetUserLoginLocations>> __typeHelper = default!;

#line default
#line hidden
#nullable disable
        }
        ))();
        }
        #pragma warning restore 219
        #pragma warning disable 0414
        private static object __o = null;
        #pragma warning restore 0414
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#nullable restore
#line 12 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
      
        foreach (var l in Model)
        {
            

#line default
#line hidden
#nullable disable
#nullable restore
#line 15 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
              __o = l.SiteName;

#line default
#line hidden
#nullable disable
#nullable restore
#line 15 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
                                     
            

#line default
#line hidden
#nullable disable
#nullable restore
#line 16 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
            __o = l.CustomThemeColor;

#line default
#line hidden
#nullable disable
#nullable restore
#line 16 "d:/source/EF-API/EF-API/Slices/Hello.cshtml"
                                          
        }
    

#line default
#line hidden
#nullable disable
        }
        #pragma warning restore 1998
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; } = default!;
        #nullable disable
        #nullable restore
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; } = default!;
        #nullable disable
    }
}
#pragma warning restore 1591

// 1

Projected Html document:

Expand

////////////////////// Projected Html as seen by extension ///////////////////////
~~~~~~ ~~~~~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
    <head>
        <link href="/Content/bootstrap.css" rel="stylesheet" />
        <title>

        </title>
    </head>
    <body>
        <div class="panel panel-primary panel-blue">
    ~~
        ~~~~~~~ ~~~~ ~ ~~ ~~~~~~
        ~
            <div >~~~~~~~~~~~~~</div>
            <div>~~~~~~~~~~~~~~~~~~~</div>
        ~
    ~
    </div>
    </body>
</html>



////////////////////// Projected Html as seen by VSCode ///////////////////////
~~~~~~ ~~~~~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<html>
    <head>
        <link href="/Content/bootstrap.css" rel="stylesheet" />
        <title>

        </title>
    </head>
    <body>
        <div class="panel panel-primary panel-blue">
    ~~
        ~~~~~~~ ~~~~ ~ ~~ ~~~~~~
        ~
            <div >~~~~~~~~~~~~~</div>
            <div>~~~~~~~~~~~~~~~~~~~</div>
        ~
    ~
    </div>
    </body>
</html>

// 1

Machine information

VSCode version: 1.79.0-insider
Razor.VSCode version: 1.25.7

dotnet --info

Expand

.NET SDK:
 Version:   7.0.203
 Commit:    5b005c19f5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.203\

Host:
  Version:      7.0.5
  Architecture: x64
  Commit:       8042d61b17

.NET SDKs installed:
  3.1.426 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.116 [C:\Program Files\dotnet\sdk]
  6.0.311 [C:\Program Files\dotnet\sdk]
  6.0.408 [C:\Program Files\dotnet\sdk]
  7.0.105 [C:\Program Files\dotnet\sdk]
  7.0.203 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Extensions

Expand

Extension Author Version
azure-account ms-vscode 0.11.4
csharp ms-dotnettools 1.25.7
csharpextensions kreativ-software 1.7.3
ecdc mitchdenny 1.8.0
git-graph mhutchie 1.30.0
hexeditor ms-vscode 1.9.11
hl7tools RobHolme 2.0.4
js-debug-nightly ms-vscode 2023.5.917
jwt-debugger yokawasa 0.4.2
kanagawa qufiwefefwoyn 1.5.1
live-server ms-vscode 0.4.8
material-icon-theme PKief 4.27.0
msbuild-project-tools tintoy 0.4.9
night-owl sdras 2.0.1
quicktype quicktype 12.0.46
sync-scroll dqisme 1.3.1
TabOut albert 0.2.2
vs-code-xml-format fabianlauer 0.1.5
vscode-azureappservice ms-azuretools 0.24.8
vscode-azurefunctions ms-azuretools 1.10.5
vscode-azureresourcegroups ms-azuretools 0.7.1
vscode-azurestorage ms-azuretools 0.15.1
vscode-base64 adamhartford 0.1.0
vscode-cosmosdb ms-azuretools 0.19.3
vscode-thunder-client rangav 2.6.2
vscodeintellicode VisualStudioExptTeam 1.2.30

@ghost ghost added the untriaged label May 11, 2023
@davidwengier
Copy link
Member

Thanks for the report. This was also reported as dotnet/vscode-csharp#5561 and should be fixed by #8669. Unfortunately we can't provide an estimate on when the next release will be available, but hopefully not too long.

@ghost ghost removed the untriaged label May 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants