Use expression body properties and implicit arrays where possible (#1906)

This commit is contained in:
James Newton-King 2018-04-08 21:40:01 +12:00 committed by GitHub
parent 0f663cadc4
commit 27d18578d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 82 additions and 93 deletions

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "Foo", 2.0f); hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "Foo", 2.0f);
break; break;
case Message.ManyArguments: case Message.ManyArguments:
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "string", 2.0f, true, (byte)9, new int[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L); hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, 1, "string", 2.0f, true, (byte)9, new[] { 5, 4, 3, 2, 1 }, 'c', 123456789101112L);
break; break;
case Message.LargeArguments: case Message.LargeArguments:
hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, new string('F', 10240), new string('B', 10240)); hubMessage = new InvocationMessage(target: "Target", argumentBindingException: null, new string('F', 10240), new string('B', 10240));

View File

@ -34,7 +34,8 @@ namespace System.Threading.Tasks
public ForceAsyncAwaiter GetAwaiter() { return this; } public ForceAsyncAwaiter GetAwaiter() { return this; }
public bool IsCompleted { get { return false; } } // the purpose of this type is to always force a continuation // The purpose of this type is to always force a continuation
public bool IsCompleted => false;
public void GetResult() { _task.GetAwaiter().GetResult(); } public void GetResult() { _task.GetAwaiter().GetResult(); }
@ -57,7 +58,8 @@ namespace System.Threading.Tasks
public ForceAsyncAwaiter<T> GetAwaiter() { return this; } public ForceAsyncAwaiter<T> GetAwaiter() { return this; }
public bool IsCompleted { get { return false; } } // the purpose of this type is to always force a continuation // The purpose of this type is to always force a continuation
public bool IsCompleted => false;
public T GetResult() { return _task.GetAwaiter().GetResult(); } public T GetResult() { return _task.GetAwaiter().GetResult(); }

View File

@ -56,10 +56,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Client
} }
return _transport; return _transport;
} }
set set => throw new NotSupportedException("The transport pipe isn't settable.");
{
throw new NotSupportedException("The transport pipe isn't settable.");
}
} }
public override IFeatureCollection Features { get; } = new FeatureCollection(); public override IFeatureCollection Features { get; } = new FeatureCollection();

View File

@ -15,10 +15,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
public string ConnectionId public string ConnectionId
{ {
get get => _connectionId;
{
return _connectionId;
}
set set
{ {
_cachedToString = null; _cachedToString = null;

View File

@ -97,10 +97,7 @@ namespace Microsoft.AspNetCore.Http.Connections
public IDuplexPipe Application public IDuplexPipe Application
{ {
get get => _application;
{
return _application;
}
set set
{ {
if (value != null) if (value != null)

View File

@ -12,8 +12,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
{ {
public static class ServerSentEventsMessageFormatter public static class ServerSentEventsMessageFormatter
{ {
private static readonly byte[] DataPrefix = new byte[] { (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)':', (byte)' ' }; private static readonly byte[] DataPrefix = new[] { (byte)'d', (byte)'a', (byte)'t', (byte)'a', (byte)':', (byte)' ' };
private static readonly byte[] Newline = new byte[] { (byte)'\r', (byte)'\n' }; private static readonly byte[] Newline = new[] { (byte)'\r', (byte)'\n' };
private const byte LineFeed = (byte)'\n'; private const byte LineFeed = (byte)'\n';

View File

@ -18,52 +18,52 @@ namespace Microsoft.AspNetCore.SignalR.Client
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken); return hubConnection.InvokeAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
} }
public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default) public static Task InvokeAsync(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default)

View File

@ -18,52 +18,52 @@ namespace Microsoft.AspNetCore.SignalR.Client
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
} }
public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default) public static Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
{ {
return hubConnection.InvokeAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken); return hubConnection.InvokeAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
} }
public static async Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default) public static async Task<TResult> InvokeAsync<TResult>(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default)

View File

@ -16,52 +16,52 @@ namespace Microsoft.AspNetCore.SignalR.Client
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
} }
public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default) public static Task SendAsync(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
{ {
return hubConnection.SendAsync(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken); return hubConnection.SendAsync(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
} }
} }
} }

