OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.72k stars 168 forks source link

Argument Exception: Document is not part of the workspace #727

Closed jedielson closed 3 years ago

jedielson commented 3 years ago

HI.

Here is my log.


OmniSharp server started.
    Path: C:\Users\myuser\AppData\Local\omnisharp-vim\omnisharp-roslyn\OmniSharp.exe
    Target: C:\git-repos\myproj\myproj-service\MyProj.sln
    PID: 13112

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.10.31515.178 16.10.2 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
            2: StandAlone 17.0.0 - "C:\Users\myuser\AppData\Local\omnisharp-vim\omnisharp-roslyn\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.10.31515.178 16.10.2 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'C:\git-repos\myproj\myproj-service'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'C:\git-repos\myproj\myproj-service\MyProj.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Api\Api.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Core\Core.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Infra.Gateway\Infra.Gateway.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Infra.Messaging\Infra.Messaging.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Infra.Persistence\Infra.Persistence.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'C:\git-repos\myproj\myproj-service\src\Core.Dto\Core.Dto.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'C:\git-repos\myproj\myproj-service'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'C:\git-repos\myproj\myproj-service' on host -1.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Api\Api.csproj
[info]: OmniSharp.OmniSharpWorkspace
        Miscellaneous file: C:\git-repos\myproj\myproj-service\src\Infra.Persistence\Decorators\OrderRepositoryDecorator.cs added to workspace
Replaying requests for buffer 14
[warn]: OmniSharp.MSBuild.ProjectLoader
        MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Api\Api.csproj'.
C:\git-repos\myproj\myproj-service\src\Api\Api.csproj
C:\git-repos\myproj\myproj-service\src\Api\Api.csproj(0,0): Error: MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Api\Api.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj'.
C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj
C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj(0,0): Error: MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\tests\Tests.IntegrationTests\Tests.Integration.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj'.
C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj
C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj(0,0): Error: MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\tests\Tests.UnitTests\Tests.UnitTests.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Core\Core.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Core\Core.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Core\Core.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj'.
C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj
C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj(0,0): Error: MyProj.Infra.CrossCutting depends on MyProj.SomeNugetDependency (>= 3.0.20167.47) but MyProj.SomeNugetDependency 3.0.20167.47 was not found. An approximate best match of MyProj.SomeNugetDependency 3.0.20296.47 was resolved.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Infra.CrossCutting\Infra.CrossCutting.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Infra.Gateway\Infra.Gateway.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Infra.Gateway\Infra.Gateway.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Infra.Gateway\Infra.Gateway.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Infra.Messaging\Infra.Messaging.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Infra.Messaging\Infra.Messaging.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Infra.Messaging\Infra.Messaging.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Infra.Persistence\Infra.Persistence.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Infra.Persistence\Infra.Persistence.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Infra.Persistence\Infra.Persistence.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: C:\git-repos\myproj\myproj-service\src\Core.Dto\Core.Dto.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'C:\git-repos\myproj\myproj-service\src\Core.Dto\Core.Dto.csproj'.
All projects loaded
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'C:\git-repos\myproj\myproj-service\src\Core.Dto\Core.Dto.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Api
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Tests.Integration
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Tests.UnitTests
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Core
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Infra.CrossCutting
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Infra.Gateway
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Infra.Messaging
Replaying on-load requests
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Infra.Persistence
[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Seq": 1004,
  "Arguments": {
    "FileName": "C:\\git-repos\\myproj\\myproj-service\\src\\Infra.Persistence\\Decorators\\OrderRepositoryDecorator.cs",
    "Column": 1,
    "Line": 1,
    "Buffer": "here goes some buffer code"
  },
  "Type": "request",
  "Command": "/v2/highlight"
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (30.4482ms) ************ 
{
  "Request_seq": 1004,
  "Command": "/v2/highlight",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentException: '<Documentcbb54f4e-5207-4eea-8a1a-d3f20d71d779>' is not part of the workspace.\\r\\n   at Microsoft.CodeAnalysis.Workspace.CheckDocumentIsInCurrentSolution(DocumentId documentId)\\r\\n   at Microsoft.CodeAnalysis.Workspace.OnAnyDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode, Action`1 checkIsInCurrentSolution, Func`3 getRelatedDocuments, Func`5 updateSolutionWithText, WorkspaceChangeKind changeKind, Boolean isCodeDocument)\\r\\n   at Microsoft.CodeAnalysis.Workspace.OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode)\\r\\n   at Microsoft.CodeAnalysis.Workspace.ApplyChangedDocument(ProjectChanges projectChanges, DocumentId documentId)\\r\\n   at Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(ProjectChanges projectChanges)\\r\\n   at OmniSharp.OmniSharpWorkspace.ApplyProjectChanges(ProjectChanges projectChanges) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn\\\\OmniSharpWorkspace.cs:line 589\\r\\n   at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution, IProgressTracker progressTracker)\\r\\n   at OmniSharp.Roslyn.BufferManager.<UpdateBufferAsync>d__8.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn\\\\BufferManager.cs:line 124\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Buffer.UpdateBufferService.<Handle>d__2.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Buffer\\\\UpdateBufferService.cs:line 23\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 230\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 131\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 114\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Stdio.Host.<HandleRequest>d__14.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\"",
  "Body": null,
  "Seq": 85,
  "Type": "response"
}
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Core.Dto
Workspace complete: 9 project(s)

The root where the project is has a .sln file, so what can be causing this error?

nickspoons commented 3 years ago

I'm not sure, I haven't seen that before.

  1. Is this the latest version of OmniSharp-roslyn? (:OmniSharpInstall to get the latest)
  2. What kind of project is this? .NET Framework/core version? What's the value of <Framework target> in the .csproj?

The error is being raised by the server so there's only limited help we can give in this repo, but we can try to narrow the problem down at least.

jedielson commented 3 years ago

It's akward...

I do have omnishap roslyn installed, and I configure it like this...

 local nvim_lsp = require('lspconfig')

 local on_attach = function(client, bufferNumber)
    require('completion').on_attach(client)
 end

 local omnisharp_root = ""
 if vim.fn.has('unix') == 1 then
     print('Hello from linux\n')
     omnisharp_root = "/home/jedi/.cache/omnisharp-vim/omnisharp-roslyn/run"
 else
     print("Hello from Windows\n")
      omnisharp_root = "C:\\ProgramData\\chocolatey\\bin\\OmniSharp.exe"
  end

 local pid = vim.fn.getpid()
 local omnisharp_bin = nvim_lsp.omnisharp.setup({ cmd = { omnisharp_root, "--languageserver" , "--hostPID", tostring(pid) } })
nickspoons commented 3 years ago

That is configuring neovim LSP, not OmniSharp-vim. As you can see from the 2nd line of your log, OmniSharp-vim is not using that config you've shown, the server (OmniSharp.exe) is at the OmniSharp-vim install location C:\Users\myuser\AppData\Local\omnisharp-vim\omnisharp-roslyn\OmniSharp.exe, not your chocolatey install path. If you are going to use both OmniSharp-vim and LSP, you'll be running 2 instances of the server simultaneously. On Windows it looks like you'll be using the chocolatey version from neovim LSP, whatever version that might be.

To help diagnose the original problem, please upgrade the server used by OmniSharp-vim with :OmniSharpInstall, and then answer question 2 from my previous comment.

nickspoons commented 3 years ago

Closing due to lack of response