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

View File

@ -3,6 +3,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.SignalR
{
@ -62,12 +63,12 @@ namespace Microsoft.AspNetCore.SignalR
public virtual Task OnConnectedAsync()
{
return Task.CompletedTask;
return TaskCache.CompletedTask;
}
public virtual Task OnDisconnectedAsync()
{
return Task.CompletedTask;
return TaskCache.CompletedTask;
}
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
= new Dictionary<string, Func<Connection, InvocationDescriptor, Task<InvocationResultDescriptor>>>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Type[]> _paramTypes = new Dictionary<string, Type[]>();
private static object[] EmptyArray = new object[0];
private readonly HubLifetimeManager<THub> _lifetimeManager;
private readonly IHubContext<THub, TClient> _hubContext;
@ -183,7 +184,7 @@ namespace Microsoft.AspNetCore.SignalR
try
{
var arguments = invocationDescriptor.Arguments ?? Array.Empty<object>();
var arguments = invocationDescriptor.Arguments ?? EmptyArray;
var args = arguments
.Zip(parameters, (a, p) => Convert.ChangeType(a, p.ParameterType))

View File

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

View File

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

View File

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

View File

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

View File

@ -25,10 +25,15 @@
"dependencies": {
"Channels": "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-*"
},
"frameworks": {
"netstandard1.3": {}
"netstandard1.3": {},
"net451": {}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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