dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Error [Request textDocument/formatting failed.] - when try save razor ".cshtml" #5668

Open crmmvio opened 1 year ago

crmmvio commented 1 year ago

When try saved file .cshtml, the vscode saved the file, but generate message erro "Request textDocument/formatting failed.", my currently version C# OmmiSharp is 1.25.7

I going to come back version 1.25.2 because this work corretly.

Log: Starting OmniSharp server at 5/4/2023, 10:32:23 AM Target: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\SgkUI.sln

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

    Starting OmniSharp on Windows 10.0.19045.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    Located 2 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 6.0.408 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.408\"
    Registered MSBuild instance: .NET Core SDK 7.0.203 17.5.1 - "C:\Program Files\dotnet\sdk\7.0.203\"
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Detecting Cake files in 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI'.
    Did not find any Cake files
    Detecting projects in 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\SgkUI.sln'.
    Queue project update for 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj'
    Queue project update for 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.Data\CBL.Sgk.Infra.Data.csproj'
    Queue project update for 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.IoC\CBL.Sgk.Infra.IoC.csproj'
    Queue project update for 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\CBL.Sgk.UI.csproj'
    Detecting CSX files in 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI'.
    Did not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI' on host 23296.
    Loading project: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj
    Successfully loaded project file 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj'.
    Adding project 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj'
    Failed to add project to workspace: 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj'
    Loading project: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.Data\CBL.Sgk.Infra.Data.csproj
    Miscellaneous file: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\Views\Shared\_NavMenu.cshtml__virtual.cs added to workspace
    Successfully loaded project file 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.Data\CBL.Sgk.Infra.Data.csproj'.
    Adding project 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.Data\CBL.Sgk.Infra.Data.csproj'
    Loading project: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.IoC\CBL.Sgk.Infra.IoC.csproj
    Successfully loaded project file 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.IoC\CBL.Sgk.Infra.IoC.csproj'.
    Adding project 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Infra.IoC\CBL.Sgk.Infra.IoC.csproj'
    Loading project: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\CBL.Sgk.UI.csproj
    Successfully loaded project file 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\CBL.Sgk.UI.csproj'.
    Adding project 'c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\CBL.Sgk.UI.csproj'
    Could not locate project in workspace: c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.Application\CBL.Sgk.Application.csproj
    Update project: CBL.Sgk.Infra.Data
    Error occurred while processing project updates

System.ArgumentException: "" não é parte do workspace. at Microsoft.CodeAnalysis.Workspace.CheckProjectIsInSolution(Solution solution, ProjectId projectId) at Microsoft.CodeAnalysis.Workspace.CheckProjectIsInCurrentSolution(ProjectId projectId) at Microsoft.CodeAnalysis.Workspace.<>c__DisplayClass58_0.b0(Solution oldSolution) at Microsoft.CodeAnalysis.Workspace.<>c.b26_3(Solution oldSolution, ValueTuple7 data) at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution[TData](Func3 transformation, TData data, Action3 onBeforeUpdate, Action3 onAfterUpdate) at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution(Func2 transformation, Func3 changeKind, ProjectId projectId, DocumentId documentId, Action2 onBeforeUpdate, Action2 onAfterUpdate) at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution(Func2 transformation, WorkspaceChangeKind changeKind, ProjectId projectId, DocumentId documentId, Action2 onBeforeUpdate, Action2 onAfterUpdate) at Microsoft.CodeAnalysis.Workspace.OnProjectReferenceAdded(ProjectId projectId, ProjectReference projectReference) at OmniSharp.OmniSharpWorkspace.AddProjectReference(ProjectId projectId, ProjectReference projectReference) in D:\a\1\s\src\OmniSharp.Roslyn\OmniSharpWorkspace.cs:line 122 at OmniSharp.MSBuild.ProjectManager.UpdateProjectReferences(Project project, ImmutableArray1 projectReferencePaths) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 816 at OmniSharp.MSBuild.ProjectManager.UpdateProject(String projectFilePath, String changeTriggerFilePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 482 at OmniSharp.MSBuild.ProjectManager.ProcessQueue(CancellationToken cancellationToken) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 268 at OmniSharp.MSBuild.ProjectManager.ProcessLoopAsync(CancellationToken cancellationToken) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 185

    ************ Request ************

{ "Type": "request", "Seq": 23, "Command": "/close", "Arguments": { "FileName": "c:\Users\moviocr1\Projetos\1859-SGK\SgkUI\src\CBL.Sgk.UI\Views\Shared\_NavMenu.cshtml__virtual.cs" } }

    ************  Response (18.5763ms) ************ 

{ "Request_seq": 23, "Command": "/close", "Running": true, "Success": false, "Message": "\"System.ArgumentException: \\"_NavMenu.cshtmlvirtual.cs\\" não está aberto.\r\n at Microsoft.CodeAnalysis.Workspace.CheckDocumentIsOpen(DocumentId documentId)\r\n at Microsoft.CodeAnalysis.Workspace.<>c.b199_0(Solution oldSolution, ValueTuple4 data)\\r\\n at Microsoft.CodeAnalysis.Workspace.SetCurrentSolution[TData](Func3 transformation, TData data, Action3 onBeforeUpdate, Action3 onAfterUpdate)\r\n at Microsoft.CodeAnalysis.Workspace.OnDocumentClosed(DocumentId documentId, TextLoader reloader, Boolean updateActiveContext)\r\n at OmniSharp.OmniSharpWorkspace.CloseDocument(DocumentId documentId) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\OmniSharpWorkspace.cs:line 106\r\n at OmniSharp.Roslyn.CSharp.Services.Files.FileCloseService.Handle(FileCloseRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\Files\\FileCloseService.cs:line 25\r\n at OmniSharp.Endpoint.Exports.RequestHandlerExportHandler2.Handle(TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\Exports\\\\RequestHandlerExportHandler.cs:line 29\\r\\n at OmniSharp.Endpoint.EndpointHandler2.AggregateResponsesFromLanguageHandlers(ExportHandler2[] handlers, TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 165\\r\\n at OmniSharp.Endpoint.EndpointHandler2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 226\r\n at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 130\r\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 218\"", "Body": null, "Seq": 1634, "Type": "response" }

tkoenig89 commented 1 year ago

Hey @crmmvio, this might be a duplicate of #5561 as you might have "format on save" on. Maybe have a look at this issue, as your problem might be tracked there as well.

A PR with a fix has been proposed recently, but a release with the extension seems to be a longer process, so we might need to wait a little longer for a fix.