View File

@ -17,52 +17,52 @@ namespace Microsoft.AspNetCore.SignalR.Client
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }, cancellationToken);
} }
public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default) public static Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10, CancellationToken cancellationToken = default)
{ {
return hubConnection.StreamAsChannelAsync<TResult>(methodName, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken); return hubConnection.StreamAsChannelAsync<TResult>(methodName, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }, cancellationToken);
} }
public static async Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default) public static async Task<ChannelReader<TResult>> StreamAsChannelAsync<TResult>(this HubConnection hubConnection, string methodName, object[] args, CancellationToken cancellationToken = default)

View File

@ -27,13 +27,7 @@ namespace Microsoft.AspNetCore.SignalR.Internal.Protocol
} }
} }
public Exception ArgumentBindingException public Exception ArgumentBindingException => _argumentBindingException?.SourceException;
{
get
{
return _argumentBindingException?.SourceException;
}
}
protected HubMethodInvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, object[] arguments) protected HubMethodInvocationMessage(string invocationId, string target, ExceptionDispatchInfo argumentBindingException, object[] arguments)
: base(invocationId) : base(invocationId)

View File

@ -9,8 +9,16 @@ namespace Microsoft.AspNetCore.SignalR
public new DynamicHubClients Clients public new DynamicHubClients Clients
{ {
get { return _clients ?? new DynamicHubClients(base.Clients); } get
set { _clients = value; } {
if (_clients == null)
{
_clients = new DynamicHubClients(base.Clients);
}
return _clients;
}
set => _clients = value;
} }
} }
} }

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.SignalR
{ {
_connectionId = connectionId; _connectionId = connectionId;
_hubClients = hubClients; _hubClients = hubClients;
_currentConnectionId = new string[] { _connectionId }; _currentConnectionId = new[] { _connectionId };
} }
public IClientProxy Caller => _hubClients.Client(_connectionId); public IClientProxy Caller => _hubClients.Client(_connectionId);

View File

@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.SignalR
} }
return _clients; return _clients;
} }
set { _clients = value; } set => _clients = value;
} }
} }
} }

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1 }); return clientProxy.SendCoreAsync(method, new[] { arg1 });
} }
/// <summary> /// <summary>
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2 });
} }
/// <summary> /// <summary>
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3 });
} }
/// <summary> /// <summary>
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4 });
} }
/// <summary> /// <summary>
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5 });
} }
/// <summary> /// <summary>
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6 });
} }
/// <summary> /// <summary>
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7 });
} }
/// <summary> /// <summary>
@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 });
} }
/// <summary> /// <summary>
@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 });
} }
/// <summary> /// <summary>
@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.SignalR
/// <returns>A task that represents when the data has been sent to the client.</returns> /// <returns>A task that represents when the data has been sent to the client.</returns>
public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10) public static Task SendAsync(this IClientProxy clientProxy, string method, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8, object arg9, object arg10)
{ {
return clientProxy.SendCoreAsync(method, new object[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 }); return clientProxy.SendCoreAsync(method, new[] { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 });
} }
} }
} }

View File

@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.SignalR
var invokeMethod = typeof(IClientProxy).GetMethod( var invokeMethod = typeof(IClientProxy).GetMethod(
nameof(IClientProxy.SendCoreAsync), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, nameof(IClientProxy.SendCoreAsync), BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
new Type[] { typeof(string), typeof(object[]) }, null); new[] { typeof(string), typeof(object[]) }, null);
methodBuilder.SetReturnType(interfaceMethodInfo.ReturnType); methodBuilder.SetReturnType(interfaceMethodInfo.ReturnType);
methodBuilder.SetParameters(paramTypes); methodBuilder.SetParameters(paramTypes);

View File

