Skip to content

Commit 1171678

Browse files
Merge pull request #102 from OmniSharp/bug/gh-98
Bug/gh #98
2 parents c919309 + efe2312 commit 1171678

14 files changed

+19
-7
lines changed

src/Client/Protocol/ServerMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ServerMessage
1414
/// <summary>
1515
/// The JSON-RPC protocol version.
1616
/// </summary>
17+
[JsonProperty("jsonrpc")]
1718
public string ProtocolVersion { get; set; } = "2.0";
1819

1920
/// <summary>

src/JsonRpc/Client/Notification.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace OmniSharp.Extensions.JsonRpc.Client
66
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
77
public class Notification
88
{
9+
[JsonProperty("jsonrpc")]
910
public string ProtocolVersion { get; } = "2.0";
1011

1112
public string Method { get; set; }

src/JsonRpc/Client/Request.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class Request
88
{
99
public object Id { get; set; }
1010

11+
[JsonProperty("jsonrpc")]
1112
public string ProtocolVersion { get; } = "2.0";
1213

1314
public string Method { get; set; }

src/JsonRpc/Client/Response.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public Response(object id, object result)
1717
Result = result;
1818
}
1919

20+
[JsonProperty("jsonrpc")]
2021
public string ProtocolVersion { get; set; } = "2.0";
2122

2223
public object Id { get; set; }

src/JsonRpc/RpcError.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public RpcError(object id, ErrorMessage<T> message, string protocolVersion)
2020
ProtocolVersion = protocolVersion;
2121
}
2222

23+
[JsonProperty("jsonrpc")]
2324
public string ProtocolVersion { get; set; }
2425

2526
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]

src/JsonRpc/RpcErrorConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
3636
data = dataToken.ToObject(errorMessageType, serializer);
3737
}
3838

39-
return Activator.CreateInstance(objectType, requestId, data, obj["protocolVersion"].ToString());
39+
return Activator.CreateInstance(objectType, requestId, data, obj["jsonrpc"].ToString());
4040
}
4141

4242
public override bool CanConvert(Type objectType)

src/JsonRpc/Server/Notification.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal Notification(
1818

1919
internal Notification(string method, JToken @params) : this(method, @params, "2.0") { }
2020

21+
[JsonProperty("jsonrpc")]
2122
public string ProtocolVersion { get; }
2223

2324
public string Method { get; }

src/JsonRpc/Server/Request.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal Request(
2222

2323
public object Id { get; }
2424

25+
[JsonProperty("jsonrpc")]
2526
public string ProtocolVersion { get; }
2627

2728
public string Method { get; }

src/JsonRpc/Server/ResponseBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
using Newtonsoft.Json.Serialization;
4+
15
namespace OmniSharp.Extensions.JsonRpc.Server
26
{
37
public class ResponseBase
@@ -7,8 +11,9 @@ public ResponseBase(object id)
711
Id = id;
812
}
913

14+
[JsonProperty("jsonrpc")]
1015
public string ProtocolVersion { get; set; } = "2.0";
1116

1217
public object Id { get; set; }
1318
}
14-
}
19+
}

test/JsonRpc.Tests/OutputHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public async Task ShouldSerializeValues()
5050

5151
handler.Send(value);
5252
await wait();
53-
const string send = "Content-Length: 43\r\n\r\n{\"protocolVersion\":\"2.0\",\"id\":1,\"result\":1}";
53+
const string send = "Content-Length: 35\r\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":1}";
5454
received.Should().Be(send);
5555
var b = System.Text.Encoding.UTF8.GetBytes(send);
5656
w.Received().Write(Arg.Any<byte[]>(), 0, b.Length); // can't compare b here, because it is only value-equal and this test tests reference equality

0 commit comments

Comments
 (0)