Remove params from message ctors (#1931)
This commit is contained in:
parent
13f7981010
commit
c83baf2b76
|
|
@ -166,67 +166,67 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
[Benchmark]
|
||||
public Task Invocation()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "Invocation", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "Invocation", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task InvocationAsync()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationAsync", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationAsync", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task InvocationReturnValue()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationReturnValue", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationReturnValue", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task InvocationReturnAsync()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationReturnAsync", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationReturnAsync", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task InvocationValueTaskAsync()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationValueTaskAsync", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new InvocationMessage("123", "InvocationValueTaskAsync", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReader()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReader", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReader", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReaderAsync()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderAsync", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderAsync", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReaderValueTaskAsync()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderValueTaskAsync", null));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderValueTaskAsync", null, Array.Empty<object>()));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReaderCount_Zero()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", argumentBindingException: null, new object[] { 0 }));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", null, new object[] { 0 }));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReaderCount_One()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", argumentBindingException: null, new object[] { 1 }));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", null, new object[] { 1 }));
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public Task StreamChannelReaderCount_Thousand()
|
||||
{
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", argumentBindingException: null, new object[] { 1000 }));
|
||||
return _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", null, new object[] { 1000 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
switch (Input)
|
||||
{
|
||||
case Message.NoArguments:
|
||||
_hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null);
|
||||
_hubMessage = new InvocationMessage("Target", null, Array.Empty<object>());
|
||||
break;
|
||||
case Message.FewArguments:
|
||||
_hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "Foo", 2.0f);
|
||||
_hubMessage = new InvocationMessage("Target", null, new object[] { 1, "Foo", 2.0f });
|
||||
break;
|
||||
case Message.ManyArguments:
|
||||
_hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "string", 2.0f, true, (byte)9, new byte[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L);
|
||||
_hubMessage = new InvocationMessage("Target", null, new object[] { 1, "string", 2.0f, true, (byte)9, new byte[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L });
|
||||
break;
|
||||
case Message.LargeArguments:
|
||||
_hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, new string('F', 10240), new byte[10240]);
|
||||
_hubMessage = new InvocationMessage("Target", null, new object[] { new string('F', 10240), new byte[10240] });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
switch (Input)
|
||||
{
|
||||
case Message.NoArguments:
|
||||
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null);
|
||||
hubMessage = new InvocationMessage("Target", null, Array.Empty<object>());
|
||||
break;
|
||||
case Message.FewArguments:
|
||||
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "Foo", 2.0f);
|
||||
hubMessage = new InvocationMessage("Target", null, new object[] { 1, "Foo", 2.0f });
|
||||
break;
|
||||
case Message.ManyArguments:
|
||||
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "string", 2.0f, true, (byte)9, new[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L);
|
||||
hubMessage = new InvocationMessage("Target", null, new object[] { 1, "string", 2.0f, true, (byte)9, new[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L });
|
||||
break;
|
||||
case Message.LargeArguments:
|
||||
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, new string('F', 10240), new string('B', 10240));
|
||||
hubMessage = new InvocationMessage("Target", null, new object[] { new string('F', 10240), new string('B', 10240) });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -294,8 +294,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
|||
Log.PreparingBlockingInvocation(_logger, irq.InvocationId, methodName, irq.ResultType.FullName, args.Length);
|
||||
|
||||
// Client invocations are always blocking
|
||||
var invocationMessage = new InvocationMessage(irq.InvocationId, target: methodName,
|
||||
argumentBindingException: null, arguments: args);
|
||||
var invocationMessage = new InvocationMessage(irq.InvocationId, methodName, null, args);
|
||||
|
||||
Log.RegisteringInvocation(_logger, invocationMessage.InvocationId);
|
||||
|
||||
|
|
@ -322,8 +321,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
|||
|
||||
Log.PreparingStreamingInvocation(_logger, irq.InvocationId, methodName, irq.ResultType.FullName, args.Length);
|
||||
|
||||
var invocationMessage = new StreamInvocationMessage(irq.InvocationId, methodName,
|
||||
argumentBindingException: null, arguments: args);
|
||||
var invocationMessage = new StreamInvocationMessage(irq.InvocationId, methodName, null, args);
|
||||
|
||||
// I just want an excuse to use 'irq' as a variable name...
|
||||
Log.RegisteringInvocation(_logger, invocationMessage.InvocationId);
|
||||
|
|
@ -371,8 +369,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
|
|||
|
||||
Log.PreparingNonBlockingInvocation(_logger, methodName, args.Length);
|
||||
|
||||
var invocationMessage = new InvocationMessage(null, target: methodName,
|
||||
argumentBindingException: null, arguments: args);
|
||||
var invocationMessage = new InvocationMessage(null, methodName, null, args);
|
||||
|
||||
await SendHubMessage(invocationMessage, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
|
||||
public class InvocationMessage : HubMethodInvocationMessage
|
||||
{
|
||||
public InvocationMessage(string target, ExceptionDispatchInfo argumentBindingException, params object[] arguments)
|
||||
: this(invocationId: null, target, argumentBindingException, arguments)
|
||||
public InvocationMessage(string target, ExceptionDispatchInfo argumentBindingException, object[] arguments)
|
||||
: this(null, target, argumentBindingException, arguments)
|
||||
{
|
||||
}
|
||||
|
||||
public InvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, params object[] arguments)
|
||||
public InvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, object[] arguments)
|
||||
: base(invocationId, target, argumentBindingException, arguments)
|
||||
{
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
|
||||
public class StreamInvocationMessage : HubMethodInvocationMessage
|
||||
{
|
||||
public StreamInvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, params object[] arguments)
|
||||
public StreamInvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, object[] arguments)
|
||||
: base(invocationId, target, argumentBindingException, arguments)
|
||||
{
|
||||
if (string.IsNullOrEmpty(invocationId))
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
|
||||
private HubMessage CreateInvocationMessage(string methodName, object[] args)
|
||||
{
|
||||
return new InvocationMessage(target: methodName, argumentBindingException: null, arguments: args);
|
||||
return new InvocationMessage(methodName, null, args);
|
||||
}
|
||||
|
||||
public override Task SendUserAsync(string userId, string methodName, object[] args)
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
throw new InvalidDataException($"Missing required property '{TargetPropertyName}'.");
|
||||
}
|
||||
|
||||
return new StreamInvocationMessage(invocationId, target, argumentBindingException: argumentBindingException, arguments: arguments);
|
||||
return new StreamInvocationMessage(invocationId, target, argumentBindingException, arguments);
|
||||
}
|
||||
|
||||
private HubMessage BindInvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, object[] arguments, bool hasArguments, IInvocationBinder binder)
|
||||
|
|
@ -572,7 +572,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
throw new InvalidDataException($"Missing required property '{ArgumentsPropertyName}'.");
|
||||
}
|
||||
|
||||
return new InvocationMessage(invocationId, target, argumentBindingException: argumentBindingException, arguments: arguments);
|
||||
return new InvocationMessage(invocationId, target, argumentBindingException, arguments);
|
||||
}
|
||||
|
||||
private object[] BindArguments(JsonTextReader reader, IReadOnlyList<Type> paramTypes)
|
||||
|
|
|
|||
|
|
@ -148,11 +148,11 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
try
|
||||
{
|
||||
var arguments = BindArguments(input, ref offset, parameterTypes, resolver);
|
||||
return ApplyHeaders(headers, new InvocationMessage(invocationId, target, argumentBindingException: null, arguments: arguments));
|
||||
return ApplyHeaders(headers, new InvocationMessage(invocationId, target, null, arguments));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApplyHeaders(headers, new InvocationMessage(invocationId, target, ExceptionDispatchInfo.Capture(ex)));
|
||||
return ApplyHeaders(headers, new InvocationMessage(invocationId, target, ExceptionDispatchInfo.Capture(ex), null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,11 +166,11 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
|
|||
try
|
||||
{
|
||||
var arguments = BindArguments(input, ref offset, parameterTypes, resolver);
|
||||
return ApplyHeaders(headers, new StreamInvocationMessage(invocationId, target, argumentBindingException: null, arguments: arguments));
|
||||
return ApplyHeaders(headers, new StreamInvocationMessage(invocationId, target, null, arguments));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApplyHeaders(headers, new StreamInvocationMessage(invocationId, target, ExceptionDispatchInfo.Capture(ex)));
|
||||
return ApplyHeaders(headers, new StreamInvocationMessage(invocationId, target, ExceptionDispatchInfo.Capture(ex), null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
|
|||
public static RedisInvocation Create(string target, object[] arguments, IReadOnlyList<string> excludedIds = null)
|
||||
{
|
||||
return new RedisInvocation(
|
||||
new SerializedHubMessage(new InvocationMessage(target, argumentBindingException: null, arguments)),
|
||||
new SerializedHubMessage(new InvocationMessage(target, null, arguments)),
|
||||
excludedIds);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Internal
|
|||
writer.WriteVarInt(0);
|
||||
}
|
||||
|
||||
SerializedHubMessage.WriteAllSerializedVersions(writer, new InvocationMessage(methodName, argumentBindingException: null, args), _protocols);
|
||||
SerializedHubMessage.WriteAllSerializedVersions(writer, new InvocationMessage(methodName, null, args), _protocols);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis
|
|||
var connection = _connections[connectionId];
|
||||
if (connection != null)
|
||||
{
|
||||
return connection.WriteAsync(new InvocationMessage(methodName, argumentBindingException: null, args)).AsTask();
|
||||
return connection.WriteAsync(new InvocationMessage(methodName, null, args)).AsTask();
|
||||
}
|
||||
|
||||
var message = _protocol.WriteInvocation(methodName, args);
|
||||
|
|
|
|||
|
|
@ -33,17 +33,17 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
|
||||
public static IDictionary<string, JsonProtocolTestData> ProtocolTestData => new[]
|
||||
{
|
||||
new JsonProtocolTestData("InvocationMessage_HasInvocationId", new InvocationMessage("123", "Target", null, 1, "Foo", 2.0f), true, NullValueHandling.Ignore, "{\"type\":1,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasFloatArgument", new InvocationMessage(null, "Target", null, 1, "Foo", 2.0f), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasBoolArgument", new InvocationMessage(null, "Target", null, true), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[true]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasInvocationId", new InvocationMessage("123", "Target", null, new object[] { 1, "Foo", 2.0f }), true, NullValueHandling.Ignore, "{\"type\":1,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasFloatArgument", new InvocationMessage(null, "Target", null, new object[] { 1, "Foo", 2.0f }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasBoolArgument", new InvocationMessage(null, "Target", null, new object[] { true }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[true]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasNullArgument", new InvocationMessage(null, "Target", null, new object[] { null }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[null]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNoCamelCase", new InvocationMessage(null, "Target", null, new CustomObject()), false, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueIgnore", new InvocationMessage(null, "Target", null, new CustomObject()), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueIgnoreAndNoCamelCase", new InvocationMessage(null, "Target", null, new CustomObject()), false, NullValueHandling.Include, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"NullProp\":null,\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueInclude", new InvocationMessage(null, "Target", null, new CustomObject()), true, NullValueHandling.Include, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasHeaders", AddHeaders(TestHeaders, new InvocationMessage("123", "Target", null, 1, "Foo", 2.0f)), true, NullValueHandling.Ignore, "{\"type\":1," + SerializedHeaders + ",\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_StringIsoDateArgument", new InvocationMessage("Method", null, "2016-05-10T13:51:20+12:34"), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Method\",\"arguments\":[\"2016-05-10T13:51:20+12:34\"]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgument", new InvocationMessage("Method", null, DateTimeOffset.Parse("2016-05-10T13:51:20+12:34")), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Method\",\"arguments\":[\"2016-05-10T13:51:20+12:34\"]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNoCamelCase", new InvocationMessage(null, "Target", null, new object[] { new CustomObject() }), false, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueIgnore", new InvocationMessage(null, "Target", null, new object[] { new CustomObject() }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueIgnoreAndNoCamelCase", new InvocationMessage(null, "Target", null, new object[] { new CustomObject() }), false, NullValueHandling.Include, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"NullProp\":null,\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasCustomArgumentWithNullValueInclude", new InvocationMessage(null, "Target", null, new object[] { new CustomObject() }), true, NullValueHandling.Include, "{\"type\":1,\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_HasHeaders", AddHeaders(TestHeaders, new InvocationMessage("123", "Target", null, new object[] { 1, "Foo", 2.0f })), true, NullValueHandling.Ignore, "{\"type\":1," + SerializedHeaders + ",\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_StringIsoDateArgument", new InvocationMessage("Method", null, new object[] { "2016-05-10T13:51:20+12:34" }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Method\",\"arguments\":[\"2016-05-10T13:51:20+12:34\"]}"),
|
||||
new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgument", new InvocationMessage("Method", null, new object[] { DateTimeOffset.Parse("2016-05-10T13:51:20+12:34") }), true, NullValueHandling.Ignore, "{\"type\":1,\"target\":\"Method\",\"arguments\":[\"2016-05-10T13:51:20+12:34\"]}"),
|
||||
|
||||
new JsonProtocolTestData("StreamItemMessage_HasIntegerItem", new StreamItemMessage("123", 1), true, NullValueHandling.Ignore, "{\"type\":2,\"invocationId\":\"123\",\"item\":1}"),
|
||||
new JsonProtocolTestData("StreamItemMessage_HasStringItem", new StreamItemMessage("123", "Foo"), true, NullValueHandling.Ignore, "{\"type\":2,\"invocationId\":\"123\",\"item\":\"Foo\"}"),
|
||||
|
|
@ -71,15 +71,15 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
new JsonProtocolTestData("CompletionMessage_HasErrorAndCamelCase", CompletionMessage.Empty("123"), true, NullValueHandling.Ignore, "{\"type\":3,\"invocationId\":\"123\"}"),
|
||||
new JsonProtocolTestData("CompletionMessage_HasErrorAndHeadersAndCamelCase", AddHeaders(TestHeaders, CompletionMessage.Empty("123")), true, NullValueHandling.Ignore, "{\"type\":3," + SerializedHeaders + ",\"invocationId\":\"123\"}"),
|
||||
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasInvocationId", new StreamInvocationMessage("123", "Target", null, 1, "Foo", 2.0f), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasFloatArgument", new StreamInvocationMessage("123", "Target", null, 1, "Foo", 2.0f), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasBoolArgument", new StreamInvocationMessage("123", "Target", null, true), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[true]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasInvocationId", new StreamInvocationMessage("123", "Target", null, new object[] { 1, "Foo", 2.0f }), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasFloatArgument", new StreamInvocationMessage("123", "Target", null, new object[] { 1, "Foo", 2.0f }), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[1,\"Foo\",2.0]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasBoolArgument", new StreamInvocationMessage("123", "Target", null, new object[] { true }), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[true]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasNullArgument", new StreamInvocationMessage("123", "Target", null, new object[] { null }), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[null]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNoCamelCase", new StreamInvocationMessage("123", "Target", null, new CustomObject()), false, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueIgnore", new StreamInvocationMessage("123", "Target", null, new CustomObject()), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueIgnoreAndNoCamelCase", new StreamInvocationMessage("123", "Target", null, new CustomObject()), false, NullValueHandling.Include, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"NullProp\":null,\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueInclude", new StreamInvocationMessage("123", "Target", null, new CustomObject()), true, NullValueHandling.Include, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasHeaders", AddHeaders(TestHeaders, new StreamInvocationMessage("123", "Target", null, new CustomObject())), true, NullValueHandling.Include, "{\"type\":4," + SerializedHeaders + ",\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNoCamelCase", new StreamInvocationMessage("123", "Target", null, new object[] { new CustomObject() }), false, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueIgnore", new StreamInvocationMessage("123", "Target", null, new object[] { new CustomObject() }), true, NullValueHandling.Ignore, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueIgnoreAndNoCamelCase", new StreamInvocationMessage("123", "Target", null, new object[] { new CustomObject() }), false, NullValueHandling.Include, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"StringProp\":\"SignalR!\",\"DoubleProp\":6.2831853071,\"IntProp\":42,\"DateTimeProp\":\"2017-04-11T00:00:00Z\",\"NullProp\":null,\"ByteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasCustomArgumentWithNullValueInclude", new StreamInvocationMessage("123", "Target", null, new object[] { new CustomObject() }), true, NullValueHandling.Include, "{\"type\":4,\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_HasHeaders", AddHeaders(TestHeaders, new StreamInvocationMessage("123", "Target", null, new object[] { new CustomObject() })), true, NullValueHandling.Include, "{\"type\":4," + SerializedHeaders + ",\"invocationId\":\"123\",\"target\":\"Target\",\"arguments\":[{\"stringProp\":\"SignalR!\",\"doubleProp\":6.2831853071,\"intProp\":42,\"dateTimeProp\":\"2017-04-11T00:00:00Z\",\"nullProp\":null,\"byteArrProp\":\"AQID\"}]}"),
|
||||
|
||||
new JsonProtocolTestData("CancelInvocationMessage_HasInvocationId", new CancelInvocationMessage("123"), true, NullValueHandling.Ignore, "{\"type\":5,\"invocationId\":\"123\"}"),
|
||||
new JsonProtocolTestData("CancelInvocationMessage_HasHeaders", AddHeaders(TestHeaders, new CancelInvocationMessage("123")), true, NullValueHandling.Ignore, "{\"type\":5," + SerializedHeaders + ",\"invocationId\":\"123\"}"),
|
||||
|
|
@ -96,10 +96,10 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
|
||||
public static IDictionary<string, JsonProtocolTestData> OutOfOrderJsonTestData => new[]
|
||||
{
|
||||
new JsonProtocolTestData("InvocationMessage_StringIsoDateArgumentFirst", new InvocationMessage("Method", argumentBindingException: null, "2016-05-10T13:51:20+12:34"), false, NullValueHandling.Ignore, "{ \"arguments\": [\"2016-05-10T13:51:20+12:34\"], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgumentFirst", new InvocationMessage("Method", argumentBindingException: null, DateTimeOffset.Parse("2016-05-10T13:51:20+12:34")), false, NullValueHandling.Ignore, "{ \"arguments\": [\"2016-05-10T13:51:20+12:34\"], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("InvocationMessage_IntegerArrayArgumentFirst", new InvocationMessage("Method", argumentBindingException: null, 1, 2), false, NullValueHandling.Ignore, "{ \"arguments\": [1,2], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_IntegerArrayArgumentFirst", new StreamInvocationMessage("3", "Method", argumentBindingException: null, 1, 2), false, NullValueHandling.Ignore, "{ \"type\":4, \"arguments\": [1,2], \"target\": \"Method\", \"invocationId\": \"3\" }"),
|
||||
new JsonProtocolTestData("InvocationMessage_StringIsoDateArgumentFirst", new InvocationMessage("Method", null, new object[] { "2016-05-10T13:51:20+12:34" }), false, NullValueHandling.Ignore, "{ \"arguments\": [\"2016-05-10T13:51:20+12:34\"], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("InvocationMessage_DateTimeOffsetArgumentFirst", new InvocationMessage("Method", null, new object[] { DateTimeOffset.Parse("2016-05-10T13:51:20+12:34") }), false, NullValueHandling.Ignore, "{ \"arguments\": [\"2016-05-10T13:51:20+12:34\"], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("InvocationMessage_IntegerArrayArgumentFirst", new InvocationMessage("Method", null, new object[] { 1, 2 }), false, NullValueHandling.Ignore, "{ \"arguments\": [1,2], \"type\":1, \"target\": \"Method\" }"),
|
||||
new JsonProtocolTestData("StreamInvocationMessage_IntegerArrayArgumentFirst", new StreamInvocationMessage("3", "Method", null, new object[] { 1, 2 }), false, NullValueHandling.Ignore, "{ \"type\":4, \"arguments\": [1,2], \"target\": \"Method\", \"invocationId\": \"3\" }"),
|
||||
new JsonProtocolTestData("CompletionMessage_ResultFirst", new CompletionMessage("15", null, 10, hasResult: true), false, NullValueHandling.Ignore, "{ \"type\":3, \"result\": 10, \"invocationId\": \"15\" }"),
|
||||
new JsonProtocolTestData("StreamItemMessage_ItemFirst", new StreamItemMessage("1a", "foo"), false, NullValueHandling.Ignore, "{ \"item\": \"foo\", \"invocationId\": \"1a\", \"type\":2 }")
|
||||
}.ToDictionary(t => t.Name);
|
||||
|
|
|
|||
|
|
@ -58,175 +58,175 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
// Invocation messages
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersAndNoArgs",
|
||||
message: new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
message: new InvocationMessage("xyz", "method", null, Array.Empty<object>()),
|
||||
binary: "lQGAo3h5eqZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndNoArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null),
|
||||
message: new InvocationMessage("method", null, Array.Empty<object>()),
|
||||
binary: "lQGAwKZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleNullArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, new object[] { null }),
|
||||
message: new InvocationMessage("method", null, new object[] { null }),
|
||||
binary: "lQGAwKZtZXRob2SRwA=="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndSingleIntArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42),
|
||||
message: new InvocationMessage("method", null, new object[] { 42 }),
|
||||
binary: "lQGAwKZtZXRob2SRKg=="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdIntAndStringArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string"),
|
||||
message: new InvocationMessage("method", null, new object[] { 42, "string" }),
|
||||
binary: "lQGAwKZtZXRob2SSKqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdIntAndEnumArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, TestEnum.One),
|
||||
message: new InvocationMessage("method", null, new object[] { 42, TestEnum.One }),
|
||||
binary: "lQGAwKZtZXRob2SSKqNPbmU="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndCustomObjectArg",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
message: new InvocationMessage("method", null, new object[] { 42, "string", new CustomObject() }),
|
||||
binary: "lQGAwKZtZXRob2STKqZzdHJpbmeGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithNoHeadersNoIdAndArrayOfCustomObjectArgs",
|
||||
message: new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
|
||||
message: new InvocationMessage("method", null, new object[] { new CustomObject(), new CustomObject() }),
|
||||
binary: "lQGAwKZtZXRob2SShqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQIDhqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQID"),
|
||||
new ProtocolTestData(
|
||||
name: "InvocationWithHeadersNoIdAndArrayOfCustomObjectArgs",
|
||||
message: AddHeaders(TestHeaders, new InvocationMessage(target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
|
||||
message: AddHeaders(TestHeaders, new InvocationMessage("method", null, new object[] { new CustomObject(), new CustomObject() })),
|
||||
binary: "lQGDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmXApm1ldGhvZJKGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgOGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
|
||||
// StreamItem Messages
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndNullItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: null),
|
||||
message: new StreamItemMessage("xyz", item: null),
|
||||
binary: "lAKAo3h5esA="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndIntItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42),
|
||||
message: new StreamItemMessage("xyz", item: 42),
|
||||
binary: "lAKAo3h5eio="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndFloatItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: 42.0f),
|
||||
message: new StreamItemMessage("xyz", item: 42.0f),
|
||||
binary: "lAKAo3h5espCKAAA"),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndStringItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: "string"),
|
||||
message: new StreamItemMessage("xyz", item: "string"),
|
||||
binary: "lAKAo3h5eqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndBoolItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: true),
|
||||
message: new StreamItemMessage("xyz", item: true),
|
||||
binary: "lAKAo3h5esM="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndEnumItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: TestEnum.One),
|
||||
message: new StreamItemMessage("xyz", item: TestEnum.One),
|
||||
binary: "lAKAo3h5eqNPbmU="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndCustomObjectItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: new CustomObject()),
|
||||
message: new StreamItemMessage("xyz", item: new CustomObject()),
|
||||
binary: "lAKAo3h5eoaqU3RyaW5nUHJvcKhTaWduYWxSIapEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqrERhdGVUaW1lUHJvcNb/WOwcgKhOdWxsUHJvcMCrQnl0ZUFyclByb3DEAwECAw=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithNoHeadersAndCustomObjectArrayItem",
|
||||
message: new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() }),
|
||||
message: new StreamItemMessage("xyz", item: new[] { new CustomObject(), new CustomObject() }),
|
||||
binary: "lAKAo3h5epKGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgOGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamItemWithHeadersAndCustomObjectArrayItem",
|
||||
message: AddHeaders(TestHeaders, new StreamItemMessage(invocationId: "xyz", item: new[] { new CustomObject(), new CustomObject() })),
|
||||
message: AddHeaders(TestHeaders, new StreamItemMessage("xyz", item: new[] { new CustomObject(), new CustomObject() })),
|
||||
binary: "lAKDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6koaqU3RyaW5nUHJvcKhTaWduYWxSIapEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqrERhdGVUaW1lUHJvcNb/WOwcgKhOdWxsUHJvcMCrQnl0ZUFyclByb3DEAwECA4aqU3RyaW5nUHJvcKhTaWduYWxSIapEb3VibGVQcm9wy0AZIftUQs8Sp0ludFByb3AqrERhdGVUaW1lUHJvcNb/WOwcgKhOdWxsUHJvcMCrQnl0ZUFyclByb3DEAwECAw=="),
|
||||
|
||||
// Completion Messages
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndError",
|
||||
message: CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!"),
|
||||
message: CompletionMessage.WithError("xyz", error: "Error not found!"),
|
||||
binary: "lQOAo3h5egGwRXJyb3Igbm90IGZvdW5kIQ=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndError",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithError(invocationId: "xyz", error: "Error not found!")),
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithError("xyz", error: "Error not found!")),
|
||||
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6AbBFcnJvciBub3QgZm91bmQh"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNoResult",
|
||||
message: CompletionMessage.Empty(invocationId: "xyz"),
|
||||
message: CompletionMessage.Empty("xyz"),
|
||||
binary: "lAOAo3h5egI="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndNoResult",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.Empty(invocationId: "xyz")),
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.Empty("xyz")),
|
||||
binary: "lAODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6Ag=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndNullResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: null),
|
||||
message: CompletionMessage.WithResult("xyz", payload: null),
|
||||
binary: "lQOAo3h5egPA"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndIntResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42),
|
||||
message: CompletionMessage.WithResult("xyz", payload: 42),
|
||||
binary: "lQOAo3h5egMq"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndEnumResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: TestEnum.One),
|
||||
message: CompletionMessage.WithResult("xyz", payload: TestEnum.One),
|
||||
binary: "lQOAo3h5egOjT25l"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndFloatResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: 42.0f),
|
||||
message: CompletionMessage.WithResult("xyz", payload: 42.0f),
|
||||
binary: "lQOAo3h5egPKQigAAA=="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndStringResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: "string"),
|
||||
message: CompletionMessage.WithResult("xyz", payload: "string"),
|
||||
binary: "lQOAo3h5egOmc3RyaW5n"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndBooleanResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: true),
|
||||
message: CompletionMessage.WithResult("xyz", payload: true),
|
||||
binary: "lQOAo3h5egPD"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndCustomObjectResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: new CustomObject()),
|
||||
message: CompletionMessage.WithResult("xyz", payload: new CustomObject()),
|
||||
binary: "lQOAo3h5egOGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithNoHeadersAndCustomObjectArrayResult",
|
||||
message: CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() }),
|
||||
message: CompletionMessage.WithResult("xyz", payload: new[] { new CustomObject(), new CustomObject() }),
|
||||
binary: "lQOAo3h5egOShqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQIDhqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQID"),
|
||||
new ProtocolTestData(
|
||||
name: "CompletionWithHeadersAndCustomObjectArrayResult",
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithResult(invocationId: "xyz", payload: new[] { new CustomObject(), new CustomObject() })),
|
||||
message: AddHeaders(TestHeaders, CompletionMessage.WithResult("xyz", payload: new[] { new CustomObject(), new CustomObject() })),
|
||||
binary: "lQODo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6A5KGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgOGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
|
||||
// StreamInvocation Messages
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNoArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, Array.Empty<object>()),
|
||||
binary: "lQSAo3h5eqZtZXRob2SQ"),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndNullArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new object[] { null }),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { null }),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRwA=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { 42 }),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRKg=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndEnumArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, TestEnum.One),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { TestEnum.One }),
|
||||
binary: "lQSAo3h5eqZtZXRob2SRo09uZQ=="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntAndStringArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string"),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { 42, "string" }),
|
||||
binary: "lQSAo3h5eqZtZXRob2SSKqZzdHJpbmc="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndIntStringAndCustomObjectArgs",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, 42, "string", new CustomObject()),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { 42, "string", new CustomObject() }),
|
||||
binary: "lQSAo3h5eqZtZXRob2STKqZzdHJpbmeGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithNoHeadersAndCustomObjectArrayArg",
|
||||
message: new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() }),
|
||||
message: new StreamInvocationMessage("xyz", "method", null, new object[] { new CustomObject(), new CustomObject() }),
|
||||
binary: "lQSAo3h5eqZtZXRob2SShqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQIDhqpTdHJpbmdQcm9wqFNpZ25hbFIhqkRvdWJsZVByb3DLQBkh+1RCzxKnSW50UHJvcCqsRGF0ZVRpbWVQcm9w1v9Y7ByAqE51bGxQcm9wwKtCeXRlQXJyUHJvcMQDAQID"),
|
||||
new ProtocolTestData(
|
||||
name: "StreamInvocationWithHeadersAndCustomObjectArrayArg",
|
||||
message: AddHeaders(TestHeaders, new StreamInvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null, new[] { new CustomObject(), new CustomObject() })),
|
||||
message: AddHeaders(TestHeaders, new StreamInvocationMessage("xyz", "method", null, new object[] { new CustomObject(), new CustomObject() })),
|
||||
binary: "lQSDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6pm1ldGhvZJKGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgOGqlN0cmluZ1Byb3CoU2lnbmFsUiGqRG91YmxlUHJvcMtAGSH7VELPEqdJbnRQcm9wKqxEYXRlVGltZVByb3DW/1jsHICoTnVsbFByb3DAq0J5dGVBcnJQcm9wxAMBAgM="),
|
||||
|
||||
// CancelInvocation Messages
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithNoHeaders",
|
||||
message: new CancelInvocationMessage(invocationId: "xyz"),
|
||||
message: new CancelInvocationMessage("xyz"),
|
||||
binary: "kwWAo3h5eg=="),
|
||||
new ProtocolTestData(
|
||||
name: "CancelInvocationWithHeaders",
|
||||
message: AddHeaders(TestHeaders, new CancelInvocationMessage(invocationId: "xyz")),
|
||||
message: AddHeaders(TestHeaders, new CancelInvocationMessage("xyz")),
|
||||
binary: "kwWDo0Zvb6NCYXKyS2V5V2l0aApOZXcNCkxpbmVzq1N0aWxsIFdvcmtzsVZhbHVlV2l0aE5ld0xpbmVzsEFsc28KV29ya3MNCkZpbmWjeHl6"),
|
||||
|
||||
// Ping Messages
|
||||
|
|
@ -257,10 +257,10 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
[Fact]
|
||||
public void ParseMessageWithExtraData()
|
||||
{
|
||||
var expectedMessage = new InvocationMessage(invocationId: "xyz", target: "method", argumentBindingException: null);
|
||||
var expectedMessage = new InvocationMessage("xyz", "method", null, Array.Empty<object>());
|
||||
|
||||
// Verify that the input binary string decodes to the expected MsgPack primitives
|
||||
var bytes = new byte[] { Array(6), 1, 0x80, String(3), (byte)'x', (byte)'y', (byte)'z', String(6), (byte)'m', (byte)'e', (byte)'t', (byte)'h', (byte)'o', (byte)'d', Array(0), String(2), (byte)'e', (byte)'x' };
|
||||
var bytes = new byte[] { ArrayBytes(6), 1, 0x80, StringBytes(3), (byte)'x', (byte)'y', (byte)'z', StringBytes(6), (byte)'m', (byte)'e', (byte)'t', (byte)'h', (byte)'o', (byte)'d', ArrayBytes(0), StringBytes(2), (byte)'e', (byte)'x' };
|
||||
|
||||
// Parse the input fully now.
|
||||
bytes = Frame(bytes);
|
||||
|
|
@ -442,17 +442,17 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
|
|||
public void SerializerCanSerializeTypesWithNoDefaultCtor()
|
||||
{
|
||||
var result = Write(CompletionMessage.WithResult("0", new List<int> { 42 }.AsReadOnly()));
|
||||
AssertMessages(new byte[] { Array(5), 3, 0x80, String(1), (byte)'0', 0x03, Array(1), 42 }, result);
|
||||
AssertMessages(new byte[] { ArrayBytes(5), 3, 0x80, StringBytes(1), (byte)'0', 0x03, ArrayBytes(1), 42 }, result);
|
||||
}
|
||||
|
||||
private byte Array(int size)
|
||||
private byte ArrayBytes(int size)
|
||||
{
|
||||
Debug.Assert(size < 16, "Test code doesn't support array sizes greater than 15");
|
||||
|
||||
return (byte)(0x90 | size);
|
||||
}
|
||||
|
||||
private byte String(int size)
|
||||
private byte StringBytes(int size)
|
||||
{
|
||||
Debug.Assert(size < 16, "Test code doesn't support string sizes greater than 15");
|
||||
|
||||
|
|
|
|||
|
|
@ -166,15 +166,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
public Task<string> SendInvocationAsync(string methodName, bool nonBlocking, params object[] args)
|
||||
{
|
||||
var invocationId = nonBlocking ? null : GetInvocationId();
|
||||
return SendHubMessageAsync(new InvocationMessage(invocationId, methodName,
|
||||
argumentBindingException: null, arguments: args));
|
||||
return SendHubMessageAsync(new InvocationMessage(invocationId, methodName, null, args));
|
||||
}
|
||||
|
||||
public Task<string> SendStreamInvocationAsync(string methodName, params object[] args)
|
||||
{
|
||||
var invocationId = GetInvocationId();
|
||||
return SendHubMessageAsync(new StreamInvocationMessage(invocationId, methodName,
|
||||
argumentBindingException: null, arguments: args));
|
||||
return SendHubMessageAsync(new StreamInvocationMessage(invocationId, methodName, null, args));
|
||||
}
|
||||
|
||||
public async Task<string> SendHubMessageAsync(HubMessage message)
|
||||
|
|
|
|||
|
|
@ -1430,8 +1430,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
await client.Connected.OrTimeout();
|
||||
|
||||
var invocationId = Guid.NewGuid().ToString("N");
|
||||
await client.SendHubMessageAsync(new StreamInvocationMessage(invocationId, nameof(StreamingHub.BlockingStream),
|
||||
argumentBindingException: null));
|
||||
await client.SendHubMessageAsync(new StreamInvocationMessage(invocationId, nameof(StreamingHub.BlockingStream), null, Array.Empty<object>()));
|
||||
|
||||
// cancel the Streaming method
|
||||
await client.SendHubMessageAsync(new CancelInvocationMessage(invocationId)).OrTimeout();
|
||||
|
|
|
|||
Loading…
Reference in New Issue