From 61c3d0c4030033013d4ad155d0f284aba384070a Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 5 Apr 2018 01:32:10 -0700 Subject: [PATCH] Added Microsoft.AspNetCore.SignalR.Protocols.Json (#1861) - Fixed package descriptions - Call AddJsonProtocol from both the SignalR.Core (client and server) --- SignalR.sln | 9 +++++++- .../HubConnectionBuilder.cs | 2 +- ...soft.AspNetCore.SignalR.Client.Core.csproj | 1 + .../{Protocol => }/Utf8BufferTextReader.cs | 4 ++-- .../{Protocol => }/Utf8BufferTextWriter.cs | 4 ++-- .../Microsoft.AspNetCore.SignalR.Core.csproj | 2 +- .../SignalRDependencyInjectionExtensions.cs | 5 +++-- .../Internal/Protocol/JsonHubProtocol.cs | 0 .../JsonHubProtocolOptions.cs | 0 ...onProtocolDependencyInjectionExtensions.cs | 0 ...t.AspNetCore.SignalR.Protocols.Json.csproj | 21 +++++++++++++++++++ ...spNetCore.SignalR.Protocols.MsgPack.csproj | 6 +----- .../SignalRDependencyInjectionExtensions.cs | 3 +-- .../Protocol/Utf8BufferTextReaderTests.cs | 2 +- .../Protocol/Utf8BufferTextWriterTests.cs | 2 +- 15 files changed, 43 insertions(+), 18 deletions(-) rename src/Microsoft.AspNetCore.SignalR.Common/Internal/{Protocol => }/Utf8BufferTextReader.cs (95%) rename src/Microsoft.AspNetCore.SignalR.Common/Internal/{Protocol => }/Utf8BufferTextWriter.cs (98%) rename src/{Microsoft.AspNetCore.SignalR.Common => Microsoft.AspNetCore.SignalR.Protocols.Json}/Internal/Protocol/JsonHubProtocol.cs (100%) rename src/{Microsoft.AspNetCore.SignalR.Common => Microsoft.AspNetCore.SignalR.Protocols.Json}/JsonHubProtocolOptions.cs (100%) rename src/{Microsoft.AspNetCore.SignalR.Core => Microsoft.AspNetCore.SignalR.Protocols.Json}/JsonProtocolDependencyInjectionExtensions.cs (100%) create mode 100644 src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj diff --git a/SignalR.sln b/SignalR.sln index 6f0eff3555..78e41b75cd 100644 --- a/SignalR.sln +++ b/SignalR.sln @@ -1,4 +1,4 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27110.0 MinimumVisualStudioVersion = 15.0.26730.03 @@ -85,6 +85,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "clients\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkServer", "benchmarks\BenchmarkServer\BenchmarkServer.csproj", "{B5286020-C218-443C-91A9-B65751FB9B29}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.SignalR.Protocols.Json", "src\Microsoft.AspNetCore.SignalR.Protocols.Json\Microsoft.AspNetCore.SignalR.Protocols.Json.csproj", "{896FA5EE-63A5-4EAC-9F09-346584BB4830}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -199,6 +201,10 @@ Global {B5286020-C218-443C-91A9-B65751FB9B29}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5286020-C218-443C-91A9-B65751FB9B29}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5286020-C218-443C-91A9-B65751FB9B29}.Release|Any CPU.Build.0 = Release|Any CPU + {896FA5EE-63A5-4EAC-9F09-346584BB4830}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {896FA5EE-63A5-4EAC-9F09-346584BB4830}.Debug|Any CPU.Build.0 = Debug|Any CPU + {896FA5EE-63A5-4EAC-9F09-346584BB4830}.Release|Any CPU.ActiveCfg = Release|Any CPU + {896FA5EE-63A5-4EAC-9F09-346584BB4830}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -231,6 +237,7 @@ Global {55DB4B6F-12E5-4A27-97F4-E97E135470FF} = {DA69F624-5398-4884-87E4-B816698CDE65} {D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981} = {3A76C5A2-79ED-49BC-8BDC-6A3A766FFA1B} {B5286020-C218-443C-91A9-B65751FB9B29} = {8A4582C8-DC59-4B61-BCE7-119FBAA99EFB} + {896FA5EE-63A5-4EAC-9F09-346584BB4830} = {DA69F624-5398-4884-87E4-B816698CDE65} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7945A4E4-ACDB-4F6E-95CA-6AC6E7C2CD59} diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs index b193331e28..5a17d67ca7 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs @@ -23,8 +23,8 @@ namespace Microsoft.AspNetCore.SignalR.Client { Services = new ServiceCollection(); Services.AddSingleton(NullLoggerFactory.Instance); - Services.AddSingleton(); Services.AddSingleton(); + this.AddJsonProtocol(); } public HubConnection Build() diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj b/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj index e709124f48..8cd58928fc 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextReader.cs b/src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextReader.cs similarity index 95% rename from src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextReader.cs rename to src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextReader.cs index 1dba50f2c6..6d73f4ccd5 100644 --- a/src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextReader.cs +++ b/src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextReader.cs @@ -7,9 +7,9 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; -namespace Microsoft.AspNetCore.SignalR.Internal.Protocol +namespace Microsoft.AspNetCore.SignalR.Internal { - internal class Utf8BufferTextReader : TextReader + public class Utf8BufferTextReader : TextReader { private readonly Decoder _decoder; private ReadOnlySequence _utf8Buffer; diff --git a/src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextWriter.cs b/src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextWriter.cs similarity index 98% rename from src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextWriter.cs rename to src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextWriter.cs index 98901d73fe..286aac91ce 100644 --- a/src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/Utf8BufferTextWriter.cs +++ b/src/Microsoft.AspNetCore.SignalR.Common/Internal/Utf8BufferTextWriter.cs @@ -9,9 +9,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -namespace Microsoft.AspNetCore.SignalR.Internal.Protocol +namespace Microsoft.AspNetCore.SignalR.Internal { - internal sealed class Utf8BufferTextWriter : TextWriter + public sealed class Utf8BufferTextWriter : TextWriter { private static readonly UTF8Encoding _utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); diff --git a/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj b/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj index a4e3752857..d63b5aed42 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj +++ b/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj @@ -8,6 +8,7 @@ + @@ -17,7 +18,6 @@ - diff --git a/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs index e369c0c1ca..b81859c791 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs @@ -19,10 +19,11 @@ namespace Microsoft.Extensions.DependencyInjection services.AddSingleton(typeof(IUserIdProvider), typeof(DefaultUserIdProvider)); services.AddSingleton(typeof(HubDispatcher<>), typeof(DefaultHubDispatcher<>)); services.AddScoped(typeof(IHubActivator<>), typeof(DefaultHubActivator<>)); - services.AddAuthorization(); - return new SignalRServerBuilder(services); + var builder = new SignalRServerBuilder(services); + builder.AddJsonProtocol(); + return builder; } } } diff --git a/src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/JsonHubProtocol.cs b/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Internal/Protocol/JsonHubProtocol.cs similarity index 100% rename from src/Microsoft.AspNetCore.SignalR.Common/Internal/Protocol/JsonHubProtocol.cs rename to src/Microsoft.AspNetCore.SignalR.Protocols.Json/Internal/Protocol/JsonHubProtocol.cs diff --git a/src/Microsoft.AspNetCore.SignalR.Common/JsonHubProtocolOptions.cs b/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs similarity index 100% rename from src/Microsoft.AspNetCore.SignalR.Common/JsonHubProtocolOptions.cs rename to src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs diff --git a/src/Microsoft.AspNetCore.SignalR.Core/JsonProtocolDependencyInjectionExtensions.cs b/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs similarity index 100% rename from src/Microsoft.AspNetCore.SignalR.Core/JsonProtocolDependencyInjectionExtensions.cs rename to src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs diff --git a/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj b/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj new file mode 100644 index 0000000000..c8f53c26e6 --- /dev/null +++ b/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj @@ -0,0 +1,21 @@ + + + + Implements the SignalR Hub Protocol over JSON. + netstandard2.0 + Microsoft.AspNetCore.SignalR + + + + + + + + + + + + + + + diff --git a/src/Microsoft.AspNetCore.SignalR.Protocols.MsgPack/Microsoft.AspNetCore.SignalR.Protocols.MsgPack.csproj b/src/Microsoft.AspNetCore.SignalR.Protocols.MsgPack/Microsoft.AspNetCore.SignalR.Protocols.MsgPack.csproj index 0b1e4602d9..767a1169c9 100644 --- a/src/Microsoft.AspNetCore.SignalR.Protocols.MsgPack/Microsoft.AspNetCore.SignalR.Protocols.MsgPack.csproj +++ b/src/Microsoft.AspNetCore.SignalR.Protocols.MsgPack/Microsoft.AspNetCore.SignalR.Protocols.MsgPack.csproj @@ -1,11 +1,7 @@ - - Implements the SignalR Hub Protocol over MsgPack. This package provides internal infrastructure. - To use MsgPack, use the Microsoft.AspNetCore.SignalR.Client.MsgPack (for the Client) or - Microsoft.AspNetCore.SignalR.MsgPack (for the Server) packages. - + Implements the SignalR Hub Protocol over MsgPack. netstandard2.0 Microsoft.AspNetCore.SignalR true diff --git a/src/Microsoft.AspNetCore.SignalR/SignalRDependencyInjectionExtensions.cs b/src/Microsoft.AspNetCore.SignalR/SignalRDependencyInjectionExtensions.cs index 931bd9a20a..5864111ab2 100644 --- a/src/Microsoft.AspNetCore.SignalR/SignalRDependencyInjectionExtensions.cs +++ b/src/Microsoft.AspNetCore.SignalR/SignalRDependencyInjectionExtensions.cs @@ -14,8 +14,7 @@ namespace Microsoft.Extensions.DependencyInjection services.AddConnections(); services.AddSingleton(); services.AddSingleton, HubOptionsSetup>(); - return services.AddSignalRCore() - .AddJsonProtocol(); + return services.AddSignalRCore(); } public static ISignalRServerBuilder AddSignalR(this IServiceCollection services, Action options) diff --git a/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextReaderTests.cs b/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextReaderTests.cs index be5c6c2cac..763c3e2a52 100644 --- a/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextReaderTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextReaderTests.cs @@ -5,7 +5,7 @@ using System; using System.Buffers; using System.IO; using System.Text; -using Microsoft.AspNetCore.SignalR.Internal.Protocol; +using Microsoft.AspNetCore.SignalR.Internal; using Xunit; namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol diff --git a/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextWriterTests.cs b/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextWriterTests.cs index b225704d31..5765b4bdd2 100644 --- a/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextWriterTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/Utf8BufferTextWriterTests.cs @@ -5,7 +5,7 @@ using System; using System.Buffers; using System.Collections.Generic; using System.Text; -using Microsoft.AspNetCore.SignalR.Internal.Protocol; +using Microsoft.AspNetCore.SignalR.Internal; using Xunit; namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol