public async Task <InitializeResult> InitializeAsync(JToken input, CancellationToken cancellationToken) { // The VS LSP protocol package changed the type of 'tagSupport' from bool to an object. // Our version of the LSP protocol package is older and assumes that the type is bool, so deserialization fails. // Since we don't really read this field, just no-op the error until we can update our package references. // https://github.com/dotnet/roslyn/issues/40829 tracks updating this. var settings = new JsonSerializerSettings { Error = (sender, args) => { if (object.Equals(args.ErrorContext.Member, "tagSupport") && args.ErrorContext.OriginalObject.GetType() == typeof(PublishDiagnosticsSetting)) { args.ErrorContext.Handled = true; } } }; var serializer = JsonSerializer.Create(settings); // InitializeParams only references ClientCapabilities, but the VS LSP client // sends additional VS specific capabilities, so directly deserialize them into the VSClientCapabilities // to avoid losing them. _clientCapabilities = input["capabilities"].ToObject <VSClientCapabilities>(serializer); var serverCapabilities = await _protocol.InitializeAsync(_workspace.CurrentSolution, input.ToObject <InitializeParams>(serializer), _clientCapabilities, cancellationToken).ConfigureAwait(false); // As soon as LSP supports classifications in hover, we can remove this and always advertise hover support. // Tracking - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138/ serverCapabilities.Capabilities.HoverProvider = _supportsHover; return(serverCapabilities); }
public Task <InitializeResult> Initialize(JToken input, CancellationToken cancellationToken) { // InitializeParams only references ClientCapabilities, but the VS LSP client // sends additional VS specific capabilities, so directly deserialize them into the VSClientCapabilities // to avoid losing them. _clientCapabilities = input["capabilities"].ToObject <VSClientCapabilities>(); return(_protocol.InitializeAsync(_workspace.CurrentSolution, input.ToObject <InitializeParams>(), _clientCapabilities, cancellationToken)); }
public Task <InitializeResult> InitializeAsync(JToken input, CancellationToken cancellationToken) { // The VS LSP protocol package changed the type of 'tagSupport' from bool to an object. // Our version of the LSP protocol package is older and assumes that the type is bool, so deserialization fails. // Since we don't really read this field, just no-op the error until we can update our package references. // https://github.com/dotnet/roslyn/issues/40829 tracks updating this. var settings = new JsonSerializerSettings { Error = (sender, args) => { if (object.Equals(args.ErrorContext.Member, "tagSupport") && args.ErrorContext.OriginalObject.GetType() == typeof(PublishDiagnosticsSetting)) { args.ErrorContext.Handled = true; } } }; var serializer = JsonSerializer.Create(settings); // InitializeParams only references ClientCapabilities, but the VS LSP client // sends additional VS specific capabilities, so directly deserialize them into the VSClientCapabilities // to avoid losing them. _clientCapabilities = input["capabilities"].ToObject <VSClientCapabilities>(serializer); return(_protocol.InitializeAsync(_workspace.CurrentSolution, input.ToObject <InitializeParams>(serializer), _clientCapabilities, cancellationToken)); }