Allow null arguments from HubConnection (#11241)

This commit is contained in:
Brennan 2019-06-14 20:37:13 -07:00 committed by GitHub
parent f652c22202
commit 5872814a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -627,7 +627,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
for (var i = 0; i < args.Length; i++)
{
if (ReflectionHelper.IsStreamingType(args[i].GetType()))
if (args[i] != null && ReflectionHelper.IsStreamingType(args[i].GetType()))
{
if (readers == null)
{

View File

@ -138,6 +138,34 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
}
[Theory]
[MemberData(nameof(HubProtocolsList))]
public async Task CanSendNull(string protocolName)
{
var protocol = HubProtocols[protocolName];
using (StartServer<Startup>(out var server))
{
var connection = CreateHubConnection(server.Url, "/default", HttpTransportType.LongPolling, protocol, LoggerFactory);
try
{
await connection.StartAsync().OrTimeout();
var result = await connection.InvokeAsync<string>(nameof(TestHub.Echo), null).OrTimeout();
Assert.Null(result);
}
catch (Exception ex)
{
LoggerFactory.CreateLogger<HubConnectionTests>().LogError(ex, "{ExceptionType} from test", ex.GetType().FullName);
throw;
}
finally
{
await connection.DisposeAsync().OrTimeout();
}
}
}
[Theory]
[MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))]
[LogLevel(LogLevel.Trace)]