Added support for net451 and netstandard1.3

- Replaced Task.CompletedTask with TaskCache.CompletedTask
- Updated tests and src
This commit is contained in:
David Fowler 2016-11-07 21:39:19 -08:00
parent 239999e4c9
commit d00f1f93b2
13 changed files with 39 additions and 20 deletions

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Channels; using Channels;
using Microsoft.AspNetCore.Sockets; using Microsoft.AspNetCore.Sockets;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR
{ {
@ -29,7 +30,7 @@ namespace Microsoft.AspNetCore.SignalR
groups.Add(groupName); groups.Add(groupName);
} }
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
public override Task RemoveGroupAsync(Connection connection, string groupName) public override Task RemoveGroupAsync(Connection connection, string groupName)
@ -41,7 +42,7 @@ namespace Microsoft.AspNetCore.SignalR
groups.Remove(groupName); groups.Remove(groupName);
} }
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
public override Task InvokeAllAsync(string methodName, object[] args) public override Task InvokeAllAsync(string methodName, object[] args)
@ -109,13 +110,13 @@ namespace Microsoft.AspNetCore.SignalR
public override Task OnConnectedAsync(Connection connection) public override Task OnConnectedAsync(Connection connection)
{ {
_connections.Add(connection); _connections.Add(connection);
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
public override Task OnDisconnectedAsync(Connection connection) public override Task OnDisconnectedAsync(Connection connection)
{ {
_connections.Remove(connection); _connections.Remove(connection);
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
} }

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR
{ {
@ -62,12 +63,12 @@ namespace Microsoft.AspNetCore.SignalR
public virtual Task OnConnectedAsync() public virtual Task OnConnectedAsync()
{ {
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
public virtual Task OnDisconnectedAsync() public virtual Task OnDisconnectedAsync()
{ {
return Task.CompletedTask; return TaskCache.CompletedTask;
} }
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)

View File

@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.SignalR
private readonly Dictionary<string, Func<Connection, InvocationDescriptor, Task<InvocationResultDescriptor>>> _callbacks private readonly Dictionary<string, Func<Connection, InvocationDescriptor, Task<InvocationResultDescriptor>>> _callbacks
= new Dictionary<string, Func<Connection, InvocationDescriptor, Task<InvocationResultDescriptor>>>(StringComparer.OrdinalIgnoreCase); = new Dictionary<string, Func<Connection, InvocationDescriptor, Task<InvocationResultDescriptor>>>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Type[]> _paramTypes = new Dictionary<string, Type[]>(); private readonly Dictionary<string, Type[]> _paramTypes = new Dictionary<string, Type[]>();
private static object[] EmptyArray = new object[0];
private readonly HubLifetimeManager<THub> _lifetimeManager; private readonly HubLifetimeManager<THub> _lifetimeManager;
private readonly IHubContext<THub, TClient> _hubContext; private readonly IHubContext<THub, TClient> _hubContext;
@ -183,7 +184,7 @@ namespace Microsoft.AspNetCore.SignalR
try try
{ {
var arguments = invocationDescriptor.Arguments ?? Array.Empty<object>(); var arguments = invocationDescriptor.Arguments ?? EmptyArray;
var args = arguments var args = arguments
.Zip(parameters, (a, p) => Convert.ChangeType(a, p.ParameterType)) .Zip(parameters, (a, p) => Convert.ChangeType(a, p.ParameterType))

View File

@ -25,12 +25,16 @@
"Microsoft.AspNetCore.Sockets": { "Microsoft.AspNetCore.Sockets": {
"target": "project" "target": "project"
}, },
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
},
"NETStandard.Library": "1.6.1-*", "NETStandard.Library": "1.6.1-*",
"Newtonsoft.Json": "9.0.1" "Newtonsoft.Json": "9.0.1"
}, },
"frameworks": { "frameworks": {
"netstandard1.6": { "netstandard1.3": {},
} "net451": {}
} }
} }

View File

@ -27,7 +27,6 @@ namespace Microsoft.AspNetCore.Sockets
{ {
if (!context.WebSockets.IsWebSocketRequest) if (!context.WebSockets.IsWebSocketRequest)
{ {
await Task.CompletedTask;
return; return;
} }

View File

@ -30,6 +30,6 @@
}, },
"frameworks": { "frameworks": {
"netstandard1.3": {}, "netstandard1.3": {},
"net46": {} "net451": {}
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.Extensions.WebSockets.Internal namespace Microsoft.Extensions.WebSockets.Internal
{ {
@ -129,7 +130,7 @@ namespace Microsoft.Extensions.WebSockets.Internal
connection.ExecuteAsync((frame, _) => connection.ExecuteAsync((frame, _) =>
{ {
messageHandler(frame); messageHandler(frame);
return Task.CompletedTask; return TaskCache.CompletedTask;
}, null); }, null);
/// <summary> /// <summary>
@ -143,7 +144,7 @@ namespace Microsoft.Extensions.WebSockets.Internal
connection.ExecuteAsync((frame, s) => connection.ExecuteAsync((frame, s) =>
{ {
messageHandler(frame, s); messageHandler(frame, s);
return Task.CompletedTask; return TaskCache.CompletedTask;
}, state); }, state);
/// <summary> /// <summary>

View File

@ -25,10 +25,15 @@
"dependencies": { "dependencies": {
"Channels": "0.2.0-beta-*", "Channels": "0.2.0-beta-*",
"Channels.Text.Primitives": "0.2.0-beta-*", "Channels.Text.Primitives": "0.2.0-beta-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
},
"NETStandard.Library": "1.6.1-*" "NETStandard.Library": "1.6.1-*"
}, },
"frameworks": { "frameworks": {
"netstandard1.3": {} "netstandard1.3": {},
"net451": {}
} }
} }

View File

@ -20,7 +20,7 @@
} }
} }
}, },
"net46": {} "net451": {}
}, },
"testRunner": "xunit" "testRunner": "xunit"
} }

