Omnisharp-roslyn: LSP failed to handle notification - Sequence contains more than one matching element

Created on 19 Feb 2019  路  9Comments  路  Source: OmniSharp/omnisharp-roslyn

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.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

lsp

Most helpful comment

@luizribeiro sent PR for updating LSP libs in #1503

All 9 comments

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.

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"}}

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.

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.

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

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.

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

@mholo65, maybe we have to upgrade something?

@luizribeiro sent PR for updating LSP libs in #1503

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natemcmaster picture natemcmaster  路  5Comments

nickspoons picture nickspoons  路  4Comments

carlossanlop picture carlossanlop  路  6Comments

bradwilson picture bradwilson  路  3Comments

liugt34 picture liugt34  路  5Comments