diff --git a/AustinHarris.JsonRpcTestN/AustinHarris.JsonRpcTestN.csproj b/AustinHarris.JsonRpcTestN/AustinHarris.JsonRpcTestN.csproj
index c5db038..84dc3ae 100644
--- a/AustinHarris.JsonRpcTestN/AustinHarris.JsonRpcTestN.csproj
+++ b/AustinHarris.JsonRpcTestN/AustinHarris.JsonRpcTestN.csproj
@@ -2,7 +2,7 @@
Austin Harris
- netcoreapp3.0;netcoreapp3.1
+ net5.0;netcoreapp3.0;netcoreapp3.1
diff --git a/AustinHarris.JsonRpcTestN/Test.cs b/AustinHarris.JsonRpcTestN/Test.cs
index ed46543..46e46dc 100644
--- a/AustinHarris.JsonRpcTestN/Test.cs
+++ b/AustinHarris.JsonRpcTestN/Test.cs
@@ -1,6 +1,7 @@
using NUnit.Framework;
using System;
using System.Linq;
+using System.Text.Json;
using AustinHarris.JsonRpc;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
@@ -42,7 +43,7 @@ static Test()
[Test()]
public void TestCanCreateMultipleServicesOfSameTypeInTheirOwnSessions()
{
- Func request = (int param) => String.Format("{{method:'add',params:[{0}],id:1}}", param);
+ Func request = (int param) => String.Format("{{\"method\":\"add\",\"params\":[{0}],\"id\":1}}", param);
Func expectedResult = (int param) => String.Format("{{\"jsonrpc\":\"2.0\",\"result\":{0},\"id\":1}}", param);
for (int i = 0; i < 100; i++)
@@ -70,7 +71,7 @@ public void TestCanCreateAndRemoveSession()
}.ToDictionary(x => x.Item1, x => x.Item2);
h.RegisterFuction("workie", metadata, new System.Collections.Generic.Dictionary(),new Func(x => "workie ... " + x));
- string request = @"{method:'workie',params:{'sooper':'good'},id:1}";
+ string request = @"{""method"":""workie"",""params"":{""sooper"":""good""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"workie ... good\",\"id\":1}";
string expectedResultAfterDestroy = "{\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Method not found\",\"code\":-32601,\"data\":\"The method does not exist / is not available.\"},\"id\":1}";
var result = JsonRpcProcessor.Process("this one", request);
@@ -92,7 +93,7 @@ public void TestCanCreateAndRemoveSession()
[Test()]
public void TestInProcessClient()
{
- string request = @"{method:'NullableFloatToNullableFloat',params:[0.0],id:1}";
+ string request = @"{""method"":""NullableFloatToNullableFloat"",""params"":[0.0],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":0.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -104,7 +105,7 @@ public void TestInProcessClient()
[Test()]
public void NullableDateTimeToNullableDateTime()
{
- string request = @"{method:'NullableDateTimeToNullableDateTime',params:['2014-06-30T14:50:38.5208399+09:00'],id:1}";
+ string request = @"{""method"":""NullableDateTimeToNullableDateTime"",""params"":[""2014-06-30T14:50:38.5208399+09:00""],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"2014-06-30T14:50:38.5208399+09:00\",\"id\":1}";
var expectedDate = DateTime.Parse("2014-06-30T14:50:38.5208399+09:00");
var result = JsonRpcProcessor.Process(request);
@@ -113,9 +114,9 @@ public void NullableDateTimeToNullableDateTime()
Assert.AreEqual(expectedDate, acutalDate);
}
- [TestCase(@"{method:'NullableFloatToNullableFloat',params:[1.2345],id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.2345,\"id\":1}")]
- [TestCase(@"{method:'NullableFloatToNullableFloat',params:[3.14159],id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":3.14159,\"id\":1}")]
- [TestCase(@"{method:'NullableFloatToNullableFloat',params:[null],id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":1}")]
+ [TestCase(@"{""method"":""NullableFloatToNullableFloat"",""params"":[1.2345],""id"":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.2345,\"id\":1}")]
+ [TestCase(@"{""method"":""NullableFloatToNullableFloat"",""params"":[3.14159],""id"":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":3.14159,\"id\":1}")]
+ [TestCase(@"{""method"":""NullableFloatToNullableFloat"",""params"":[null],""id"":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":1}")]
public string NullableFloatToNullableFloat(string request)
{
var result = JsonRpcProcessor.Process(request);
@@ -127,7 +128,7 @@ public string NullableFloatToNullableFloat(string request)
[Test()]
public void DecimalToNullableDecimal()
{
- string request = @"{method:'DecimalToNullableDecimal',params:[0.0],id:1}";
+ string request = @"{""method"":""DecimalToNullableDecimal"",""params"":[0.0],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":0.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -138,7 +139,7 @@ public void DecimalToNullableDecimal()
[Test()]
public void StringToListOfString()
{
- string request = @"{method:'StringToListOfString',params:['some string'],id:1}";
+ string request = @"{""method"":""StringToListOfString"",""params"":[""some string""],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[\"one\",\"two\",\"three\",\"some string\"],\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -149,18 +150,18 @@ public void StringToListOfString()
[Test()]
public void CustomStringToListOfString()
{
- string request = @"{method:'CustomStringToListOfString',params:[{str:'some string'}],id:1}";
+ string request = @"{""method"":""CustomStringToListOfString"",""params"":[{""str"":""some string""}],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[\"one\",\"two\",\"three\",\"some string\"],\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
- Assert.AreEqual(result.Result, expectedResult);
+ Assert.AreEqual(expectedResult, result.Result);
Assert.AreEqual(expectedResult, result.Result);
}
[Test()]
public void StringToThrowingException()
{
- string request = @"{method:'StringToThrowingException',params:['some string'],id:1}";
+ string request = @"{""method"":""StringToThrowingException"",""params"":[""some string""],""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
StringAssert.Contains("-32603", result.Result);
@@ -169,7 +170,7 @@ public void StringToThrowingException()
[Test()]
public void StringToRefException()
{
- string request = @"{method:'StringToRefException',params:['some string'],id:1}";
+ string request = @"{""method"":""StringToRefException"",""params"":[""some string""],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"refException worked\",\"code\":-1,\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -179,7 +180,7 @@ public void StringToRefException()
[Test()]
public void StringToThrowJsonRpcException()
{
- string request = @"{method:'StringToThrowJsonRpcException',params:['some string'],id:1}";
+ string request = @"{""method"":""StringToThrowJsonRpcException"",""params"":[""some string""],""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
StringAssert.Contains("-2700", result.Result);
@@ -188,20 +189,24 @@ public void StringToThrowJsonRpcException()
[Test()]
public void ReturnsDateTime()
{
- string request = @"{method:'ReturnsDateTime',params:[],id:1}";
+ string request = @"{""method"":""ReturnsDateTime"",""params"":[],""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
- Assert.IsFalse(result.Result.Contains("error"));
+
+ TestContext.Out.WriteLine(result.Result);
+ var rojb = JsonSerializer.Deserialize(result.Result);
+ Assert.AreSame(null, rojb.Error?.data);
}
[Test()]
public void ReturnsCustomRecursiveClass()
{
- string request = @"{method:'ReturnsCustomRecursiveClass',params:[],id:1}";
+ string request = @"{""method"":""ReturnsCustomRecursiveClass"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":{\"Nested1\":{\"Nested1\":null,\"Value1\":5},\"Value1\":10},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
- Assert.IsFalse(result.Result.Contains("error"));
+ var rojb = JsonSerializer.Deserialize(result.Result);
+ Assert.AreSame(null, rojb.Error?.data);
Assert.AreEqual(expectedResult, result.Result);
}
@@ -209,7 +214,7 @@ public void ReturnsCustomRecursiveClass()
[Test()]
public void FloatToFloat()
{
- string request = @"{method:'FloatToFloat',params:[0.123],id:1}";
+ string request = @"{""method"":""FloatToFloat"",""params"":[0.123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":0.123,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -221,7 +226,7 @@ public void FloatToFloat()
[Test()]
public void IntToInt()
{
- string request = @"{method:'IntToInt',params:[789],id:1}";
+ string request = @"{""method"":""IntToInt"",""params"":[789],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":789,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -232,7 +237,7 @@ public void IntToInt()
[Test()]
public void OptionalParamInt16()
{
- string request = @"{method:'TestOptionalParamInt16',params:[789],id:1}";
+ string request = @"{""method"":""TestOptionalParamInt16"",""params"":[789],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":789,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -243,7 +248,7 @@ public void OptionalParamInt16()
[Test()]
public void OptionalParamInt16NoParam()
{
- string request = @"{method:'TestOptionalParamInt16',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamInt16"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":789,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -254,7 +259,7 @@ public void OptionalParamInt16NoParam()
[Test()]
public void Int16ToInt16()
{
- string request = @"{method:'Int16ToInt16',params:[789],id:1}";
+ string request = @"{""method"":""Int16ToInt16"",""params"":[789],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":789,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -265,7 +270,7 @@ public void Int16ToInt16()
[Test()]
public void Int32ToInt32()
{
- string request = @"{method:'Int32ToInt32',params:[789],id:1}";
+ string request = @"{""method"":""Int32ToInt32"",""params"":[789],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":789,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -276,7 +281,7 @@ public void Int32ToInt32()
[Test()]
public void Int64ToInt64()
{
- string request = @"{method:'Int64ToInt64',params:[78915984515564],id:1}";
+ string request = @"{""method"":""Int64ToInt64"",""params"":[78915984515564],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":78915984515564,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -288,7 +293,7 @@ public void Int64ToInt64()
[Test()]
public void TestOptionalParamByteMissing()
{
- string request = @"{method:'TestOptionalParambyte',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParambyte"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -298,7 +303,7 @@ public void TestOptionalParamByteMissing()
[Test()]
public void TestOptionalParamSbyteMissing()
{
- string request = @"{method:'TestOptionalParamsbyte',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -308,7 +313,7 @@ public void TestOptionalParamSbyteMissing()
[Test()]
public void TestOptionalParamShortMissing()
{
- string request = @"{method:'TestOptionalParamshort',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamshort"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -318,7 +323,7 @@ public void TestOptionalParamShortMissing()
[Test()]
public void TestOptionalParamintMissing()
{
- string request = @"{method:'TestOptionalParamint',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamint"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -328,7 +333,7 @@ public void TestOptionalParamintMissing()
[Test()]
public void TestOptionalParamLongMissing()
{
- string request = @"{method:'TestOptionalParamlong',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamlong"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -338,7 +343,7 @@ public void TestOptionalParamLongMissing()
[Test()]
public void TestOptionalParamUshortMissing()
{
- string request = @"{method:'TestOptionalParamushort',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamushort"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -348,7 +353,7 @@ public void TestOptionalParamUshortMissing()
[Test()]
public void TestOptionalParamUintMissing()
{
- string request = @"{method:'TestOptionalParamuint',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamuint"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -358,7 +363,7 @@ public void TestOptionalParamUintMissing()
[Test()]
public void TestOptionalParamUlongMissing()
{
- string request = @"{method:'TestOptionalParamulong',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamulong"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -368,7 +373,7 @@ public void TestOptionalParamUlongMissing()
[Test()]
public void TestOptionalParamFloatMissing()
{
- string request = @"{method:'TestOptionalParamfloat',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -378,7 +383,7 @@ public void TestOptionalParamFloatMissing()
[Test()]
public void TestOptionalParamDoubleMissing()
{
- string request = @"{method:'TestOptionalParamdouble',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -388,7 +393,7 @@ public void TestOptionalParamDoubleMissing()
[Test()]
public void TestOptionalParamBoolMissing()
{
- string request = @"{method:'TestOptionalParambool',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParambool"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -398,7 +403,7 @@ public void TestOptionalParamBoolMissing()
[Test()]
public void TestOptionalParamCharMissing()
{
- string request = @"{method:'TestOptionalParamchar',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamchar"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"a\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -408,7 +413,7 @@ public void TestOptionalParamCharMissing()
[Test()]
public void TestOptionalParamDecimalMissing()
{
- string request = @"{method:'TestOptionalParamdecimal',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -419,7 +424,7 @@ public void TestOptionalParamDecimalMissing()
[Test()]
public void TestOptionalParamBytePresent()
{
- string request = @"{method:'TestOptionalParambyte',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParambyte"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -429,7 +434,7 @@ public void TestOptionalParamBytePresent()
[Test()]
public void TestOptionalParamSbytePresent()
{
- string request = @"{method:'TestOptionalParamsbyte',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -439,7 +444,7 @@ public void TestOptionalParamSbytePresent()
[Test()]
public void TestOptionalParamShortPresent()
{
- string request = @"{method:'TestOptionalParamshort',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamshort"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -449,7 +454,7 @@ public void TestOptionalParamShortPresent()
[Test()]
public void TestOptionalParamintPresent()
{
- string request = @"{method:'TestOptionalParamint',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamint"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -459,7 +464,7 @@ public void TestOptionalParamintPresent()
[Test()]
public void TestOptionalParamLongPresent()
{
- string request = @"{method:'TestOptionalParamlong',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamlong"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -469,7 +474,7 @@ public void TestOptionalParamLongPresent()
[Test()]
public void TestOptionalParamUshortPresent()
{
- string request = @"{method:'TestOptionalParamushort',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamushort"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -479,7 +484,7 @@ public void TestOptionalParamUshortPresent()
[Test()]
public void TestOptionalParamUintPresent()
{
- string request = @"{method:'TestOptionalParamuint',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamuint"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -489,7 +494,7 @@ public void TestOptionalParamUintPresent()
[Test()]
public void TestOptionalParamUlongPresent()
{
- string request = @"{method:'TestOptionalParamulong',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamulong"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -499,7 +504,7 @@ public void TestOptionalParamUlongPresent()
[Test()]
public void TestOptionalParamFloatPresent()
{
- string request = @"{method:'TestOptionalParamfloat',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -509,7 +514,7 @@ public void TestOptionalParamFloatPresent()
[Test()]
public void TestOptionalParamDoublePresent()
{
- string request = @"{method:'TestOptionalParamdouble',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -519,7 +524,7 @@ public void TestOptionalParamDoublePresent()
[Test()]
public void TestOptionalParamBoolPresent()
{
- string request = @"{method:'TestOptionalParambool',params:[false],id:1}";
+ string request = @"{""method"":""TestOptionalParambool"",""params"":[false],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":false,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -529,7 +534,7 @@ public void TestOptionalParamBoolPresent()
[Test()]
public void TestOptionalParamCharPresent()
{
- string request = @"{method:'TestOptionalParamchar',params:[" + (int)'b' + "],id:1}";
+ string request = @"{""method"":""TestOptionalParamchar"",""params"":[" + (int)'b' + @"],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"b\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -539,7 +544,7 @@ public void TestOptionalParamCharPresent()
[Test()]
public void TestOptionalParamDecimalPresent()
{
- string request = @"{method:'TestOptionalParamdecimal',params:[71],id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal"",""params"":[71],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -550,7 +555,7 @@ public void TestOptionalParamDecimalPresent()
[Test()]
public void TestOptionalParamBytePresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParambyte',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParambyte"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -560,7 +565,7 @@ public void TestOptionalParamBytePresentObjectSyntax()
[Test()]
public void TestOptionalParamSbytePresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamsbyte',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -570,7 +575,7 @@ public void TestOptionalParamSbytePresentObjectSyntax()
[Test()]
public void TestOptionalParamShortPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamshort',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamshort"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -580,7 +585,7 @@ public void TestOptionalParamShortPresentObjectSyntax()
[Test()]
public void TestOptionalParamintPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamint',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamint"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -590,7 +595,7 @@ public void TestOptionalParamintPresentObjectSyntax()
[Test()]
public void TestOptionalParamLongPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamlong',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamlong"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -600,7 +605,7 @@ public void TestOptionalParamLongPresentObjectSyntax()
[Test()]
public void TestOptionalParamUshortPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamushort',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamushort"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -610,7 +615,7 @@ public void TestOptionalParamUshortPresentObjectSyntax()
[Test()]
public void TestOptionalParamUintPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamuint',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamuint"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -620,7 +625,7 @@ public void TestOptionalParamUintPresentObjectSyntax()
[Test()]
public void TestOptionalParamUlongPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamulong',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamulong"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -630,7 +635,7 @@ public void TestOptionalParamUlongPresentObjectSyntax()
[Test()]
public void TestOptionalParamFloatPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamfloat',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -640,7 +645,7 @@ public void TestOptionalParamFloatPresentObjectSyntax()
[Test()]
public void TestOptionalParamDoublePresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdouble',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -650,7 +655,7 @@ public void TestOptionalParamDoublePresentObjectSyntax()
[Test()]
public void TestOptionalParamBoolPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParambool',params:{'input':false},id:1}";
+ string request = @"{""method"":""TestOptionalParambool"",""params"":{""input"":false},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":false,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -660,7 +665,7 @@ public void TestOptionalParamBoolPresentObjectSyntax()
[Test()]
public void TestOptionalParamCharPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamchar',params:{'input':" + (int)'c' + "},id:1}";
+ string request = @"{""method"":""TestOptionalParamchar"",""params"":{""input"":" + (int)'c' + @"},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"c\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -670,7 +675,7 @@ public void TestOptionalParamCharPresentObjectSyntax()
[Test()]
public void TestOptionalParamDecimalPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdecimal',params:{'input':71},id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal"",""params"":{""input"":71},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":71.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -681,7 +686,7 @@ public void TestOptionalParamDecimalPresentObjectSyntax()
[Test()]
public void TestOptionalParamByteMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParambyte',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParambyte"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -691,7 +696,7 @@ public void TestOptionalParamByteMissingObjectSyntax()
[Test()]
public void TestOptionalParamSbyteMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamsbyte',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -701,7 +706,7 @@ public void TestOptionalParamSbyteMissingObjectSyntax()
[Test()]
public void TestOptionalParamShortMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamshort',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamshort"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -711,7 +716,7 @@ public void TestOptionalParamShortMissingObjectSyntax()
[Test()]
public void TestOptionalParamintMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamint',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamint"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -721,7 +726,7 @@ public void TestOptionalParamintMissingObjectSyntax()
[Test()]
public void TestOptionalParamLongMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamlong',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamlong"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -731,7 +736,7 @@ public void TestOptionalParamLongMissingObjectSyntax()
[Test()]
public void TestOptionalParamUshortMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamushort',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamushort"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -741,7 +746,7 @@ public void TestOptionalParamUshortMissingObjectSyntax()
[Test()]
public void TestOptionalParamUintMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamuint',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamuint"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -751,7 +756,7 @@ public void TestOptionalParamUintMissingObjectSyntax()
[Test()]
public void TestOptionalParamUlongMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamulong',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamulong"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -761,7 +766,7 @@ public void TestOptionalParamUlongMissingObjectSyntax()
[Test()]
public void TestOptionalParamFloatMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamfloat',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -771,7 +776,7 @@ public void TestOptionalParamFloatMissingObjectSyntax()
[Test()]
public void TestOptionalParamDoubleMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdouble',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -781,7 +786,7 @@ public void TestOptionalParamDoubleMissingObjectSyntax()
[Test()]
public void TestOptionalParamBoolMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParambool',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParambool"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -791,7 +796,7 @@ public void TestOptionalParamBoolMissingObjectSyntax()
[Test()]
public void TestOptionalParamCharMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamchar',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamchar"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"a\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -801,7 +806,7 @@ public void TestOptionalParamCharMissingObjectSyntax()
[Test()]
public void TestOptionalParamDecimalMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdecimal',params:{},id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal"",""params"":{},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":1.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -812,7 +817,7 @@ public void TestOptionalParamDecimalMissingObjectSyntax()
[Test()]
public void TestOptionalParamByte_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParambyte_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParambyte_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":98,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -822,7 +827,7 @@ public void TestOptionalParamByte_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamSbyte_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamsbyte_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":126,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -832,7 +837,7 @@ public void TestOptionalParamSbyte_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamShort_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamshort_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamshort_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -842,7 +847,7 @@ public void TestOptionalParamShort_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamint_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamint_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamint_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -852,7 +857,7 @@ public void TestOptionalParamint_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamLong_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamlong_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamlong_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -862,7 +867,7 @@ public void TestOptionalParamLong_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamUshort_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamushort_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamushort_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -872,7 +877,7 @@ public void TestOptionalParamUshort_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamUint_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamuint_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamuint_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -882,7 +887,7 @@ public void TestOptionalParamUint_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamUlong_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamulong_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamulong_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -892,7 +897,7 @@ public void TestOptionalParamUlong_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamFloat_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamfloat_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -902,7 +907,7 @@ public void TestOptionalParamFloat_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamDouble_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdouble_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -912,7 +917,7 @@ public void TestOptionalParamDouble_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamBool_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParambool_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParambool_2x"",""params"":{input1:123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -922,7 +927,7 @@ public void TestOptionalParamBool_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamChar_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamchar_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamchar_2x"",""params"":{""input1"":123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"d\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -932,7 +937,7 @@ public void TestOptionalParamChar_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamDecimal_2ndMissingObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdecimal_2x',params:{input1:123},id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal_2x"",""params"":{""input1"":123},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -943,7 +948,7 @@ public void TestOptionalParamDecimal_2ndMissingObjectSyntax()
[Test()]
public void TestOptionalParamByte_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParambyte_2x',params:{input1:123, input2: 67},id:1}";
+ string request = @"{""method"":""TestOptionalParambyte_2x"",""params"":{""input1"":123, input2: 67},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":67,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -953,7 +958,7 @@ public void TestOptionalParamByte_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamByte_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParambyte_2x',params:[123, 67],id:1}";
+ string request = @"{""method"":""TestOptionalParambyte_2x"",""params"":[123, 67],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":67,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -963,7 +968,7 @@ public void TestOptionalParamByte_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamByte_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParambyte_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParambyte_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":98,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -973,7 +978,7 @@ public void TestOptionalParamByte_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamSbyte_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamsbyte_2x',params:{input1:123, input2: 97},id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte_2x"",""params"":{""input1"":123, input2: 97},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":97,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -983,7 +988,7 @@ public void TestOptionalParamSbyte_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamSbyte_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamsbyte_2x',params:[123, 98],id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte_2x"",""params"":[123, 98],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":98,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -993,7 +998,7 @@ public void TestOptionalParamSbyte_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamSbyte_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamsbyte_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamsbyte_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":126,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1003,7 +1008,7 @@ public void TestOptionalParamSbyte_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamShort_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamshort_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamshort_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1013,7 +1018,7 @@ public void TestOptionalParamShort_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamShort_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamshort_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamshort_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1023,7 +1028,7 @@ public void TestOptionalParamShort_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamShort_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamshort_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamshort_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1033,7 +1038,7 @@ public void TestOptionalParamShort_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamint_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamint_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamint_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1043,7 +1048,7 @@ public void TestOptionalParamint_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamint_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamint_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamint_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1053,7 +1058,7 @@ public void TestOptionalParamint_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamint_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamint_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamint_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1063,7 +1068,7 @@ public void TestOptionalParamint_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamLong_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamlong_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamlong_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1073,7 +1078,7 @@ public void TestOptionalParamLong_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamLong_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamlong_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamlong_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1083,7 +1088,7 @@ public void TestOptionalParamLong_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamLong_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamlong_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamlong_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1093,7 +1098,7 @@ public void TestOptionalParamLong_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamUshort_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamushort_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamushort_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1103,7 +1108,7 @@ public void TestOptionalParamUshort_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamUshort_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamushort_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamushort_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1113,7 +1118,7 @@ public void TestOptionalParamUshort_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamUshort_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamushort_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamushort_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1123,7 +1128,7 @@ public void TestOptionalParamUshort_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamUint_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamuint_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamuint_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1133,7 +1138,7 @@ public void TestOptionalParamUint_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamUint_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamuint_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamuint_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1143,7 +1148,7 @@ public void TestOptionalParamUint_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamUint_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamuint_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamuint_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1153,7 +1158,7 @@ public void TestOptionalParamUint_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamUlong_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamulong_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamulong_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1163,7 +1168,7 @@ public void TestOptionalParamUlong_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamUlong_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamulong_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamulong_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1173,7 +1178,7 @@ public void TestOptionalParamUlong_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamUlong_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamulong_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamulong_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1183,7 +1188,7 @@ public void TestOptionalParamUlong_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamFloat_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamfloat_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1193,7 +1198,7 @@ public void TestOptionalParamFloat_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamFloat_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamfloat_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1203,7 +1208,7 @@ public void TestOptionalParamFloat_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamFloat_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamfloat_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamfloat_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1213,7 +1218,7 @@ public void TestOptionalParamFloat_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamDouble_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdouble_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1223,7 +1228,7 @@ public void TestOptionalParamDouble_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamDouble_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamdouble_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1233,7 +1238,7 @@ public void TestOptionalParamDouble_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamDouble_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamdouble_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1243,7 +1248,7 @@ public void TestOptionalParamDouble_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamBool_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParambool_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParambool_2x"",""params"":{""input1"":123, input2: 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1253,7 +1258,7 @@ public void TestOptionalParamBool_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamBool_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParambool_2x',params:[true, false],id:1}";
+ string request = @"{""method"":""TestOptionalParambool_2x"",""params"":[true, false],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":false,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1263,7 +1268,7 @@ public void TestOptionalParamBool_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamBool_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParambool_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParambool_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1273,7 +1278,7 @@ public void TestOptionalParamBool_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamChar_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamchar_2x',params:{'input1':" + (int)'c' + ", 'input2':" + (int)'d' + "},id:1}";
+ string request = @"{""method"":""TestOptionalParamchar_2x"",""params"":{""input1"":" + (int)'c' + @", ""input2"":" + (int)'d' + @"},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"d\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1283,7 +1288,7 @@ public void TestOptionalParamChar_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamChar_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamchar_2x',params:[" + (int)'c' + ", " + (int)'d' + "],id:1}";
+ string request = @"{""method"":""TestOptionalParamchar_2x"",""params"":[" + (int)'c' + ", " + (int)'d' + @"],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"d\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1293,7 +1298,7 @@ public void TestOptionalParamChar_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamChar_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamchar_2x',params:[" + (int)'c' + "],id:1}";
+ string request = @"{""method"":""TestOptionalParamchar_2x"",""params"":[" + (int)'c' + @"],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"d\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1303,7 +1308,7 @@ public void TestOptionalParamChar_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParamDecimal_2ndPresentObjectSyntax()
{
- string request = @"{method:'TestOptionalParamdecimal_2x',params:{input1:123, input2: 671},id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal_2x"",""params"":{""input1"":123, ""input2"": 671},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1313,7 +1318,7 @@ public void TestOptionalParamDecimal_2ndPresentObjectSyntax()
[Test()]
public void TestOptionalParamDecimal_2ndPresentArraySyntax()
{
- string request = @"{method:'TestOptionalParamdecimal_2x',params:[123, 671],id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal_2x"",""params"":[123, 671],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":671.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1323,7 +1328,7 @@ public void TestOptionalParamDecimal_2ndPresentArraySyntax()
[Test()]
public void TestOptionalParamDecimal_2ndMissingArraySyntax()
{
- string request = @"{method:'TestOptionalParamdecimal_2x',params:[123],id:1}";
+ string request = @"{""method"":""TestOptionalParamdecimal_2x"",""params"":[123],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":987.0,\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1334,7 +1339,7 @@ public void TestOptionalParamDecimal_2ndMissingArraySyntax()
[Test()]
public void TestOptionalParametersStrings_BothMissing()
{
- string request = @"{method:'TestOptionalParameters_Strings',params:[],id:1}";
+ string request = @"{""method"":""TestOptionalParameters_Strings"",""params"":[],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[null,null],\"id\":1}";
var result = JsonRpcProcessor.Process(request);
@@ -1346,7 +1351,7 @@ public void TestOptionalParametersStrings_BothMissing()
[Test()]
public void TestOptionalParametersStrings_SecondMissing()
{
- string request = @"{method:'TestOptionalParameters_Strings',params:['first'],id:1}";
+ string request = @"{""method"":""TestOptionalParameters_Strings"",""params"":[""first""],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[\"first\",null],\"id\":1}";
var result = JsonRpcProcessor.Process(request);
@@ -1358,7 +1363,7 @@ public void TestOptionalParametersStrings_SecondMissing()
[Test()]
public void TestOptionalParametersStrings_BothExists()
{
- string request = @"{method:'TestOptionalParameters_Strings',params:['first','second'],id:1}";
+ string request = @"{""method"":""TestOptionalParameters_Strings"",""params"":[""first"",""second""],""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":[\"first\",\"second\"],\"id\":1}";
var result = JsonRpcProcessor.Process(request);
@@ -1380,11 +1385,11 @@ public void TestOptionalParametersBoolsAndStrings()
Assert.AreEqual(expectedResult, result.Result);
}
- [TestCase("{method:\"TestDifferentOptionalParameters\",params:{location:\"loc1\", uid:\"abc123\", wavelengths: [0.0], traces: [0.0]},id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
- [TestCase("{method:\"TestDifferentOptionalParameters\",params:{uid:\"abc123\", wavelengths: [0.0], traces: [0.0]},id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
- [TestCase("{method:\"TestDifferentOptionalParameters\",params:{location:\"loc1\", uid:\"abc123\", traces: [0.0]},id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
- [TestCase("{method:\"TestDifferentOptionalParameters\",params:{location:\"loc1\", uid:\"abc123\", wavelengths: [0.0]},id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
- [TestCase("{method:\"TestDifferentOptionalParameters\",params:{uid:\"abc123\", wavelengths: [0.0]},id:1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
+ [TestCase("{\"method\":\"TestDifferentOptionalParameters\",\"params\":{\"location\":\"loc1\", \"uid\":\"abc123\", \"wavelengths\": [0.0], \"traces\": [0.0]},\"id\":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
+ [TestCase("{\"method\":\"TestDifferentOptionalParameters\",\"params\":{\"uid\":\"abc123\", \"wavelengths\": [0.0], \"traces\": [0.0]},\"id\":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
+ [TestCase("{\"method\":\"TestDifferentOptionalParameters\",\"params\":{\"location\":\"loc1\", \"uid\":\"abc123\", \"traces\": [0.0]},\"id\":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
+ [TestCase("{\"method\":\"TestDifferentOptionalParameters\",\"params\":{\"location\":\"loc1\", \"uid\":\"abc123\", \"wavelengths\": [0.0]},\"id\":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
+ [TestCase("{\"method\":\"TestDifferentOptionalParameters\",\"params\":{\"uid\":\"abc123\", \"wavelengths\": [0.0]},\"id\":1}", ExpectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"this is the requested measurement\",\"id\":1}")]
public string TestDifferentOptionalParametersNamedWorking(string request)
{
var result = JsonRpcProcessor.Process(request);
@@ -1434,7 +1439,7 @@ public void TestNotificationVoidResult()
var result = JsonRpcProcessor.Process(secondRequest);
result.Wait();
Console.WriteLine(result.Result);
- Assert.IsTrue(result.Result.Contains("result"), "Json Rpc 2.0 Spec - 'result' - This member is REQUIRED on success. A function that returns void should have the result property included even though the value may be null.");
+ Assert.IsTrue(result.Result.Contains("result"), "Json Rpc 2.0 Spec - \"result\" - This member is REQUIRED on success. A function that returns void should have the result property included even though the value may be null.");
}
[Test()]
@@ -1492,7 +1497,7 @@ public void TestPreProcessor()
try {
PreProcessHandlerLocal handler = new PreProcessHandlerLocal();
Config.SetPreProcessHandler(new PreProcessHandler(handler.PreProcess));
- string request = @"{method:'TestPreProcessor',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPreProcessor"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"Success!\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1513,7 +1518,7 @@ public void TestPreProcessorThrowsJsonRPCException()
{
PreProcessHandlerLocal handler = new PreProcessHandlerLocal();
Config.SetPreProcessHandler(new PreProcessHandler(handler.PreProcess));
- string request = @"{method:'TestPreProcessorThrowsJsonRPCException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPreProcessorThrowsJsonRPCException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-27000,\"message\":\"Just some testing\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1535,7 +1540,7 @@ public void TestPreProcessorThrowsException()
{
PreProcessHandlerLocal handler = new PreProcessHandlerLocal();
Config.SetPreProcessHandler(new PreProcessHandler(handler.PreProcess));
- string request = @"{method:'TestPreProcessorThrowsException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPreProcessorThrowsException"",""params"":{""inputValue"":""some string""},""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
StringAssert.Contains("-32603", result.Result);
@@ -1556,7 +1561,7 @@ public void TestPreProcessorSetsException()
{
PreProcessHandlerLocal handler = new PreProcessHandlerLocal();
Config.SetPreProcessHandler(new PreProcessHandler(handler.PreProcess));
- string request = @"{method:'TestPreProcessorSetsException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPreProcessorSetsException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-27000,\"message\":\"This exception was thrown using: JsonRpcContext.SetException()\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1585,7 +1590,7 @@ public void TestPreProcessOnSession()
}.ToDictionary(x => x.Item1, x => x.Item2);
h.RegisterFuction("workie", metadata, new System.Collections.Generic.Dictionary(),new Func(x => "workie ... " + x));
- string request = @"{method:'workie',params:{'sooper':'good'},id:1}";
+ string request = @"{""method"":""workie"",""params"":{""sooper"":""good""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"workie ... good\",\"id\":1}";
string expectedResultAfterDestroy = "{\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Method not found\",\"code\":-32601,\"data\":\"The method does not exist / is not available.\"},\"id\":1}";
var result = JsonRpcProcessor.Process(sessionId, request);
@@ -1641,7 +1646,7 @@ public void TestPostProcessor()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(false);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessor',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessor"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"Success!\",\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1665,7 +1670,7 @@ public void TestPostProcessorThrowsJsonRPCException()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(false);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessorThrowsJsonRPCException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessorThrowsJsonRPCException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-27000,\"message\":\"Just some testing\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1692,7 +1697,7 @@ public void TestPostProcessorThrowsException()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(false);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessorThrowsException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessorThrowsException"",""params"":{inputValue:""some string""},""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
StringAssert.Contains("-32603", result.Result);
@@ -1717,7 +1722,7 @@ public void TestPostProcessorSetsException()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(false);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessorSetsException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessorSetsException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-27001,\"message\":\"This exception was thrown using: JsonRpcContext.SetException()\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1740,7 +1745,7 @@ public void TestPostProcessorChangesReturn()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(true);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessor',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessor"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-123,\"message\":\"Test error\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1765,7 +1770,7 @@ public void TestPostProcessorThrowsJsonRPCExceptionChangesReturn()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(true);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessorThrowsJsonRPCException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessorThrowsJsonRPCException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-123,\"message\":\"Test error\",\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1792,7 +1797,7 @@ public void TestPostProcessorThrowsExceptionChangesReturn()
{
PostProcessHandlerLocal handler = new PostProcessHandlerLocal(true);
Config.SetPostProcessHandler(new PostProcessHandler(handler.PostProcess));
- string request = @"{method:'TestPostProcessorThrowsException',params:{inputValue:'some string'},id:1}";
+ string request = @"{""method"":""TestPostProcessorThrowsException"",""params"":{inputValue:""some string""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Test error\",\"code\":-123,\"data\":null},\"id\":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
@@ -1825,7 +1830,7 @@ public void TestPostProcessOnSession()
}.ToDictionary(x => x.Item1, x => x.Item2);
h.RegisterFuction("workie", metadata, new System.Collections.Generic.Dictionary(), new Func(x => "workie ... " + x));
- string request = @"{method:'workie',params:{'sooper':'good'},id:1}";
+ string request = @"{""method"":""workie"",""params"":{""sooper"":""good""},""id"":1}";
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":\"workie ... good\",\"id\":1}";
string expectedResultAfterDestroy = "{\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"Method not found\",\"code\":-32601,\"data\":\"The method does not exist / is not available.\"},\"id\":1}";
var result = JsonRpcProcessor.Process(sessionId, request);
@@ -1848,7 +1853,7 @@ public void TestPostProcessOnSession()
[Test()]
public void TestExtraParameters()
{
- string request = @"{method:'ReturnsDateTime',params:{extra:'mytext'},id:1}";
+ string request = @"{""method"":""ReturnsDateTime"",""params"":{extra:""mytext""},""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsTrue(result.Result.Contains("error"));
@@ -1858,7 +1863,7 @@ public void TestExtraParameters()
[Test()]
public void TestExtraPositionalParameters()
{
- string request = @"{method:'ReturnsDateTime',params:[1,2,'mytext'],id:1}";
+ string request = @"{""method"":""ReturnsDateTime"",""params"":[1,2,""mytext""],""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsTrue(result.Result.Contains("error"));
@@ -1868,7 +1873,7 @@ public void TestExtraPositionalParameters()
[Test()]
public void TestCustomParameterName()
{
- Func request = (string paramName) => String.Format("{{method:'TestCustomParameterName',params:{{ {0}:'some string'}},id:1}}", paramName);
+ Func request = (string paramName) => String.Format("{{\"method\":\"TestCustomParameterName\",\"params\":{{ {0}:\"some string\"}},\"id\":1}}", paramName);
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
// Check custom param name specified in attribute works
var result = JsonRpcProcessor.Process(request("myCustomParameter"));
@@ -1877,13 +1882,13 @@ public void TestCustomParameterName()
// Check method can't be used with its actual parameter name
result = JsonRpcProcessor.Process(request("arg"));
result.Wait();
- StringAssert.Contains("-32602", result.Result); // check for 'invalid params' error code
+ StringAssert.Contains("-32602", result.Result); // check for ""invalid params"" error code
}
[Test()]
public void TestCustomParameterWithNoSpecificName()
{
- Func request = (string paramName) => String.Format("{{method:'TestCustomParameterWithNoSpecificName',params:{{ {0}:'some string'}},id:1}}", paramName);
+ Func request = (string paramName) => String.Format("{{\"method\":\"TestCustomParameterWithNoSpecificName\",\"params\":{{ {0}:\"some string\"}},\"id\":1}}", paramName);
string expectedResult = "{\"jsonrpc\":\"2.0\",\"result\":true,\"id\":1}";
// Check method can be used with its parameter name
var result = JsonRpcProcessor.Process(request("arg"));
@@ -1904,7 +1909,7 @@ public void TestNestedReturnType()
[Test()]
public void TestWrongParamType()
{
- string request = @"{method:'TestOptionalParamdouble',params:{input:'mytext'},id:1}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":{input:""mytext""},""id"":1}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsTrue(result.Result.Contains("error"));
@@ -1914,7 +1919,7 @@ public void TestWrongParamType()
[Test()]
public void TestWrongIdType()
{
- string request = @"{method:'TestOptionalParamdouble',params:{input:5},id:{what:4,that:3}}";
+ string request = @"{""method"":""TestOptionalParamdouble"",""params"":{input:5},""id"":{what:4,that:3}}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsTrue(result.Result.Contains("error"));
diff --git a/AustinHarris.JsonRpcTestN/service.cs b/AustinHarris.JsonRpcTestN/service.cs
index b34d957..0fe8a82 100644
--- a/AustinHarris.JsonRpcTestN/service.cs
+++ b/AustinHarris.JsonRpcTestN/service.cs
@@ -54,7 +54,7 @@ private List StringToThrowingException(string input)
public class CustomString
{
- public string str;
+ public string str { get; set; }
}
[JsonRpcMethod]
diff --git a/Json-Rpc/AustinHarris.JsonRpc.csproj b/Json-Rpc/AustinHarris.JsonRpc.csproj
index 2f48389..297278c 100644
--- a/Json-Rpc/AustinHarris.JsonRpc.csproj
+++ b/Json-Rpc/AustinHarris.JsonRpc.csproj
@@ -7,6 +7,7 @@
1.2.2
$(VersionSuffix)
Austin Harris
+ 8.0
https://github.com/Astn/JSON-RPC.NET
https://raw.githubusercontent.com/Astn/JSON-RPC.NET/master/LICENSE
@@ -14,14 +15,13 @@
Fixes protocol validation of the ID property - @pedrolcl https://github.com/pedrolcl
DotNet Core support - @astn https://github.com/astn
- netstandard2.0;netstandard2.1;netcoreapp3.1
+ netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0
true
-
-
+
\ No newline at end of file
diff --git a/Json-Rpc/Handler.cs b/Json-Rpc/Handler.cs
index 1c746b5..f0081f7 100644
--- a/Json-Rpc/Handler.cs
+++ b/Json-Rpc/Handler.cs
@@ -1,14 +1,14 @@
-namespace AustinHarris.JsonRpc
+using System.Text.Json;
+
+namespace AustinHarris.JsonRpc
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
- using Newtonsoft.Json;
using System.Threading.Tasks;
using System.Collections.Concurrent;
- using Newtonsoft.Json.Linq;
using System.Threading;
public class Handler
@@ -221,7 +221,7 @@ public JsonResponse Handle(JsonRequest Rpc, Object RpcContext = null)
JsonResponse response = new JsonResponse()
{
Result = null,
- Error = new JsonRpcException(-32601, "Method not found", "The method does not exist / is not available."),
+ Error = JsonRpcException.Ex_32601,
Id = Rpc.Id
};
return PostProcess(Rpc, response, RpcContext);
@@ -232,37 +232,48 @@ public JsonResponse Handle(JsonRequest Rpc, Object RpcContext = null)
var metaDataParamCount = metadata.parameters.Count(x => x != null);
- var loopCt = 0;
- var getCount = Rpc.Params as ICollection;
- if (getCount != null)
+
+ JsonElement p = (JsonElement) Rpc.Params;
+
+ if (p.ValueKind == JsonValueKind.Array)
{
- loopCt = getCount.Count;
+ var loopCt = p.GetArrayLength();
+ var paramCount = loopCt;
+ if (paramCount == metaDataParamCount - 1 && metadata.parameters[metaDataParamCount - 1].ObjectType.Name.Equals(Name_of_JSONRPCEXCEPTION))
+ {
+ paramCount++;
+ expectsRefException = true;
+ }
+ parameters = new object[paramCount];
+ var enu = p.EnumerateArray();
+ for (int i = 0; enu.MoveNext() && i < metadata.parameters.Length; i++)
+ {
+
+ parameters[i] = metadata.parameters[i].ExtractValue(enu.Current);
+ }
}
-
- var paramCount = loopCt;
- if (paramCount == metaDataParamCount - 1 && metadata.parameters[metaDataParamCount - 1].ObjectType.Name.Equals(Name_of_JSONRPCEXCEPTION))
+ else if (p.ValueKind == JsonValueKind.Object)
{
- paramCount++;
- expectsRefException = true;
- }
- parameters = new object[paramCount];
+ var enu = p.EnumerateObject();
+ var asDict = new Dictionary();
+ foreach (var entry in enu)
+ {
+ asDict.Add(entry.Name,entry.Value);
+ }
- if (Rpc.Params is Newtonsoft.Json.Linq.JArray)
- {
- var jarr = ((Newtonsoft.Json.Linq.JArray)Rpc.Params);
- for (int i = 0; i < loopCt && i < metadata.parameters.Length; i++)
+ var loopCt = asDict.Count;
+ var paramCount = loopCt;
+ if (paramCount == metaDataParamCount - 1 && metadata.parameters[metaDataParamCount - 1].ObjectType.Name.Equals(Name_of_JSONRPCEXCEPTION))
{
- parameters[i] = CleanUpParameter(jarr[i], metadata.parameters[i]);
+ paramCount++;
+ expectsRefException = true;
}
- }
- else if (Rpc.Params is Newtonsoft.Json.Linq.JObject)
- {
- var asDict = Rpc.Params as IDictionary;
+ parameters = new object[paramCount];
for (int i = 0; i < loopCt && i < metadata.parameters.Length; i++)
{
if (asDict.ContainsKey(metadata.parameters[i].Name) == true)
{
- parameters[i] = CleanUpParameter(asDict[metadata.parameters[i].Name], metadata.parameters[i]);
+ parameters[i] = metadata.parameters[i].ExtractValue(asDict[metadata.parameters[i].Name]);
continue;
}
else
@@ -427,68 +438,6 @@ internal void SetParseErrorHandler(Func(this JsonElement element, JsonSerializerOptions options = null)
+ // {
+ // var bufferWriter = new System.Buffers.ArrayBufferWriter();
+ // using (var writer = new Utf8JsonWriter(bufferWriter))
+ // {
+ // element.WriteTo(writer);
+ // }
+ //
+ // return JsonSerializer.Deserialize(bufferWriter.WrittenSpan, options);
+ // }
+
+ // public static T ToObject(this JsonDocument document, JsonSerializerOptions options = null)
+ // {
+ // if (document == null)
+ // {
+ // throw new ArgumentNullException(nameof(document));
+ // }
+ //
+ // return document.RootElement.ToObject(options);
+ // }
+ //
+ public static object ToObject(this JsonElement element, Type returnType, JsonSerializerOptions options = null)
+ {
+ //var bw = new ArrayBufferWriter();
+ var ms = new MemoryStream();
+
+ using (var w = new Utf8JsonWriter(ms))
+ {
+ element.WriteTo(w);
+ }
+
+ return JsonSerializer.Deserialize(ms.GetBuffer().AsSpan(0,(int)ms.Position), returnType, options);
+ }
+ //
+ // public static object ToObject(this JsonDocument document, Type returnType, JsonSerializerOptions options = null)
+ // {
+ // if (document == null)
+ // {
+ // throw new ArgumentNullException(nameof(document));
+ // }
+ //
+ // return document.RootElement.ToObject(returnType, options);
+ // }
+ }
+}
\ No newline at end of file
diff --git a/Json-Rpc/JsonRequest.cs b/Json-Rpc/JsonRequest.cs
index e68c1ff..46a952a 100644
--- a/Json-Rpc/JsonRequest.cs
+++ b/Json-Rpc/JsonRequest.cs
@@ -1,37 +1,37 @@
-using Newtonsoft.Json;
+
+using System.Text.Json;
namespace AustinHarris.JsonRpc
{
///
/// Represents a JsonRpc request
///
- [JsonObject(MemberSerialization.OptIn)]
public class JsonRequest
{
public JsonRequest()
{
}
- public JsonRequest(string method, object pars, object id)
+ public JsonRequest(string method, JsonElement pars, JsonElement id)
{
Method = method;
Params = pars;
Id = id;
}
- [JsonProperty("jsonrpc")]
+
public string JsonRpc
{
get { return "2.0"; }
}
- [JsonProperty("method")]
+
public string Method { get; set; }
- [JsonProperty("params")]
- public object Params { get; set; }
- [JsonProperty("id")]
- public object Id { get; set; }
+ public JsonElement Params { get; set; }
+
+
+ public JsonElement Id { get; set; }
}
}
diff --git a/Json-Rpc/JsonResponse.cs b/Json-Rpc/JsonResponse.cs
index 941de82..fce07df 100644
--- a/Json-Rpc/JsonResponse.cs
+++ b/Json-Rpc/JsonResponse.cs
@@ -1,46 +1,135 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Newtonsoft.Json;
+
+using System;
+using System.Text.Json;
+using System.Text.Json.Serialization;
namespace AustinHarris.JsonRpc
{
///
/// Represents a Json Rpc Response
///
- [JsonObject(MemberSerialization.OptIn)]
+
+ [JsonConverter(typeof(JsonResponseConverter))]
public class JsonResponse
{
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "jsonrpc")]
- public string JsonRpc { get; set; } = "2.0";
+ public string Jsonrpc { get; set; } = "2.0";
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "result")]
public object Result { get; set; }
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "error")]
public JsonRpcException Error { get; set; }
- [JsonProperty(PropertyName = "id")]
- public object Id { get; set; }
+ public JsonElement Id { get; set; }
}
///
/// Represents a Json Rpc Response
///
- [JsonObject(MemberSerialization.OptIn)]
public class JsonResponse
{
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "jsonrpc")]
- public string JsonRpc { get; set; } = "2.0";
+ public string Jsonrpc { get; set; } = "2.0";
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "result")]
public T Result { get; set; }
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "error")]
public JsonRpcException Error { get; set; }
- [JsonProperty(PropertyName = "id")]
- public object Id { get; set; }
+ public JsonElement Id { get; set; }
+ }
+
+ public class JsonResponseConverter : JsonConverter
+ {
+ public override JsonResponse Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ var jres = new JsonResponse();
+ while (reader.Read())
+ {
+ if (reader.TokenType == JsonTokenType.EndObject)
+ {
+ break;
+ }
+ if (reader.TokenType == JsonTokenType.PropertyName)
+ {
+ var propname = reader.GetString();
+ if (propname == "jsonrpc")
+ {
+ reader.Read();
+ jres.Jsonrpc = reader.GetString();
+ }
+
+ if (propname == "result")
+ {
+ reader.Read();
+ jres.Result = JsonDocument.ParseValue(ref reader);
+ }
+
+ if (propname == "id")
+ {
+ reader.Read();
+ jres.Id = JsonDocument.ParseValue(ref reader).RootElement.Clone();
+ }
+
+ if (propname == "error")
+ {
+ reader.Read();
+ if (reader.TokenType == JsonTokenType.Null || reader.TokenType == JsonTokenType.None)
+ {
+
+ }
+ else
+ {
+ JsonRpcExceptionConverter exc = new JsonRpcExceptionConverter();
+ jres.Error = exc.Read(ref reader, typeof(JsonRpcException), options);
+ }
+ }
+ }
+
+ }
+
+ return jres;
+ }
+
+ public override void Write(Utf8JsonWriter writer, JsonResponse value, JsonSerializerOptions options)
+ {
+ writer.WriteStartObject();
+ writer.WriteString("jsonrpc", "2.0");
+ if (value.Error != null)
+ {
+ writer.WritePropertyName("error");
+ var spError =JsonSerializer.SerializeToUtf8Bytes(value.Error, options);
+ using (JsonDocument document = JsonDocument.Parse(spError))
+ {
+ document.RootElement.WriteTo(writer);
+ }
+ }
+ else
+ {
+
+ var spResult =JsonSerializer.SerializeToUtf8Bytes(value.Result, options);
+ using (JsonDocument document = JsonDocument.Parse(spResult))
+ {
+ if (document.RootElement.ValueKind == JsonValueKind.Object
+ || document.RootElement.ValueKind == JsonValueKind.Array)
+ {
+ writer.WritePropertyName("result");
+ document.RootElement.WriteTo(writer);
+ }else if (document.RootElement.ValueKind == JsonValueKind.Null)
+ {
+ writer.WriteNull("result");
+ }
+ else
+ {
+ writer.WritePropertyName("result");
+ document.RootElement.Clone().WriteTo(writer);
+ }
+ }
+ }
+ if (value.Id.ValueKind != JsonValueKind.Null && value.Id.ValueKind != JsonValueKind.Undefined)
+ {
+ writer.WritePropertyName("id");
+ value.Id.Clone().WriteTo(writer);
+ }
+ writer.WriteEndObject();
+
+ writer.Flush();
+ }
}
}
diff --git a/Json-Rpc/JsonResponseErrorObject.cs b/Json-Rpc/JsonResponseErrorObject.cs
index c23a241..eb9467a 100644
--- a/Json-Rpc/JsonResponseErrorObject.cs
+++ b/Json-Rpc/JsonResponseErrorObject.cs
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
-using Newtonsoft.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
namespace AustinHarris.JsonRpc
{
@@ -29,16 +32,14 @@ namespace AustinHarris.JsonRpc
/// The remainder of the space is available for application defined errors.
///
[Serializable]
- [JsonObject(MemberSerialization.OptIn)]
+ [JsonConverter(typeof(JsonRpcExceptionConverter))]
public class JsonRpcException : System.ApplicationException
{
- [JsonProperty]
+
public int code { get; set; }
- [JsonProperty]
public string message { get; set; }
- [JsonProperty]
public object data { get; set; }
public JsonRpcException(int code, string message, object data)
@@ -47,5 +48,94 @@ public JsonRpcException(int code, string message, object data)
this.message = message;
this.data = data;
}
+
+ public static readonly JsonRpcException Ex_32700 = new JsonRpcException(-32700, "Parse error",null);
+ public static readonly JsonRpcException Ex_3200 = new JsonRpcException(3200, "Invalid Request", "Batch of calls was empty.");
+
+ public static readonly JsonRpcException Ex_32602 = new JsonRpcException(-32602,
+ "Invalid params",
+ null
+ );
+ public static readonly JsonRpcException Ex_32601 = new JsonRpcException(-32601, "Method not found",
+ "The method does not exist / is not available.");
+
+ public static readonly JsonRpcException Ex_32600 =
+ new JsonRpcException(-32600, "Invalid Request", "Missing property 'method'");
+ public static JsonRpcException WithData(JsonRpcException rpcEx, object data)
+ {
+ rpcEx.data = data;
+ return rpcEx;
+ }
+
+
+ }
+
+ public class JsonRpcExceptionConverter : JsonConverter
+ {
+ public override JsonRpcException Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ if (reader.TokenType != JsonTokenType.StartObject)
+ {
+ throw new JsonException();
+ }
+ var res = new JsonRpcException(0, "", null);
+ while (reader.Read())
+ {
+ if (reader.TokenType == JsonTokenType.EndObject)
+ {
+ break;
+ }
+ if (reader.TokenType != JsonTokenType.PropertyName)
+ {
+ throw new JsonException();
+ }
+
+ string propertyName = reader.GetString();
+ if (propertyName == "code")
+ {
+ reader.Read();
+ var code = reader.GetInt32();
+ res.code = code;
+ }
+
+ if (propertyName == "message")
+ {
+ reader.Read();
+ var message = reader.GetString();
+ res.message = message;
+ }
+
+ if (propertyName == "data")
+ {
+ reader.Read();
+ var data = reader.GetString();
+ res.data = data;
+ }
+ }
+ return res;
+ }
+
+ public override void Write(Utf8JsonWriter writer, JsonRpcException value, JsonSerializerOptions options)
+ {
+ writer.WriteStartObject();
+ writer.WriteNumber("code", value.code);
+ writer.WriteString("message", value.message);
+ if (value.data != null)
+ {
+ writer.WritePropertyName("data");
+ var spError = value.data switch
+ {
+ JsonException je => JsonSerializer.SerializeToUtf8Bytes(je.Message, options),
+ { } o => JsonSerializer.SerializeToUtf8Bytes(o, options)
+ };
+ using (JsonDocument document = JsonDocument.Parse(spError))
+ {
+ document.RootElement.WriteTo(writer);
+ }
+ }
+ writer.WriteEndObject();
+
+ writer.Flush();
+ }
}
}
diff --git a/Json-Rpc/JsonRpcProcessor.cs b/Json-Rpc/JsonRpcProcessor.cs
index 1d7e1a7..00eb0b9 100644
--- a/Json-Rpc/JsonRpcProcessor.cs
+++ b/Json-Rpc/JsonRpcProcessor.cs
@@ -1,18 +1,26 @@
using System;
-using System.Globalization;
-using System.Threading;
using System.Threading.Tasks;
-using System.Reflection;
-using System.IO;
-using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using Newtonsoft.Json;
+using System.Text.Json;
+using System.Text.Json.Serialization;
namespace AustinHarris.JsonRpc
{
public static class JsonRpcProcessor
{
+
+ private static readonly JsonSerializerOptions DefaultOptions = new JsonSerializerOptions
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ IgnoreNullValues = true,
+ Converters =
+ {
+ new JsonRpcExceptionConverter(),
+ new JsonResponseConverter(),
+ new JsonStringEnumConverter()
+ }
+ };
+
public static void Process(JsonRpcStateAsync async, object context = null)
{
Process(Handler.DefaultSessionId(), async, context);
@@ -27,20 +35,21 @@ public static void Process(string sessionId, JsonRpcStateAsync async, object con
async.SetCompleted();
});
}
- public static Task Process(string jsonRpc, object context = null)
+ public static Task Process(string jsonRpc, object context = null, JsonSerializerOptions serializerOptions = null )
{
- return Process(Handler.DefaultSessionId(), jsonRpc, context);
+ return Process(Handler.DefaultSessionId(), jsonRpc, context, serializerOptions);
}
- public static Task Process(string sessionId, string jsonRpc, object context = null)
+ public static Task Process(string sessionId, string jsonRpc, object context = null, JsonSerializerOptions serializerOptions = null)
{
return Task.Factory.StartNew((_) =>
{
var tuple = (Tuple)_;
- return ProcessInternal(tuple.Item1, tuple.Item2, tuple.Item3);
+ return ProcessInternal(tuple.Item1, tuple.Item2, tuple.Item3, serializerOptions ?? DefaultOptions);
}, new Tuple(sessionId, jsonRpc, context));
}
- private static string ProcessInternal(string sessionId, string jsonRpc, object jsonRpcContext)
+ // todo: Work with and return utf8 at this level. We can deal with converting to and from utf8 in the 'Process' overloads
+ private static string ProcessInternal(string sessionId, string jsonRpc, object jsonRpcContext, JsonSerializerOptions serializerOptions)
{
var handler = Handler.GetSessionHandler(sessionId);
@@ -50,29 +59,28 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
{
if (isSingleRpc(jsonRpc))
{
- var foo = JsonConvert.DeserializeObject(jsonRpc);
+ var foo = JsonSerializer.Deserialize(jsonRpc, serializerOptions);
batch = new[] { foo };
}
else
{
- batch = JsonConvert.DeserializeObject(jsonRpc);
+ batch = JsonSerializer.Deserialize(jsonRpc, serializerOptions);
}
}
catch (Exception ex)
{
- return Newtonsoft.Json.JsonConvert.SerializeObject(new JsonResponse
+ return JsonSerializer.Serialize(new JsonResponse
{
- Error = handler.ProcessParseException(jsonRpc, new JsonRpcException(-32700, "Parse error", ex))
- });
+ Error = handler.ProcessParseException(jsonRpc, JsonRpcException.WithData( JsonRpcException.Ex_32700,ex))
+ }, serializerOptions);
}
if (batch.Length == 0)
{
- return Newtonsoft.Json.JsonConvert.SerializeObject(new JsonResponse
+ return JsonSerializer.Serialize(new JsonResponse
{
- Error = handler.ProcessParseException(jsonRpc,
- new JsonRpcException(3200, "Invalid Request", "Batch of calls was empty."))
- });
+ Error = handler.ProcessParseException(jsonRpc, JsonRpcException.Ex_3200)
+ }, serializerOptions);
}
var singleBatch = batch.Length == 1;
@@ -85,18 +93,18 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
if (jsonRequest == null)
{
jsonResponse.Error = handler.ProcessParseException(jsonRpc,
- new JsonRpcException(-32700, "Parse error",
+ JsonRpcException.WithData(JsonRpcException.Ex_32700,
"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."));
}
else if (jsonRequest.Method == null)
{
jsonResponse.Error = handler.ProcessParseException(jsonRpc,
- new JsonRpcException(-32600, "Invalid Request", "Missing property 'method'"));
+ JsonRpcException.WithData(JsonRpcException.Ex_32600, "Missing property 'method'"));
}
else if (!isSimpleValueType(jsonRequest.Id))
{
jsonResponse.Error = handler.ProcessParseException(jsonRpc,
- new JsonRpcException(-32600, "Invalid Request", "Id property must be either null or string or integer."));
+ JsonRpcException.WithData(JsonRpcException.Ex_32600,"Id property must be either null or string or integer."));
}
else
{
@@ -106,7 +114,7 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
if (data == null) continue;
- jsonResponse.JsonRpc = data.JsonRpc;
+ jsonResponse.Jsonrpc = data.Jsonrpc;
jsonResponse.Error = data.Error;
jsonResponse.Result = data.Result;
@@ -117,33 +125,14 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
// result : This member is REQUIRED on success.
// This member MUST NOT exist if there was an error invoking the method.
// Either the result member or error member MUST be included, but both members MUST NOT be included.
- jsonResponse.Result = new Newtonsoft.Json.Linq.JValue((Object)null);
+ jsonResponse.Result = null;
}
// special case optimization for single Item batch
- if (singleBatch && (jsonResponse.Id != null || jsonResponse.Error != null))
+ if (singleBatch && (jsonResponse.Id.ValueKind != JsonValueKind.Null || jsonResponse.Error != null))
{
- StringWriter sw = new StringWriter();
- JsonTextWriter writer = new JsonTextWriter(sw);
- writer.WriteStartObject();
- if (!string.IsNullOrEmpty(jsonResponse.JsonRpc))
- {
- writer.WritePropertyName("jsonrpc"); writer.WriteValue(jsonResponse.JsonRpc);
- }
- if (jsonResponse.Error != null)
- {
- writer.WritePropertyName("error"); writer.WriteRawValue(JsonConvert.SerializeObject(jsonResponse.Error));
- }
- else
- {
- writer.WritePropertyName("result"); writer.WriteRawValue(JsonConvert.SerializeObject(jsonResponse.Result));
- }
- writer.WritePropertyName("id"); writer.WriteValue(jsonResponse.Id);
- writer.WriteEndObject();
- return sw.ToString();
-
- //return JsonConvert.SerializeObject(jsonResponse);
+ return JsonSerializer.Serialize(jsonResponse, serializerOptions);
}
- else if (jsonResponse.Id == null && jsonResponse.Error == null)
+ else if (jsonResponse.Id.ValueKind == JsonValueKind.Null && jsonResponse.Error == null)
{
// do nothing
sbResult = new StringBuilder(0);
@@ -156,7 +145,7 @@ private static string ProcessInternal(string sessionId, string jsonRpc, object j
sbResult = new StringBuilder("[");
}
- sbResult.Append(JsonConvert.SerializeObject(jsonResponse));
+ sbResult.Append(JsonSerializer.Serialize(jsonResponse, serializerOptions));
if (i < batch.Length - 1)
{
sbResult.Append(',');
@@ -180,14 +169,16 @@ private static bool isSingleRpc(string json)
return true;
}
- private static bool isSimpleValueType(object property)
+ private static bool isSimpleValueType(JsonElement property)
{
- if (property == null)
- return true;
- return property.GetType() == typeof(System.String) ||
- property.GetType() == typeof(System.Int64) ||
- property.GetType() == typeof(System.Int32) ||
- property.GetType() == typeof(System.Int16);
+ JsonElement p = (JsonElement)property;
+ return p.ValueKind == JsonValueKind.Number
+ || p.ValueKind == JsonValueKind.String
+ || p.ValueKind == JsonValueKind.True
+ || p.ValueKind == JsonValueKind.False
+ || p.ValueKind == JsonValueKind.Null;
+
+ return false;
}
}
}
diff --git a/Json-Rpc/SMDService.cs b/Json-Rpc/SMDService.cs
index fe84bb5..8b80351 100644
--- a/Json-Rpc/SMDService.cs
+++ b/Json-Rpc/SMDService.cs
@@ -2,64 +2,26 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using Newtonsoft.Json;
using System.Reflection;
-using Newtonsoft.Json.Linq;
+using System.Text.Json;
+
namespace AustinHarris.JsonRpc
{
public class SMD
{
- public string transport { get; set; }
- public string envelope { get; set; }
- public string target { get; set; }
- public bool additonalParameters { get; set; }
- public SMDAdditionalParameters[] parameters { get; set; }
- [JsonIgnore]
- public static List TypeHashes { get; set; }
- [JsonProperty("types")]
- public static Dictionary Types { get; set; }
- [JsonProperty("services")]
public Dictionary Services { get; set; }
public SMD ()
{
- transport = "POST";
- envelope = "URL";
- target = "/json.rpc";
- additonalParameters = false;
- parameters = new SMDAdditionalParameters[0];
Services = new Dictionary();
- Types = new Dictionary();
- TypeHashes = new List();
}
internal void AddService(string method, Dictionary parameters, Dictionary defaultValues, Delegate dele)
{
- var newService = new SMDService(transport,"JSON-RPC-2.0",parameters, defaultValues, dele);
+ var newService = new SMDService(parameters, defaultValues, dele);
Services.Add(method,newService);
}
-
- public static int AddType(JObject jo)
- {
- var hash = string.Format("t_{0}", jo.ToString().GetHashCode());
-
- lock (TypeHashes)
- {
- if (TypeHashes.Contains(hash)) return TypeHashes.IndexOf(hash);
-
- TypeHashes.Add(hash);
- var idx = TypeHashes.IndexOf(hash);
- Types.Add(idx, jo);
- }
-
- return TypeHashes.IndexOf(hash);
- }
-
- public static bool ContainsType(JObject jo)
- {
- return TypeHashes.Contains(string.Format("t_{0}", jo.ToString().GetHashCode()));
- }
}
public class SMDService
@@ -72,12 +34,10 @@ public class SMDService
/// URL, PATH, JSON, JSON-RPC-1.0, JSON-RPC-1.1, JSON-RPC-2.0
///
///
- public SMDService(string transport, string envelope, Dictionary parameters, Dictionary defaultValues, Delegate dele)
+ public SMDService(Dictionary parameters, Dictionary defaultValues, Delegate dele)
{
// TODO: Complete member initialization
this.dele = dele;
- this.transport = transport;
- this.envelope = envelope;
this.parameters = new SMDAdditionalParameters[parameters.Count-1]; // last param is return type similar to Func<,>
int ctr=0;
foreach (var item in parameters)
@@ -97,11 +57,9 @@ public SMDService(string transport, string envelope, Dictionary pa
}
// this is getting the return type from the end of the param list
- this.returns = new SMDResult(parameters.Values.LastOrDefault());
+ this.returns = parameters.Values.LastOrDefault();
}
- public string transport { get; private set; }
- public string envelope { get; private set; }
- public SMDResult returns { get; private set; }
+ public Type returns { get; private set; }
///
/// This indicates what parameters may be supplied for the service calls.
@@ -118,17 +76,6 @@ public SMDService(string transport, string envelope, Dictionary pa
public ParameterDefaultValue[] defaultValues { get; private set; }
}
- public class SMDResult
- {
- [JsonProperty("__type")]
- public int Type { get; private set; }
-
- public SMDResult(System.Type type)
- {
- Type = SMDAdditionalParameters.GetTypeRecursive(type);
- }
- }
-
///
/// Holds default value for parameters.
///
@@ -152,92 +99,40 @@ public ParameterDefaultValue(string name, object value)
public class SMDAdditionalParameters
{
+ private Func __extractValue;
+
public SMDAdditionalParameters(string parametername, System.Type type)
{
Name = parametername;
- Type = GetTypeRecursive(ObjectType = type);
-
+ ObjectType = type;
+ // fallback... slow
+ __extractValue = (je) => je.ToObject(type);//throw new NotImplementedException($"Convert to type {type} not implemented");
+
+ if (type == typeof(string)) __extractValue = (je) => je.GetString();
+ if (type == typeof(short)) __extractValue = (je) => je.GetInt16();
+ if (type == typeof(int)) __extractValue = (je) => je.GetInt32();
+ if (type == typeof(Int64)) __extractValue = (je) => je.GetInt64();
+ if (type == typeof(float)) __extractValue = (je) => je.GetSingle();
+ if (type == typeof(double)) __extractValue = (je) => je.GetDouble();
+ if (type == typeof(decimal)) __extractValue = (je) => je.GetDecimal();
+ if (type == typeof(float?)) __extractValue = (je) => je.ValueKind == JsonValueKind.Null ? new float?() : je.GetSingle();
+ if (type == typeof(double?)) __extractValue = (je) => je.ValueKind == JsonValueKind.Null ? new double?() :je.GetDouble();
+ if (type == typeof(decimal?)) __extractValue = (je) => je.ValueKind == JsonValueKind.Null ? new decimal?() :je.GetDecimal();
+ if (type == typeof(Boolean)) __extractValue = (je) => je.GetBoolean();
+ if (type == typeof(DateTime)) __extractValue = (je) => je.GetDateTime();
+ if (type == typeof(DateTimeOffset)) __extractValue = (je) => je.GetDateTimeOffset();
+ if (type == typeof(char)) __extractValue = (je) => (char) je.GetInt32();
+
}
- [JsonIgnore()]
+
public Type ObjectType { get; set; }
- [JsonProperty("__name")]
public string Name { get; set; }
- [JsonProperty("__type")]
- public int Type { get; set; }
- internal static int GetTypeRecursive(Type t)
+ public object ExtractValue(JsonElement je)
{
- JObject jo = new JObject();
- jo.Add("__name", t.Name.ToLower());
-
- if (isSimpleType(t) || SMD.ContainsType(jo))
- {
- return SMD.AddType(jo);
- }
-
- var retVal = SMD.AddType(jo);
-
- var genArgs = t.GetGenericArguments();
- PropertyInfo[] properties = t.GetProperties();
- FieldInfo[] fields = t.GetFields();
-
- if (genArgs.Length > 0)
- {
- var ja = new JArray();
- foreach (var item in genArgs)
- {
- if (item != t)
- {
- var jt = GetTypeRecursive(item);
- ja.Add(jt);
- }
- else
- {
- // make a special case where -1 indicates this type
- ja.Add(-1);
- }
- }
- jo.Add("__genericArguments", ja);
- }
-
- foreach (var item in properties)
- {
- if (item.GetAccessors().Where(x => x.IsPublic).Count() > 0)
- {
- if (item.PropertyType != t)
- {
- var jt = GetTypeRecursive(item.PropertyType);
- jo.Add(item.Name, jt);
- }
- else
- {
- // make a special case where -1 indicates this type
- jo.Add(item.Name, -1);
- }
- }
- }
-
- foreach (var item in fields)
- {
- if (item.IsPublic)
- {
- if (item.FieldType != t)
- {
- var jt = GetTypeRecursive(item.FieldType);
- jo.Add(item.Name, jt);
- }
- else
- {
- // make a special case where -1 indicates this type
- jo.Add(item.Name, -1);
- }
- }
- }
-
- return retVal;
+ return this.__extractValue(je);
}
-
internal static bool isSimpleType(Type t)
{
var name = t.FullName.ToLower();
diff --git a/TestServer_Console/Program.cs b/TestServer_Console/Program.cs
index df3152f..1934d14 100644
--- a/TestServer_Console/Program.cs
+++ b/TestServer_Console/Program.cs
@@ -60,11 +60,11 @@ private static void Benchmark()
var sessionid = Handler.DefaultSessionId();
for (int i = 0; i < cnt; i+=5)
{
- tasks[i] = JsonRpcProcessor.Process(sessionid, "{'method':'add','params':[1,2],'id':1}");
- tasks[i+1] = JsonRpcProcessor.Process(sessionid, "{'method':'addInt','params':[1,7],'id':2}");
- tasks[i+2] = JsonRpcProcessor.Process(sessionid, "{'method':'NullableFloatToNullableFloat','params':[1.23],'id':3}");
- tasks[i+3] = JsonRpcProcessor.Process(sessionid, "{'method':'Test2','params':[3.456],'id':4}");
- tasks[i+4] = JsonRpcProcessor.Process(sessionid, "{'method':'StringMe','params':['Foo'],'id':5}");
+ tasks[i] = JsonRpcProcessor.Process(sessionid, "{\"method\":\"add\",\"params\":[1,2],\"id\":1}");
+ tasks[i+1] = JsonRpcProcessor.Process(sessionid, "{\"method\":\"addInt\",\"params\":[1,7],\"id\":2}");
+ tasks[i+2] = JsonRpcProcessor.Process(sessionid, "{\"method\":\"NullableFloatToNullableFloat\",\"params\":[1.23],\"id\":3}");
+ tasks[i+3] = JsonRpcProcessor.Process(sessionid, "{\"method\":\"Test2\",\"params\":[3.456],\"id\":4}");
+ tasks[i+4] = JsonRpcProcessor.Process(sessionid, "{\"method\":\"StringMe\",\"params\":[\"Foo\"],\"id\":5}");
}
Task.WaitAll(tasks);
sw.Stop();
diff --git a/TestServer_Console/TestServer_Console.csproj b/TestServer_Console/TestServer_Console.csproj
index ba5f427..ede8dff 100644
--- a/TestServer_Console/TestServer_Console.csproj
+++ b/TestServer_Console/TestServer_Console.csproj
@@ -3,7 +3,7 @@
Austin Harris
Exe
- netcoreapp3.1
+ net5.0;netcoreapp3.1