View File

@ -10,18 +10,19 @@
"Microsoft.Extensions.Logging": "1.1.0-*", "Microsoft.Extensions.Logging": "1.1.0-*",
"Microsoft.Extensions.Logging.Console": "1.1.0-*", "Microsoft.Extensions.Logging.Console": "1.1.0-*",
"Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*",
"System.Diagnostics.FileVersionInfo": "4.3.0-*",
"xunit": "2.2.0-*" "xunit": "2.2.0-*"
}, },
"testRunner": "xunit", "testRunner": "xunit",
"frameworks": { "frameworks": {
"netcoreapp1.1": { "netcoreapp1.1": {
"dependencies": { "dependencies": {
"System.Diagnostics.FileVersionInfo": "4.3.0-*",
"Microsoft.NETCore.App": { "Microsoft.NETCore.App": {
"version": "1.1.0-*", "version": "1.1.0-*",
"type": "platform" "type": "platform"
} }
} }
} },
"net451": { }
} }
} }

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Channels; using Channels;
using Microsoft.Extensions.Internal;
using Xunit; using Xunit;
namespace Microsoft.Extensions.WebSockets.Internal.Tests namespace Microsoft.Extensions.WebSockets.Internal.Tests
@ -22,7 +23,7 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
var client = pair.ClientSocket.ExecuteAsync(_ => var client = pair.ClientSocket.ExecuteAsync(_ =>
{ {
Assert.False(true, "did not expect the client to receive any frames!"); Assert.False(true, "did not expect the client to receive any frames!");
return Task.CompletedTask; return TaskCache.CompletedTask;
}); });
// Send Frames // Send Frames

View File

@ -5,6 +5,7 @@ using System;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Channels; using Channels;
using Microsoft.Extensions.Internal;
using Xunit; using Xunit;
namespace Microsoft.Extensions.WebSockets.Internal.Tests namespace Microsoft.Extensions.WebSockets.Internal.Tests
@ -182,7 +183,7 @@ namespace Microsoft.Extensions.WebSockets.Internal.Tests
executeTask = connection.ExecuteAsync(f => executeTask = connection.ExecuteAsync(f =>
{ {
Assert.False(true, "Did not expect to receive any messages"); Assert.False(true, "Did not expect to receive any messages");
return Task.CompletedTask; return TaskCache.CompletedTask;
}); });
await producer(connection).OrTimeout(); await producer(connection).OrTimeout();
inbound.CompleteWriter(); inbound.CompleteWriter();

View File

@ -5,6 +5,10 @@
"dependencies": { "dependencies": {
"dotnet-test-xunit": "2.2.0-*", "dotnet-test-xunit": "2.2.0-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
},
"Microsoft.Extensions.WebSockets.Internal": "0.1.0-*", "Microsoft.Extensions.WebSockets.Internal": "0.1.0-*",
"xunit": "2.2.0-*" "xunit": "2.2.0-*"
}, },
@ -22,7 +26,7 @@
"portable-net451+win8" "portable-net451+win8"
] ]
}, },
"net46": { "net451": {
"dependencies": { "dependencies": {
"xunit.runner.console": "2.1.0" "xunit.runner.console": "2.1.0"
} }