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

LSP failed to handle notification - Sequence contains more than one matching element #1403

Closed
Daniel-V1 opened this issue Feb 19, 2019 · 9 comments · Fixed by #1503
Closed
Labels

Comments

@Daniel-V1
Copy link

Daniel-V1 commented Feb 19, 2019

I get the following error when attempting to start the server in with -lsp. I have built from the latest commit on master.

Finding descriptor for initialize
Starting: Routing Request (1) initialize
Converting params for Request (1) initialize to OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams
Assembly loaded: OmniSharp.Cake
Loaded OmniSharp.Cake, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.DotNet
Loaded OmniSharp.DotNet, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.DotNetTest
Loaded OmniSharp.DotNetTest, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.Host
Loaded OmniSharp.Host, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.MSBuild
Loaded OmniSharp.MSBuild, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.Plugins
Loaded OmniSharp.Plugins, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.Roslyn
Loaded OmniSharp.Roslyn, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.Roslyn.CSharp
Loaded OmniSharp.Roslyn.CSharp, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
Assembly loaded: OmniSharp.Script
Loaded OmniSharp.Script, Version=1.32.0.0, Culture=neutral, PublicKeyToken=null
DotNetPath set to dotnet
Located 2 MSBuild instance(s)
1: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
2: StandAlone 15.0 - "/home/daniel/Src/github/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/mono/msbuild/15.0/Bin"
Assembly loaded from path: /usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Utilities.Core.dll
SUCCESS: Resolved to '/usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Utilities.Core.dll' (name-only).
Assembly loaded from path: /usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Tasks.Core.dll
SUCCESS: Resolved to '/usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Tasks.Core.dll' (name-only).
Assembly loaded from path: /usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Framework.dll
SUCCESS: Resolved to '/usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.Framework.dll' (name-only).
Assembly loaded from path: /usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.dll
SUCCESS: Resolved to '/usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.dll' (name-only).
Registered MSBuild instance: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
CscToolPath = /home/daniel/Src/github/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/mono/msbuild/15.0/Bin/Roslyn
CscToolExe = csc.exe
Attempting to resolve 'System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Assembly loaded from path: /usr/lib/mono/msbuild/15.0/bin/System.Threading.Tasks.Dataflow.dll
SUCCESS: Resolved to '/usr/lib/mono/msbuild/15.0/bin/System.Threading.Tasks.Dataflow.dll'
Assembly loaded: Microsoft.CodeAnalysis.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
FAILURE: Could not locate '/usr/lib/mono/msbuild/15.0/bin/Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'.
Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
FAILURE: Could not locate '/usr/lib/mono/msbuild/15.0/bin/Microsoft.CodeAnalysis.VisualBasic.Features.dll'.
Successfully added Microsoft.CodeAnalysis.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
Successfully added Microsoft.CodeAnalysis.CSharp.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 to host service assemblies.
Configured Document Selectors { language = Cake, selector = [/*.cake] }, { language = C#, selector = [/.cs], [**/.csx] }
--- Handler Definitions ---
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Types.TypeLookupHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Structure.BlockStructureHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Structure.CodeStructureHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Structure.MembersAsTreeHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Signatures.SignatureHelpHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Refactoring.RenameHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Refactoring.V2.GetCodeActionsHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Refactoring.V2.RunCodeActionsHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.FindImplementationsHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.FindSymbolsHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.FindUsagesHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.GotoDefinitionHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.GotoFileHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.GotoRegionHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.MetadataHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.NavigateUpHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Navigation.NavigateDownHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Intellisense.AutoCompleteHandler
Handler: Cake:[/*.cake]:OmniSharp.Cake.Services.RequestHandlers.Diagnostics.CodeCheckHandler
Handler: Cake:[
/.cake]:OmniSharp.Cake.Services.RequestHandlers.Buffer.ChangeBufferHandler
Handler: Cake:[**/
.cake]:OmniSharp.Cake.Services.RequestHandlers.Buffer.UpdateBufferHandler
Handler: C#:[/*.cs], [/.csx]:OmniSharp.DotNetTest.Services.DebugTestClassService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.DotNetTest.Services.DebugTestService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.DotNetTest.Services.DebugTestService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.DotNetTest.Services.DebugTestService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.DotNetTest.Services.GetTestStartInfoService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.DotNetTest.Services.RunTestService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.DotNetTest.Services.RunTestsInClassService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Types.TypeLookupService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.TestCommands.TestCommandService
Assembly loaded: Microsoft.CodeAnalysis.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Structure.BlockStructureService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Structure.CodeStructureService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Structure.MembersAsFlatService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Structure.MembersAsTreeService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Signatures.SignatureHelpService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.FixUsingService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.GetCodeActionsService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.RenameService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.RunCodeActionsService
Assembly loaded: Microsoft.CodeAnalysis.CSharp.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Assembly loaded: Microsoft.CodeAnalysis.Features, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Assembly loaded: Microsoft.CodeAnalysis.Workspaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.RunCodeActionService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.FindImplementationsService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.FindSymbolsService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.GotoDefinitionService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.GotoFileService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.GotoRegionService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.MetadataService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.NavigateUpService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Navigation.NavigateDownService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Intellisense.IntellisenseService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Highlighting.HighlightingService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Formatting.CodeFormatService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Formatting.FormatAfterKeystrokeService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Formatting.FormatRangeService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Files.FileCloseService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Files.FileOpenService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Files.OnFilesChangedService
Handler: C#:[**/
.cs], [/*.csx]:OmniSharp.Roslyn.CSharp.Services.Diagnostics.CodeCheckService
Handler: C#:[
/.cs], [**/.csx]:OmniSharp.Roslyn.CSharp.Services.Diagnostics.DiagnosticsService
Handler: C#:[/*.cs], [/.csx]:OmniSharp.Roslyn.CSharp.Services.Buffer.ChangeBufferService
Handler: C#:[**/
.cs], [**/*.csx]:OmniSharp.Roslyn.CSharp.Services.Buffer.UpdateBufferService
--- Handler Definitions ---
Failed to handle notification initialize - System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) [0x0004a] in <5107f2ad97fb4efa9f99de1259ce0538>:0
at OmniSharp.Extensions.LanguageServer.Server.ClientCapabilityProvider.HasStaticHandler[T] (OmniSharp.Extensions.LanguageServer.Protocol.Supports1[T] capability) [0x00044] in <2ef0d254b13a441f977ce7b5128e9913>:0 at OmniSharp.Extensions.LanguageServer.Server.ClientCapabilityProvider.GetStaticOptions[T] (OmniSharp.Extensions.LanguageServer.Protocol.Supports1[T] capability) [0x00000] in <2ef0d254b13a441f977ce7b5128e9913>:0
at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.OmniSharp.Extensions.Embedded.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams request, System.Threading.CancellationToken token) [0x0037e] in <2ef0d254b13a441f977ce7b5128e9913>:0
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, OmniSharp.Extensions.Embedded.MediatR.RequestHandlerDelegate1[TResponse] next) [0x000e1] in <2ef0d254b13a441f977ce7b5128e9913>:0
at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest (OmniSharp.Extensions.JsonRpc.IHandlerDescriptor descriptor, OmniSharp.Extensions.JsonRpc.Server.Request request) [0x002e2] in <2ef0d254b13a441f977ce7b5128e9913>:0
Finished: Routing Request (1) initialize in 1051ms

@filipw filipw added the lsp label Mar 12, 2019
@LoneBoco
Copy link
Contributor

I encounter the same issue. I haven't yet been able to resolve it as the error originates in the https://github.com/OmniSharp/csharp-language-server-protocol project. No .pdb's exist so I have to manually download, compile, integrate the .dll, and debug, and I haven't had enough time to do that yet.

@mickaelistria
Copy link

Same issue here. I guess that the client sends a capability that's not well understood by OmniSharp, and the tricky part is to find out which one it is.
Here is the message from my client to OmniSharp

{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":28133,"rootPath":"/home/mistria/runtime-New_configuration(2)/fd/","rootUri":"file:///home/mistria/runtime-New_configuration(2)/fd/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true}},"hover":{},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{},"rangeFormatting":{},"definition":{},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse Platform","trace":"off"}}

@mickaelistria
Copy link

I tweaked my client to sort out which capabilities do cause an issue with OmniSharp, from the previous message, Omnisharp will fail whenever initialize message contains "colorProvider":{} or "synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true}. It just look like OmniSharp is late compared to the LSP spec.

@LoneBoco
Copy link
Contributor

https://github.com/OmniSharp/csharp-language-server-protocol/blob/7d8567c09c88d27b4b4a2209959f689df8e9419d/src/Server/ClientCapabilityProvider.cs#L28-L31

capability = {OmniSharp.Extensions.LanguageServer.Protocol.Supports<OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.SynchronizationCapability>}

typeof(T).GetTypeInfo().ImplementedInterfaces.Where(x => x.GetTypeInfo().IsGenericType && x.GetTypeInfo().GetGenericTypeDefinition() == typeof(ConnectedCapability<>))
{System.Linq.Enumerable.WhereArrayIterator<System.Type>}
    [0]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IDidChangeTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}
    [1]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IDidCloseTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}
    [2]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IDidOpenTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}
    [3]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IDidSaveTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}
    [4]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IWillSaveTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}
    [5]: {Name = "ConnectedCapability`1" FullName = "OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities.ConnectedCapability`1[[OmniSharp.Extensions.LanguageServer.Protocol.Server.IWillSaveWaitUntilTextDocumentHandler, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}

This is where it is exploding. The SynchronizationCapability has 6 different interfaces attached to it, and all 6 of them satisfy the conditions of .Single(), which makes the code explode.

I'm not entirely sure how to fix this yet. I mean, you could probably just change .Single() to .First() and hope for the best.

@LoneBoco
Copy link
Contributor

Ah, changing to .First() just moves the error someplace else.

@luizribeiro
Copy link

I am also running into this problem with vim-ale.

These are the capabilities that vim-ale is sending to omnisharp-roslyn's LSP server: https://github.com/w0rp/ale/blob/master/autoload/ale/lsp.vim#L327-L385

Removing the synchronization key of the dictionary makes the LSP server initialize, but then the LSP isn't as useful.

@luizribeiro
Copy link

Looks like this was solved on OmniSharp/csharp-language-server-protocol#132.

@mholo65, maybe we have to upgrade something?

bjorkstromm added a commit to bjorkstromm/omnisharp-roslyn that referenced this issue May 22, 2019
@bjorkstromm
Copy link
Member

@luizribeiro sent PR for updating LSP libs in #1503

@LoneBoco
Copy link
Contributor

I just tried the PR and after months of LSP being broken, it works again! Thank you very much for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants