Skip to content

Commit 584051d

Browse files
authored
Merge pull request #58 from tintoy/fix/client-response-type
Enable client to handle array-type responses
2 parents cde3283 + 1efb2ab commit 584051d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Client/Protocol/ClientMessage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public class ClientMessage
3232
/// The request / notification message, if the message represents a request or a notification.
3333
/// </summary>
3434
[Optional]
35-
public JObject Params { get; set; }
35+
public JToken Params { get; set; }
3636

3737
/// <summary>
3838
/// The response message, if the message represents a response.
3939
/// </summary>
40-
[Optional]
41-
public JObject Result { get; set; }
40+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, NullValueHandling = NullValueHandling.Ignore)]
41+
public JToken Result { get; set; }
4242
}
4343
}

src/Client/Protocol/LspConnection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public void SendNotification(string method, object notification)
343343
{
344344
// No Id means it's a notification.
345345
Method = method,
346-
Params = JObject.FromObject(notification, Serializer.JsonSerializer)
346+
Params = JToken.FromObject(notification, Serializer.JsonSerializer)
347347
});
348348
}
349349

@@ -401,7 +401,7 @@ public void SendNotification(string method, object notification)
401401
{
402402
Id = requestId,
403403
Method = method,
404-
Params = request != null ? JObject.FromObject(request, Serializer.JsonSerializer) : null
404+
Params = request != null ? JToken.FromObject(request, Serializer.JsonSerializer) : null
405405
});
406406

407407
await responseCompletion.Task;
@@ -464,7 +464,7 @@ public void SendNotification(string method, object notification)
464464
{
465465
Id = requestId,
466466
Method = method,
467-
Params = request != null ? JObject.FromObject(request, Serializer.JsonSerializer) : null
467+
Params = request != null ? JToken.FromObject(request, Serializer.JsonSerializer) : null
468468
});
469469

470470
ServerMessage response = await responseCompletion.Task;
@@ -899,7 +899,7 @@ private void DispatchRequest(ServerMessage requestMessage)
899899
{
900900
Id = requestMessage.Id,
901901
Method = requestMessage.Method,
902-
Result = handlerTask.Result != null ? JObject.FromObject(handlerTask.Result, Serializer.JsonSerializer) : null
902+
Result = handlerTask.Result != null ? JToken.FromObject(handlerTask.Result, Serializer.JsonSerializer) : null
903903
});
904904
}
905905

0 commit comments

Comments
 (0)