From 80ae51ead89101abc7487de7322932ca5e177201 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Mon, 3 Dec 2018 08:59:44 -0800 Subject: [PATCH] Rename Json protocol to NewtonsoftJson (#4319) --- build/SharedFrameworkOnly.props | 2 +- build/artifacts.props | 2 +- src/Framework/Microsoft.AspNetCore.App.props | 2 +- src/SignalR/SignalR.sln | 6 ++--- .../BroadcastBenchmark.cs | 2 +- .../DefaultHubLifetimeManagerBenchmark.cs | 2 +- .../HubConnectionContextBenchmark.cs | 2 +- .../HubConnectionReceiveBenchmark.cs | 4 ++-- .../HubProtocolBenchmark.cs | 2 +- .../RedisHubLifetimeManagerBenchmark.cs | 2 +- .../ServerSentEventsBenchmark.cs | 4 ++-- src/SignalR/build.cmd | 3 +++ src/SignalR/build.sh | 7 ++++++ .../clients/ts/FunctionalTests/Startup.cs | 2 +- .../HubConnectionBuilder.cs | 2 +- ...soft.AspNetCore.SignalR.Client.Core.csproj | 2 +- .../Microsoft.AspNetCore.SignalR.Core.csproj | 2 +- .../SignalRDependencyInjectionExtensions.cs | 2 +- ...e.SignalR.Protocols.NewtonsoftJson.csproj} | 2 +- .../NewtonsoftJsonHubProtocolOptions.cs} | 6 ++--- ...nProtocolDependencyInjectionExtensions.cs} | 13 +++++------ .../Protocol/NewtonsoftJsonHubProtocol.cs} | 12 +++++----- .../baseline.netcore.json | 16 +++++++------- .../HubConnectionTests.cs | 2 +- .../VersionJsonHubProtocol.cs | 8 +++---- .../HubConnectionBuilderExtensionsTests.cs | 6 ++--- .../HubConnectionBuilderTests.cs | 10 ++++----- .../Internal/Protocol/JsonHubProtocolTests.cs | 22 +++++++++---------- .../RedisHubLifetimeManagerTests.cs | 8 +++---- .../HubConnectionContextUtils.cs | 2 +- .../HubProtocolHelpers.cs | 10 ++++----- .../TestClient.cs | 2 +- .../HubConnectionHandlerTests.cs | 22 +++++++++---------- .../DefaultHubProtocolResolverTests.cs | 4 ++-- 34 files changed, 101 insertions(+), 94 deletions(-) create mode 100644 src/SignalR/build.cmd create mode 100755 src/SignalR/build.sh rename src/SignalR/src/{Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj => Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj} (91%) rename src/SignalR/src/{Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs => Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonHubProtocolOptions.cs} (71%) rename src/SignalR/src/{Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs => Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonProtocolDependencyInjectionExtensions.cs} (72%) rename src/SignalR/src/{Microsoft.AspNetCore.SignalR.Protocols.Json/Protocol/JsonHubProtocol.cs => Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Protocol/NewtonsoftJsonHubProtocol.cs} (98%) rename src/SignalR/src/{Microsoft.AspNetCore.SignalR.Protocols.Json => Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson}/baseline.netcore.json (91%) diff --git a/build/SharedFrameworkOnly.props b/build/SharedFrameworkOnly.props index bd1b008c07..42c6f11893 100644 --- a/build/SharedFrameworkOnly.props +++ b/build/SharedFrameworkOnly.props @@ -17,7 +17,7 @@ - + diff --git a/build/artifacts.props b/build/artifacts.props index f55ada5dd8..dab708f823 100644 --- a/build/artifacts.props +++ b/build/artifacts.props @@ -62,7 +62,7 @@ - + diff --git a/src/Framework/Microsoft.AspNetCore.App.props b/src/Framework/Microsoft.AspNetCore.App.props index a5cf6c21c0..cbbded6f00 100644 --- a/src/Framework/Microsoft.AspNetCore.App.props +++ b/src/Framework/Microsoft.AspNetCore.App.props @@ -82,7 +82,7 @@ - + diff --git a/src/SignalR/SignalR.sln b/src/SignalR/SignalR.sln index 6f8900fb5f..98a518913d 100644 --- a/src/SignalR/SignalR.sln +++ b/src/SignalR/SignalR.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27110.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28315.86 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}" ProjectSection(SolutionItems) = preProject @@ -77,7 +77,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "clients\ts\FunctionalTests\FunctionalTests.csproj", "{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Protocols.Json", "src\Microsoft.AspNetCore.SignalR.Protocols.Json\Microsoft.AspNetCore.SignalR.Protocols.Json.csproj", "{896FA5EE-63A5-4EAC-9F09-346584BB4830}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson", "src\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj", "{896FA5EE-63A5-4EAC-9F09-346584BB4830}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkServer", "benchmarkapps\BenchmarkServer\BenchmarkServer.csproj", "{8C75AC94-C980-4FE1-9F79-6CED3C8665CE}" EndProject diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs index 8028bbb06c..c074c1c21d 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/BroadcastBenchmark.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks if (Protocol == "json") { - protocol = new JsonHubProtocol(); + protocol = new NewtonsoftJsonHubProtocol(); } else { diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/DefaultHubLifetimeManagerBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/DefaultHubLifetimeManagerBenchmark.cs index d2d0a438be..d54311a713 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/DefaultHubLifetimeManagerBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/DefaultHubLifetimeManagerBenchmark.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks _groupNames = new List(); _userIdentifiers = new List(); - var jsonHubProtocol = new JsonHubProtocol(); + var jsonHubProtocol = new NewtonsoftJsonHubProtocol(); for (int i = 0; i < 100; i++) { diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionContextBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionContextBenchmark.cs index d4182297cf..891a73b49e 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionContextBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionContextBenchmark.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks var connection = new DefaultConnectionContext(Guid.NewGuid().ToString(), _pipe, _pipe); _hubConnectionContext = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance); - _successHubProtocolResolver = new TestHubProtocolResolver(new JsonHubProtocol()); + _successHubProtocolResolver = new TestHubProtocolResolver(new NewtonsoftJsonHubProtocol()); _failureHubProtocolResolver = new TestHubProtocolResolver(null); _userIdProvider = new TestUserIdProvider(); _supportedProtocols = new List { "json" }; diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionReceiveBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionReceiveBenchmark.cs index 1ab018b1a2..4821e95eeb 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionReceiveBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubConnectionReceiveBenchmark.cs @@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks var hubConnectionBuilder = new HubConnectionBuilder(); if (Protocol == "json") { - hubProtocol = new JsonHubProtocol(); + hubProtocol = new NewtonsoftJsonHubProtocol(); } else { @@ -167,4 +167,4 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks await _waitTcs.Task.OrTimeout(); } } -} \ No newline at end of file +} diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubProtocolBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubProtocolBenchmark.cs index 5c089c0f7a..17b3ccda42 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubProtocolBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/HubProtocolBenchmark.cs @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks _hubProtocol = new MessagePackHubProtocol(); break; case Protocol.Json: - _hubProtocol = new JsonHubProtocol(); + _hubProtocol = new NewtonsoftJsonHubProtocol(); break; } diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/RedisHubLifetimeManagerBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/RedisHubLifetimeManagerBenchmark.cs index 606c53673c..486ef8fa49 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/RedisHubLifetimeManagerBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/RedisHubLifetimeManagerBenchmark.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks for (var i = 0; i < protocolCount; i++) { yield return ((i % 2) == 0) - ? new WrappedHubProtocol($"json_{i}", new JsonHubProtocol()) + ? new WrappedHubProtocol($"json_{i}", new NewtonsoftJsonHubProtocol()) : new WrappedHubProtocol($"messagepack_{i}", new MessagePackHubProtocol()); } } diff --git a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/ServerSentEventsBenchmark.cs b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/ServerSentEventsBenchmark.cs index 33b9055428..8b6e61acb5 100644 --- a/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/ServerSentEventsBenchmark.cs +++ b/src/SignalR/benchmarks/Microsoft.AspNetCore.SignalR.Microbenchmarks/ServerSentEventsBenchmark.cs @@ -29,12 +29,12 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks if (Protocol == "json") { - protocol = new JsonHubProtocol(); + protocol = new NewtonsoftJsonHubProtocol(); } else { // New line in result to trigger SSE formatting - protocol = new JsonHubProtocol + protocol = new NewtonsoftJsonHubProtocol { PayloadSerializer = { Formatting = Formatting.Indented } }; diff --git a/src/SignalR/build.cmd b/src/SignalR/build.cmd new file mode 100644 index 0000000000..f4169ea5e4 --- /dev/null +++ b/src/SignalR/build.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +SET RepoRoot="%~dp0..\.." +%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %* diff --git a/src/SignalR/build.sh b/src/SignalR/build.sh new file mode 100755 index 0000000000..d5bb0cf631 --- /dev/null +++ b/src/SignalR/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +repo_root="$DIR/../.." +"$repo_root/build.sh" --path "$DIR" --lockfile "$repo_root/korebuild-lock.txt" "$@" diff --git a/src/SignalR/clients/ts/FunctionalTests/Startup.cs b/src/SignalR/clients/ts/FunctionalTests/Startup.cs index 5417be9d64..a2a5cd4399 100644 --- a/src/SignalR/clients/ts/FunctionalTests/Startup.cs +++ b/src/SignalR/clients/ts/FunctionalTests/Startup.cs @@ -34,7 +34,7 @@ namespace FunctionalTests { options.EnableDetailedErrors = true; }) - .AddJsonProtocol(options => + .AddNewtonsoftJsonProtocol(options => { // we are running the same tests with JSON and MsgPack protocols and having // consistent casing makes it cleaner to verify results diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs index bb7f9071f6..e52f18aa30 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnectionBuilder.cs @@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.SignalR.Client Services = new ServiceCollection(); Services.AddSingleton(); Services.AddLogging(); - this.AddJsonProtocol(); + this.AddNewtonsoftJsonProtocol(); } /// diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj index bc9ad15161..2557d6e233 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Client.Core/Microsoft.AspNetCore.SignalR.Client.Core.csproj @@ -16,7 +16,7 @@ - + diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj index 98856f40d9..7c5bd397b2 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/Microsoft.AspNetCore.SignalR.Core.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs index efdeda8d18..d55aaa9a56 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Core/SignalRDependencyInjectionExtensions.cs @@ -32,7 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection services.AddAuthorization(); var builder = new SignalRServerBuilder(services); - builder.AddJsonProtocol(); + builder.AddNewtonsoftJsonProtocol(); return builder; } } diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj similarity index 91% rename from src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj rename to src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj index 7daf883097..ada3fdadb3 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj @@ -1,7 +1,7 @@  - Implements the SignalR Hub Protocol over JSON. + Implements the SignalR Hub Protocol using Newtonsoft.Json. netstandard2.0 Microsoft.AspNetCore.SignalR true diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonHubProtocolOptions.cs similarity index 71% rename from src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs rename to src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonHubProtocolOptions.cs index cd978a52eb..7fe77e17c7 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonHubProtocolOptions.cs +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonHubProtocolOptions.cs @@ -7,13 +7,13 @@ using Newtonsoft.Json; namespace Microsoft.AspNetCore.SignalR { /// - /// Options used to configure a instance. + /// Options used to configure a instance. /// - public class JsonHubProtocolOptions + public class NewtonsoftJsonHubProtocolOptions { /// /// Gets or sets the settings used to serialize invocation arguments and return values. /// - public JsonSerializerSettings PayloadSerializerSettings { get; set; } = JsonHubProtocol.CreateDefaultSerializerSettings(); + public JsonSerializerSettings PayloadSerializerSettings { get; set; } = NewtonsoftJsonHubProtocol.CreateDefaultSerializerSettings(); } } diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonProtocolDependencyInjectionExtensions.cs similarity index 72% rename from src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs rename to src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonProtocolDependencyInjectionExtensions.cs index 8b4c40f33a..d3dd196eb1 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/JsonProtocolDependencyInjectionExtensions.cs +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/NewtonsoftJsonProtocolDependencyInjectionExtensions.cs @@ -1,7 +1,6 @@ using System; using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR.Protocol; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection @@ -9,7 +8,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// Extension methods for . /// - public static class JsonProtocolDependencyInjectionExtensions + public static class NewtonsoftJsonProtocolDependencyInjectionExtensions { /// /// Enables the JSON protocol for SignalR. @@ -19,8 +18,8 @@ namespace Microsoft.Extensions.DependencyInjection /// /// The representing the SignalR server to add JSON protocol support to. /// The value of - public static TBuilder AddJsonProtocol(this TBuilder builder) where TBuilder : ISignalRBuilder - => AddJsonProtocol(builder, _ => { }); + public static TBuilder AddNewtonsoftJsonProtocol(this TBuilder builder) where TBuilder : ISignalRBuilder + => AddNewtonsoftJsonProtocol(builder, _ => { }); /// /// Enables the JSON protocol for SignalR and allows options for the JSON protocol to be configured. @@ -29,11 +28,11 @@ namespace Microsoft.Extensions.DependencyInjection /// Any options configured here will be applied, even if the JSON protocol has already been registered with the server. /// /// The representing the SignalR server to add JSON protocol support to. - /// A delegate that can be used to configure the + /// A delegate that can be used to configure the /// The value of - public static TBuilder AddJsonProtocol(this TBuilder builder, Action configure) where TBuilder : ISignalRBuilder + public static TBuilder AddNewtonsoftJsonProtocol(this TBuilder builder, Action configure) where TBuilder : ISignalRBuilder { - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); + builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); builder.Services.Configure(configure); return builder; } diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Protocol/JsonHubProtocol.cs b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Protocol/NewtonsoftJsonHubProtocol.cs similarity index 98% rename from src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Protocol/JsonHubProtocol.cs rename to src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Protocol/NewtonsoftJsonHubProtocol.cs index 8436d0aa68..22bca86813 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/Protocol/JsonHubProtocol.cs +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/Protocol/NewtonsoftJsonHubProtocol.cs @@ -17,9 +17,9 @@ using Newtonsoft.Json.Serialization; namespace Microsoft.AspNetCore.SignalR.Protocol { /// - /// Implements the SignalR Hub Protocol using JSON. + /// Implements the SignalR Hub Protocol using Newtonsoft.Json. /// - public class JsonHubProtocol : IHubProtocol + public class NewtonsoftJsonHubProtocol : IHubProtocol { private const string ResultPropertyName = "result"; private const string ItemPropertyName = "item"; @@ -41,17 +41,17 @@ namespace Microsoft.AspNetCore.SignalR.Protocol public JsonSerializer PayloadSerializer { get; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public JsonHubProtocol() : this(Options.Create(new JsonHubProtocolOptions())) + public NewtonsoftJsonHubProtocol() : this(Options.Create(new NewtonsoftJsonHubProtocolOptions())) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The options used to initialize the protocol. - public JsonHubProtocol(IOptions options) + public NewtonsoftJsonHubProtocol(IOptions options) { PayloadSerializer = JsonSerializer.Create(options.Value.PayloadSerializerSettings); } diff --git a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/baseline.netcore.json b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/baseline.netcore.json similarity index 91% rename from src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/baseline.netcore.json rename to src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/baseline.netcore.json index 8ad9c14400..8f3594eef6 100644 --- a/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.Json/baseline.netcore.json +++ b/src/SignalR/src/Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson/baseline.netcore.json @@ -1,8 +1,8 @@ { - "AssemblyIdentity": "Microsoft.AspNetCore.SignalR.Protocols.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", + "AssemblyIdentity": "Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60", "Types": [ { - "Name": "Microsoft.Extensions.DependencyInjection.JsonProtocolDependencyInjectionExtensions", + "Name": "Microsoft.Extensions.DependencyInjection.NewtonsoftJsonProtocolDependencyInjectionExtensions", "Visibility": "Public", "Kind": "Class", "Abstract": true, @@ -12,7 +12,7 @@ "Members": [ { "Kind": "Method", - "Name": "AddJsonProtocol", + "Name": "AddNewtonsoftJsonProtocol", "Parameters": [ { "Name": "builder", @@ -35,7 +35,7 @@ }, { "Kind": "Method", - "Name": "AddJsonProtocol", + "Name": "AddNewtonsoftJsonProtocol", "Parameters": [ { "Name": "builder", @@ -43,7 +43,7 @@ }, { "Name": "configure", - "Type": "System.Action" + "Type": "System.Action" } ], "ReturnType": "T0", @@ -64,7 +64,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions", + "Name": "Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [], @@ -101,7 +101,7 @@ "GenericParameters": [] }, { - "Name": "Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol", + "Name": "Microsoft.AspNetCore.SignalR.Protocol.NewtonsoftJsonHubProtocol", "Visibility": "Public", "Kind": "Class", "ImplementedInterfaces": [ @@ -240,7 +240,7 @@ "Parameters": [ { "Name": "options", - "Type": "Microsoft.Extensions.Options.IOptions" + "Type": "Microsoft.Extensions.Options.IOptions" } ], "Visibility": "Public", diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index f0a7309a9a..656496e1d1 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -1116,7 +1116,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests public static Dictionary HubProtocols => new Dictionary { - { "json", new JsonHubProtocol() }, + { "json", new NewtonsoftJsonHubProtocol() }, { "messagepack", new MessagePackHubProtocol() }, }; diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/VersionJsonHubProtocol.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/VersionJsonHubProtocol.cs index 8c0e761386..e3a91e6d2e 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/VersionJsonHubProtocol.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/VersionJsonHubProtocol.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -14,12 +14,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests public class VersionedJsonHubProtocol : IHubProtocol { private readonly int _version; - private readonly JsonHubProtocol _innerProtocol; + private readonly NewtonsoftJsonHubProtocol _innerProtocol; public VersionedJsonHubProtocol(int version) { _version = version; - _innerProtocol = new JsonHubProtocol(); + _innerProtocol = new NewtonsoftJsonHubProtocol(); } public string Name => _innerProtocol.Name; @@ -84,4 +84,4 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests return version <= _version; } } -} \ No newline at end of file +} diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderExtensionsTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderExtensionsTests.cs index 59515d0338..1a5bcb5fd9 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderExtensionsTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderExtensionsTests.cs @@ -101,13 +101,13 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests public void AddJsonProtocolAddsProtocol() { var connectionBuilder = new HubConnectionBuilder(); - connectionBuilder.AddJsonProtocol(); + connectionBuilder.AddNewtonsoftJsonProtocol(); var serviceProvider = connectionBuilder.Services.BuildServiceProvider(); var resolvedHubProtocol = serviceProvider.GetService(); - Assert.IsType(resolvedHubProtocol); + Assert.IsType(resolvedHubProtocol); } [Fact] @@ -123,4 +123,4 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests Assert.IsType(resolvedHubProtocol); } } -} \ No newline at end of file +} diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderTests.cs index 48b0a50968..601634a252 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionBuilderTests.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Http.Connections.Client; using Microsoft.AspNetCore.SignalR.Protocol; using Microsoft.Extensions.DependencyInjection; @@ -27,16 +25,16 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests [Fact] public void AddJsonProtocolSetsHubProtocolToJsonWithDefaultOptions() { - var serviceProvider = new HubConnectionBuilder().AddJsonProtocol().Services.BuildServiceProvider(); + var serviceProvider = new HubConnectionBuilder().AddNewtonsoftJsonProtocol().Services.BuildServiceProvider(); - var actualProtocol = Assert.IsType(serviceProvider.GetService()); + var actualProtocol = Assert.IsType(serviceProvider.GetService()); Assert.IsType(actualProtocol.PayloadSerializer.ContractResolver); } [Fact] public void AddJsonProtocolSetsHubProtocolToJsonWithProvidedOptions() { - var serviceProvider = new HubConnectionBuilder().AddJsonProtocol(options => + var serviceProvider = new HubConnectionBuilder().AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings = new JsonSerializerSettings { @@ -44,7 +42,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests }; }).Services.BuildServiceProvider(); - var actualProtocol = Assert.IsType(serviceProvider.GetService()); + var actualProtocol = Assert.IsType(serviceProvider.GetService()); Assert.Equal("JUST A TEST", actualProtocol.PayloadSerializer.DateFormatString); } diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/JsonHubProtocolTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/JsonHubProtocolTests.cs index 7bd1946100..1da37780ea 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/JsonHubProtocolTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Common.Tests/Internal/Protocol/JsonHubProtocolTests.cs @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol var expectedOutput = Frame(testData.Json); - var protocolOptions = new JsonHubProtocolOptions + var protocolOptions = new NewtonsoftJsonHubProtocolOptions { PayloadSerializerSettings = new JsonSerializerSettings() { @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol } }; - var protocol = new JsonHubProtocol(Options.Create(protocolOptions)); + var protocol = new NewtonsoftJsonHubProtocol(Options.Create(protocolOptions)); var writer = MemoryBufferWriter.Get(); try @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol var input = Frame(testData.Json); - var protocolOptions = new JsonHubProtocolOptions + var protocolOptions = new NewtonsoftJsonHubProtocolOptions { PayloadSerializerSettings = new JsonSerializerSettings { @@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol }; var binder = new TestBinder(testData.Message); - var protocol = new JsonHubProtocol(Options.Create(protocolOptions)); + var protocol = new NewtonsoftJsonHubProtocol(Options.Create(protocolOptions)); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(input)); protocol.TryParseMessage(ref data, binder, out var message); @@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol input = Frame(input); var binder = new TestBinder(Array.Empty(), typeof(object)); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(input)); var ex = Assert.Throws(() => protocol.TryParseMessage(ref data, binder, out var _)); Assert.Equal(expectedMessage, ex.Message); @@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol var input = Frame(testData.Json); var binder = new TestBinder(testData.Message); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(input)); protocol.TryParseMessage(ref data, binder, out var message); @@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol input = Frame(input); var binder = new TestBinder(paramTypes: new[] { typeof(int), typeof(string) }, returnType: typeof(bool)); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(input)); Assert.True(protocol.TryParseMessage(ref data, binder, out var message)); Assert.NotNull(message); @@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol input = Frame(input); var binder = new TestBinder(paramTypes: new[] { typeof(int), typeof(string) }, returnType: typeof(bool)); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(input)); protocol.TryParseMessage(ref data, binder, out var message); var bindingFailure = Assert.IsType(message); @@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol public void DateTimeArgumentPreservesUtcKind(string input) { var binder = new TestBinder(new[] { typeof(DateTime) }); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(Frame(input))); protocol.TryParseMessage(ref data, binder, out var message); var invocationMessage = Assert.IsType(message); @@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol public void DateTimeReturnValuePreservesUtcKind(string input) { var binder = new TestBinder(typeof(DateTime)); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(Frame(input))); protocol.TryParseMessage(ref data, binder, out var message); var invocationMessage = Assert.IsType(message); @@ -304,7 +304,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol public void ReadToEndOfArgumentArrayOnError() { var binder = new TestBinder(new[] { typeof(string) }); - var protocol = new JsonHubProtocol(); + var protocol = new NewtonsoftJsonHubProtocol(); var data = new ReadOnlySequence(Encoding.UTF8.GetBytes(Frame("{'type':1,'invocationId':'42','target':'foo','arguments':[[],{'target':'foo2'}]}"))); protocol.TryParseMessage(ref data, binder, out var message); var bindingFailure = Assert.IsType(message); diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests/RedisHubLifetimeManagerTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests/RedisHubLifetimeManagerTests.cs index c9137975b5..c2c4a3f5f7 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests/RedisHubLifetimeManagerTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests/RedisHubLifetimeManagerTests.cs @@ -22,17 +22,17 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests public string TestProperty { get; set; } } - private RedisHubLifetimeManager CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, JsonHubProtocolOptions jsonOptions = null) + private RedisHubLifetimeManager CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, NewtonsoftJsonHubProtocolOptions jsonOptions = null) { var options = new RedisOptions() { ConnectionFactory = async (t) => await Task.FromResult(new TestConnectionMultiplexer(server)) }; messagePackOptions = messagePackOptions ?? new MessagePackHubProtocolOptions(); - jsonOptions = jsonOptions ?? new JsonHubProtocolOptions(); + jsonOptions = jsonOptions ?? new NewtonsoftJsonHubProtocolOptions(); return new RedisHubLifetimeManager( NullLogger>.Instance, Options.Create(options), new DefaultHubProtocolResolver(new IHubProtocol[] { - new JsonHubProtocol(Options.Create(jsonOptions)), + new NewtonsoftJsonHubProtocol(Options.Create(jsonOptions)), new MessagePackHubProtocol(Options.Create(messagePackOptions)), }, NullLogger.Instance)); } @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests var messagePackOptions = new MessagePackHubProtocolOptions(); - var jsonOptions = new JsonHubProtocolOptions(); + var jsonOptions = new NewtonsoftJsonHubProtocolOptions(); jsonOptions.PayloadSerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); using (var client1 = new TestClient()) diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs index bbbfb1db96..b1fdfa91d7 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubConnectionContextUtils.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests { return new HubConnectionContext(connection, TimeSpan.FromSeconds(15), NullLoggerFactory.Instance) { - Protocol = protocol ?? new JsonHubProtocol(), + Protocol = protocol ?? new NewtonsoftJsonHubProtocol(), UserIdentifier = userIdentifier, }; } diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubProtocolHelpers.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubProtocolHelpers.cs index 53ee3f5572..087f308e34 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubProtocolHelpers.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/HubProtocolHelpers.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -11,19 +11,19 @@ namespace Microsoft.AspNetCore.SignalR.Tests { public static class HubProtocolHelpers { - private static readonly IHubProtocol JsonHubProtocol = new JsonHubProtocol(); + private static readonly IHubProtocol NewtonsoftJsonHubProtocol = new NewtonsoftJsonHubProtocol(); private static readonly IHubProtocol MessagePackHubProtocol = new MessagePackHubProtocol(); public static readonly List AllProtocolNames = new List { - JsonHubProtocol.Name, + NewtonsoftJsonHubProtocol.Name, MessagePackHubProtocol.Name }; public static readonly IList AllProtocols = new List() { - JsonHubProtocol, + NewtonsoftJsonHubProtocol, MessagePackHubProtocol }; @@ -38,4 +38,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests return protocol; } } -} \ No newline at end of file +} diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/TestClient.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/TestClient.cs index 947a323b55..5ac4eab33c 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/TestClient.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests.Utils/TestClient.cs @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests Connection.User = new ClaimsPrincipal(new ClaimsIdentity(claims)); Connection.Items["ConnectedTask"] = new TaskCompletionSource(); - _protocol = protocol ?? new JsonHubProtocol(); + _protocol = protocol ?? new NewtonsoftJsonHubProtocol(); _invocationBinder = invocationBinder ?? new DefaultInvocationBinder(); _cts = new CancellationTokenSource(); diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTests.cs index 1147b2e4e4..687c0b5ee7 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTests.cs @@ -1842,7 +1842,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client1 = new TestClient(protocol: new JsonHubProtocol())) + using (var client1 = new TestClient(protocol: new NewtonsoftJsonHubProtocol())) using (var client2 = new TestClient(protocol: new MessagePackHubProtocol())) { var firstConnectionHandlerTask = await client1.ConnectAsync(connectionHandler); @@ -1973,7 +1973,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests { services .AddSignalR() - .AddJsonProtocol(o => + .AddNewtonsoftJsonProtocol(o => { o.PayloadSerializerSettings = new JsonSerializerSettings { @@ -2237,7 +2237,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); await client.Connected.OrTimeout(); @@ -2266,7 +2266,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); @@ -2310,7 +2310,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); await client.Connected.OrTimeout(); @@ -2371,7 +2371,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); await client.Connected.OrTimeout(); @@ -2397,7 +2397,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); await client.Connected.OrTimeout(); @@ -2424,7 +2424,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(300)), LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); await client.Connected.OrTimeout(); @@ -2450,7 +2450,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); @@ -2493,7 +2493,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests }, LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler); @@ -2522,7 +2522,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var connectionHandler = serviceProvider.GetService>(); - using (var client = new TestClient(new JsonHubProtocol())) + using (var client = new TestClient(new NewtonsoftJsonHubProtocol())) { var connectionHandlerTask = await client.ConnectAsync(connectionHandler).OrTimeout(); diff --git a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/Internal/DefaultHubProtocolResolverTests.cs b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/Internal/DefaultHubProtocolResolverTests.cs index cce80cde51..fb9fc56477 100644 --- a/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/Internal/DefaultHubProtocolResolverTests.cs +++ b/src/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/Internal/DefaultHubProtocolResolverTests.cs @@ -73,8 +73,8 @@ namespace Microsoft.AspNetCore.SignalR.Common.Protocol.Tests public void RegisteringMultipleHubProtocolsFails() { var exception = Assert.Throws(() => new DefaultHubProtocolResolver(new[] { - new JsonHubProtocol(), - new JsonHubProtocol() + new NewtonsoftJsonHubProtocol(), + new NewtonsoftJsonHubProtocol() }, NullLogger.Instance)); Assert.Equal($"Multiple Hub Protocols with the name 'json' were registered.", exception.Message);