@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
await dispatcher.ExecuteAsync(context, options, c => Task.CompletedTask); await dispatcher.ExecuteAsync(context, options, c => Task.CompletedTask);
// This write should complete immediately but it exceeds the writer threshold // This write should complete immediately but it exceeds the writer threshold
var writeTask = connection.Application.Output.WriteAsync(new byte[] { (byte)'b', (byte)'y', (byte)'t', (byte)'e', (byte)'s' }); var writeTask = connection.Application.Output.WriteAsync(new[] { (byte)'b', (byte)'y', (byte)'t', (byte)'e', (byte)'s' });
Assert.False(writeTask.IsCompleted); Assert.False(writeTask.IsCompleted);
@ -1651,7 +1651,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
private HttpContext HttpContext; private HttpContext HttpContext;
private AuthenticationScheme _scheme; private AuthenticationScheme _scheme;
protected virtual bool ShouldAccept { get => true; } protected virtual bool ShouldAccept => true;
public Task<AuthenticateResult> AuthenticateAsync() public Task<AuthenticateResult> AuthenticateAsync()
{ {

View File

@ -519,7 +519,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
{ {
await connection.StartAsync().OrTimeout(); await connection.StartAsync().OrTimeout();
var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("Echo", new int[] { 42 })).OrTimeout(); var ex = await Assert.ThrowsAsync<HubException>(() => connection.InvokeAsync("Echo", new[] { 42 })).OrTimeout();
Assert.StartsWith("Failed to invoke 'Echo' due to an error on the server.", ex.Message); Assert.StartsWith("Failed to invoke 'Echo' due to an error on the server.", ex.Message);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact] [Fact]
public async Task LongPollingTransportDispatchesMessagesReceivedFromPoll() public async Task LongPollingTransportDispatchesMessagesReceivedFromPoll()
{ {
var message1Payload = new byte[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o' }; var message1Payload = new[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o' };
var firstCall = true; var firstCall = true;
var mockHttpHandler = new Mock<HttpMessageHandler>(); var mockHttpHandler = new Mock<HttpMessageHandler>();
@ -337,7 +337,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
await longPollingTransport.Input.ReadAllAsync(); await longPollingTransport.Input.ReadAllAsync();
Assert.Single(sentRequests); Assert.Single(sentRequests);
Assert.Equal(new byte[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o', (byte)'W', (byte)'o', (byte)'r', (byte)'l', (byte)'d' Assert.Equal(new[] { (byte)'H', (byte)'e', (byte)'l', (byte)'l', (byte)'o', (byte)'W', (byte)'o', (byte)'r', (byte)'l', (byte)'d'
}, sentRequests[0]); }, sentRequests[0]);
} }
finally finally

View File

@ -12,13 +12,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
public class WebSocketsSupportedConditionAttribute : Attribute, ITestCondition public class WebSocketsSupportedConditionAttribute : Attribute, ITestCondition
{ {
public bool IsMet public bool IsMet => TestHelpers.IsWebSocketsSupported();
{
get
{
return TestHelpers.IsWebSocketsSupported();
}
}
public string SkipReason => "No WebSockets Client for this platform"; public string SkipReason => "No WebSockets Client for this platform";
} }

View File

@ -872,7 +872,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
Assert.Equal("Array", invocation.Target); Assert.Equal("Array", invocation.Target);
Assert.Single(invocation.Arguments); Assert.Single(invocation.Arguments);
var values = ((JArray)invocation.Arguments[0]).Select(t => t.Value<int>()).ToArray(); var values = ((JArray)invocation.Arguments[0]).Select(t => t.Value<int>()).ToArray();
Assert.Equal(new int[] { 1, 2, 3 }, values); Assert.Equal(new[] { 1, 2, 3 }, values);
} }
// kill the connections // kill the connections

View File

@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
public Task SendArray() public Task SendArray()
{ {
return Clients.All.SendAsync("Array", new int[] { 1, 2, 3 }); return Clients.All.SendAsync("Array", new[] { 1, 2, 3 });
} }
public Task<int> TaskValueMethod() public Task<int> TaskValueMethod()