Skip to content

Null ref exception in Client lib #210

@TylerLeonhardt

Description

@TylerLeonhardt

It only seems to happen on my machine (running in CI) but here's what I get:

Error Message:
   System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters.CommandOrCodeActionConverter.ReadJson(JsonReader reader, Type objectType, CommandOrCodeAction existingValue, Boolean hasExistingValue, JsonSerializer serializer) in /_/src/Protocol/Serialization/Converters/CommandOrCodeActionConverter.cs:line 28
   at Newtonsoft.Json.JsonConverter`1.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
   at OmniSharp.Extensions.LanguageServer.Client.Protocol.LspConnection.SendRequest[TResponse](String method, Object request, CancellationToken cancellationToken)
   at PowerShellEditorServices.Test.E2E.LanguageServerProtocolMessageTests.CanSendCodeActionRequest() in /Users/tyleonha/Code/PowerShell/vscode/PowerShellEditorServices/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs:line 642

The code in question:

Here was my request:

await LanguageClient.SendRequest<CommandOrCodeActionContainer>(
                    "textDocument/codeAction",
                    new CodeActionParams
                    {
                        TextDocument = new TextDocumentIdentifier(
                            new Uri(filePath, UriKind.Absolute)),
                        Range = new Range
                        {
                            Start = new Position
                            {
                                Line = 0,
                                Character = 0
                            },
                            End = new Position
                            {
                                Line = 0,
                                Character = 3
                            }
                        },
                        Context = new CodeActionContext
                        {
                            Diagnostics = new Container<Diagnostic>(Diagnostics)
                        }
                    });

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions