From 2597e52e53923a1b937918ca374e355692c1a8cf Mon Sep 17 00:00:00 2001 From: Mikael Mengistu Date: Wed, 5 Jul 2017 22:56:03 -0700 Subject: [PATCH] Rename HubConnection Extension Methods from Invoke to InvokeAsync (#637) --- samples/ClientSample/HubSample.cs | 2 +- .../HubConnectionExtensions.cs | 12 ++++++------ .../HubConnectionTests.cs | 10 +++++----- .../HubConnectionProtocolTests.cs | 10 +++++----- .../HubConnectionTests.cs | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/samples/ClientSample/HubSample.cs b/samples/ClientSample/HubSample.cs index aaf3b31002..e286fff6a7 100644 --- a/samples/ClientSample/HubSample.cs +++ b/samples/ClientSample/HubSample.cs @@ -60,7 +60,7 @@ namespace ClientSample break; } - await connection.Invoke("Send", cts.Token, line); + await connection.InvokeAsync("Send", cts.Token, line); } } catch (AggregateException aex) when (aex.InnerExceptions.All(e => e is OperationCanceledException)) diff --git a/src/Microsoft.AspNetCore.SignalR.Client/HubConnectionExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Client/HubConnectionExtensions.cs index 7ef2ff80cd..89667ca7c1 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client/HubConnectionExtensions.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client/HubConnectionExtensions.cs @@ -10,10 +10,10 @@ namespace Microsoft.AspNetCore.SignalR.Client { public static class HubConnectionExtensions { - public static Task Invoke(this HubConnection hubConnection, string methodName, params object[] args) => - Invoke(hubConnection, methodName, CancellationToken.None, args); + public static Task InvokeAsync(this HubConnection hubConnection, string methodName, params object[] args) => + InvokeAsync(hubConnection, methodName, CancellationToken.None, args); - public static Task Invoke(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken, params object[] args) + public static Task InvokeAsync(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken, params object[] args) { if (hubConnection == null) { @@ -23,10 +23,10 @@ namespace Microsoft.AspNetCore.SignalR.Client return hubConnection.InvokeAsync(methodName, typeof(object), cancellationToken, args); } - public static Task Invoke(this HubConnection hubConnection, string methodName, params object[] args) => - Invoke(hubConnection, methodName, CancellationToken.None, args); + public static Task InvokeAsync(this HubConnection hubConnection, string methodName, params object[] args) => + InvokeAsync(hubConnection, methodName, CancellationToken.None, args); - public async static Task Invoke(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken, params object[] args) + public async static Task InvokeAsync(this HubConnection hubConnection, string methodName, CancellationToken cancellationToken, params object[] args) { if (hubConnection == null) { diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index d01519bed9..d0f7db0011 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests { await connection.StartAsync(); - var result = await connection.Invoke(nameof(TestHub.HelloWorld)); + var result = await connection.InvokeAsync(nameof(TestHub.HelloWorld)); Assert.Equal("Hello World!", result); } @@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests { await connection.StartAsync(); - var result = await connection.Invoke(nameof(TestHub.Echo), originalMessage); + var result = await connection.InvokeAsync(nameof(TestHub.Echo), originalMessage); Assert.Equal(originalMessage, result); } @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests { await connection.StartAsync(); - var result = await connection.Invoke(nameof(TestHub.Echo).ToLowerInvariant(), originalMessage); + var result = await connection.InvokeAsync(nameof(TestHub.Echo).ToLowerInvariant(), originalMessage); Assert.Equal(originalMessage, result); } @@ -134,7 +134,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests var tcs = new TaskCompletionSource(); connection.On("Echo", tcs.SetResult); - await connection.Invoke(nameof(TestHub.CallEcho), originalMessage).OrTimeout(); + await connection.InvokeAsync(nameof(TestHub.CallEcho), originalMessage).OrTimeout(); Assert.Equal(originalMessage, await tcs.Task.OrTimeout()); } @@ -181,7 +181,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests await connection.StartAsync(); var ex = await Assert.ThrowsAnyAsync( - async () => await connection.Invoke("!@#$%")); + async () => await connection.InvokeAsync("!@#$%")); Assert.Equal("Unknown hub method '!@#$%'", ex.Message); } diff --git a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionProtocolTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionProtocolTests.cs index 0818fdc422..f2cca4d845 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionProtocolTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionProtocolTests.cs @@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("Foo"); + var invokeTask = hubConnection.InvokeAsync("Foo"); // skip negotiation await connection.ReadSentTextMessageAsync().OrTimeout(); @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("Foo"); + var invokeTask = hubConnection.InvokeAsync("Foo"); await connection.ReceiveJsonMessage(new { invocationId = "1", type = 3 }).OrTimeout(); @@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("Foo"); + var invokeTask = hubConnection.InvokeAsync("Foo"); await connection.ReceiveJsonMessage(new { invocationId = "1", type = 3, result = 42 }).OrTimeout(); @@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("Foo"); + var invokeTask = hubConnection.InvokeAsync("Foo"); await connection.ReceiveJsonMessage(new { invocationId = "1", type = 3, error = "An error occurred" }).OrTimeout(); @@ -256,7 +256,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("Foo"); + var invokeTask = hubConnection.InvokeAsync("Foo"); await connection.ReceiveJsonMessage(new { invocationId = "1", type = 2, item = 42 }).OrTimeout(); diff --git a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.cs index 31a4d1cd02..4d96a7fb28 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests await hubConnection.StartAsync(); var actualException = - await Assert.ThrowsAsync(async () => await hubConnection.Invoke("test")); + await Assert.ThrowsAsync(async () => await hubConnection.InvokeAsync("test")); Assert.Same(exception, actualException); } @@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests await hubConnection.StartAsync(); await hubConnection.DisposeAsync(); var exception = await Assert.ThrowsAsync( - async () => await hubConnection.Invoke("test")); + async () => await hubConnection.InvokeAsync("test")); Assert.Equal("Connection has been terminated.", exception.Message); } @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests var hubConnection = new HubConnection(connection, new LoggerFactory()); await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("testMethod"); + var invokeTask = hubConnection.InvokeAsync("testMethod"); await hubConnection.DisposeAsync(); await Assert.ThrowsAsync(async () => await invokeTask); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests var hubConnection = new HubConnection(mockConnection.Object, new LoggerFactory()); await hubConnection.StartAsync(); - var invokeTask = hubConnection.Invoke("testMethod"); + var invokeTask = hubConnection.InvokeAsync("testMethod"); await hubConnection.DisposeAsync(); var thrown = await Assert.ThrowsAsync(exception.GetType(), async () => await invokeTask);