Skip to content

Null ref exception in Client lib #210

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

Closed
TylerLeonhardt opened this issue Feb 13, 2020 · 3 comments · Fixed by #211
Closed

Null ref exception in Client lib #210

TylerLeonhardt opened this issue Feb 13, 2020 · 3 comments · Fixed by #211
Assignees
Labels
bug Something isn't working

Comments

@TylerLeonhardt
Copy link
Collaborator

TylerLeonhardt commented Feb 13, 2020

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)
                        }
                    });
@TylerLeonhardt TylerLeonhardt assigned tintoy and unassigned tintoy Feb 13, 2020
@TylerLeonhardt
Copy link
Collaborator Author

cc @tintoy

@TylerLeonhardt
Copy link
Collaborator Author

I feel like the problem is probably here:

What happens if command doesn't exist?

@tintoy
Copy link
Collaborator

tintoy commented Feb 13, 2020

Yep - that sounds correct to me. I’ll take a look at this in an hour or 2 (need my morning coffee first 😉)

@tintoy tintoy self-assigned this Feb 13, 2020
@tintoy tintoy added the bug Something isn't working label Feb 13, 2020
tintoy added a commit to tintoy/csharp-language-server-protocol that referenced this issue Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants