Rename Json protocol to NewtonsoftJson (#4319)

This commit is contained in:
BrennanConroy 2018-12-03 08:59:44 -08:00 committed by GitHub
parent d10205f309
commit 80ae51ead8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 101 additions and 94 deletions

View File

@ -17,7 +17,7 @@
<!-- Assemblies required by the SignalR client. --> <!-- Assemblies required by the SignalR client. -->
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.Http.Features" /> <SharedFrameworkAndPackage Include="Microsoft.AspNetCore.Http.Features" />
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Common" /> <SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Common" />
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Protocols.Json" /> <SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" />
<!-- Assemblies produced by this repo that will move to aspnet/Extensions after repo refactoring is done --> <!-- Assemblies produced by this repo that will move to aspnet/Extensions after repo refactoring is done -->
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Identity.Core" /> <SharedFrameworkAndPackage Include="Microsoft.Extensions.Identity.Core" />

View File

@ -62,7 +62,7 @@
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Client.Core" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Client.Core" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Client" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Client" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Common" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Common" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Category="ship" />
<PackageArtifact Include="Microsoft.AspNetCore.SignalR.Specification.Tests" Category="ship" /> <PackageArtifact Include="Microsoft.AspNetCore.SignalR.Specification.Tests" Category="ship" />

View File

@ -82,7 +82,7 @@
<Dependency Include="Microsoft.AspNetCore.Session" Version="$(MicrosoftAspNetCoreSessionPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.Session" Version="$(MicrosoftAspNetCoreSessionPackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.SignalR.Common" Version="$(MicrosoftAspNetCoreSignalRCommonPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.SignalR.Common" Version="$(MicrosoftAspNetCoreSignalRCommonPackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.SignalR.Core" Version="$(MicrosoftAspNetCoreSignalRCorePackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.SignalR.Core" Version="$(MicrosoftAspNetCoreSignalRCorePackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.SignalR.Protocols.Json" Version="$(MicrosoftAspNetCoreSignalRProtocolsJsonPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="$(MicrosoftAspNetCoreSignalRProtocolsNewtonsoftJsonPackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.SignalR" Version="$(MicrosoftAspNetCoreSignalRPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.SignalR" Version="$(MicrosoftAspNetCoreSignalRPackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" />
<Dependency Include="Microsoft.AspNetCore.WebSockets" Version="$(MicrosoftAspNetCoreWebSocketsPackageVersion)" /> <Dependency Include="Microsoft.AspNetCore.WebSockets" Version="$(MicrosoftAspNetCoreWebSocketsPackageVersion)" />

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.27110.0 VisualStudioVersion = 16.0.28315.86
MinimumVisualStudioVersion = 15.0.26730.03 MinimumVisualStudioVersion = 15.0.26730.03
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DA69F624-5398-4884-87E4-B816698CDE65}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
@ -77,7 +77,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Signal
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "clients\ts\FunctionalTests\FunctionalTests.csproj", "{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "clients\ts\FunctionalTests\FunctionalTests.csproj", "{D0C7B22E-B0B6-4D62-BF7D-79EE4AAF1981}"
EndProject 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkServer", "benchmarkapps\BenchmarkServer\BenchmarkServer.csproj", "{8C75AC94-C980-4FE1-9F79-6CED3C8665CE}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkServer", "benchmarkapps\BenchmarkServer\BenchmarkServer.csproj", "{8C75AC94-C980-4FE1-9F79-6CED3C8665CE}"
EndProject EndProject

View File

@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
if (Protocol == "json") if (Protocol == "json")
{ {
protocol = new JsonHubProtocol(); protocol = new NewtonsoftJsonHubProtocol();
} }
else else
{ {

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
_groupNames = new List<string>(); _groupNames = new List<string>();
_userIdentifiers = new List<string>(); _userIdentifiers = new List<string>();
var jsonHubProtocol = new JsonHubProtocol(); var jsonHubProtocol = new NewtonsoftJsonHubProtocol();
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {

View File

@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
var connection = new DefaultConnectionContext(Guid.NewGuid().ToString(), _pipe, _pipe); var connection = new DefaultConnectionContext(Guid.NewGuid().ToString(), _pipe, _pipe);
_hubConnectionContext = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance); _hubConnectionContext = new HubConnectionContext(connection, Timeout.InfiniteTimeSpan, NullLoggerFactory.Instance);
_successHubProtocolResolver = new TestHubProtocolResolver(new JsonHubProtocol()); _successHubProtocolResolver = new TestHubProtocolResolver(new NewtonsoftJsonHubProtocol());
_failureHubProtocolResolver = new TestHubProtocolResolver(null); _failureHubProtocolResolver = new TestHubProtocolResolver(null);
_userIdProvider = new TestUserIdProvider(); _userIdProvider = new TestUserIdProvider();
_supportedProtocols = new List<string> { "json" }; _supportedProtocols = new List<string> { "json" };

View File

@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
var hubConnectionBuilder = new HubConnectionBuilder(); var hubConnectionBuilder = new HubConnectionBuilder();
if (Protocol == "json") if (Protocol == "json")
{ {
hubProtocol = new JsonHubProtocol(); hubProtocol = new NewtonsoftJsonHubProtocol();
} }
else else
{ {
@ -167,4 +167,4 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
await _waitTcs.Task.OrTimeout(); await _waitTcs.Task.OrTimeout();
} }
} }
} }

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
_hubProtocol = new MessagePackHubProtocol(); _hubProtocol = new MessagePackHubProtocol();
break; break;
case Protocol.Json: case Protocol.Json:
_hubProtocol = new JsonHubProtocol(); _hubProtocol = new NewtonsoftJsonHubProtocol();
break; break;
} }

View File

@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
for (var i = 0; i < protocolCount; i++) for (var i = 0; i < protocolCount; i++)
{ {
yield return ((i % 2) == 0) yield return ((i % 2) == 0)
? new WrappedHubProtocol($"json_{i}", new JsonHubProtocol()) ? new WrappedHubProtocol($"json_{i}", new NewtonsoftJsonHubProtocol())
: new WrappedHubProtocol($"messagepack_{i}", new MessagePackHubProtocol()); : new WrappedHubProtocol($"messagepack_{i}", new MessagePackHubProtocol());
} }
} }

View File

@ -29,12 +29,12 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
if (Protocol == "json") if (Protocol == "json")
{ {
protocol = new JsonHubProtocol(); protocol = new NewtonsoftJsonHubProtocol();
} }
else else
{ {
// New line in result to trigger SSE formatting // New line in result to trigger SSE formatting
protocol = new JsonHubProtocol protocol = new NewtonsoftJsonHubProtocol
{ {
PayloadSerializer = { Formatting = Formatting.Indented } PayloadSerializer = { Formatting = Formatting.Indented }
}; };

3
src/SignalR/build.cmd Normal file
View File

@ -0,0 +1,3 @@
@ECHO OFF
SET RepoRoot="%~dp0..\.."
%RepoRoot%\build.cmd -LockFile %RepoRoot%\korebuild-lock.txt -Path %~dp0 %*

7
src/SignalR/build.sh Executable file
View File

@ -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" "$@"

View File

@ -34,7 +34,7 @@ namespace FunctionalTests
{ {
options.EnableDetailedErrors = true; options.EnableDetailedErrors = true;
}) })
.AddJsonProtocol(options => .AddNewtonsoftJsonProtocol(options =>
{ {
// we are running the same tests with JSON and MsgPack protocols and having // we are running the same tests with JSON and MsgPack protocols and having
// consistent casing makes it cleaner to verify results // consistent casing makes it cleaner to verify results

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.SignalR.Client
Services = new ServiceCollection(); Services = new ServiceCollection();
Services.AddSingleton<HubConnection>(); Services.AddSingleton<HubConnection>();
Services.AddLogging(); Services.AddLogging();
this.AddJsonProtocol(); this.AddNewtonsoftJsonProtocol();
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -16,7 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Common\Microsoft.AspNetCore.SignalR.Common.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Common\Microsoft.AspNetCore.SignalR.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Protocols.Json\Microsoft.AspNetCore.SignalR.Protocols.Json.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -12,7 +12,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Common\Microsoft.AspNetCore.SignalR.Common.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Common\Microsoft.AspNetCore.SignalR.Common.csproj" />
<ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Protocols.Json\Microsoft.AspNetCore.SignalR.Protocols.Json.csproj" /> <ProjectReference Include="..\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -32,7 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddAuthorization(); services.AddAuthorization();
var builder = new SignalRServerBuilder(services); var builder = new SignalRServerBuilder(services);
builder.AddJsonProtocol(); builder.AddNewtonsoftJsonProtocol();
return builder; return builder;
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Description>Implements the SignalR Hub Protocol over JSON.</Description> <Description>Implements the SignalR Hub Protocol using Newtonsoft.Json.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace> <RootNamespace>Microsoft.AspNetCore.SignalR</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

View File

@ -7,13 +7,13 @@ using Newtonsoft.Json;
namespace Microsoft.AspNetCore.SignalR namespace Microsoft.AspNetCore.SignalR
{ {
/// <summary> /// <summary>
/// Options used to configure a <see cref="JsonHubProtocol"/> instance. /// Options used to configure a <see cref="NewtonsoftJsonHubProtocol"/> instance.
/// </summary> /// </summary>
public class JsonHubProtocolOptions public class NewtonsoftJsonHubProtocolOptions
{ {
/// <summary> /// <summary>
/// Gets or sets the settings used to serialize invocation arguments and return values. /// Gets or sets the settings used to serialize invocation arguments and return values.
/// </summary> /// </summary>
public JsonSerializerSettings PayloadSerializerSettings { get; set; } = JsonHubProtocol.CreateDefaultSerializerSettings(); public JsonSerializerSettings PayloadSerializerSettings { get; set; } = NewtonsoftJsonHubProtocol.CreateDefaultSerializerSettings();
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR.Protocol; using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection namespace Microsoft.Extensions.DependencyInjection
@ -9,7 +8,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <summary> /// <summary>
/// Extension methods for <see cref="ISignalRBuilder"/>. /// Extension methods for <see cref="ISignalRBuilder"/>.
/// </summary> /// </summary>
public static class JsonProtocolDependencyInjectionExtensions public static class NewtonsoftJsonProtocolDependencyInjectionExtensions
{ {
/// <summary> /// <summary>
/// Enables the JSON protocol for SignalR. /// Enables the JSON protocol for SignalR.
@ -19,8 +18,8 @@ namespace Microsoft.Extensions.DependencyInjection
/// </remarks> /// </remarks>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add JSON protocol support to.</param> /// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add JSON protocol support to.</param>
/// <returns>The value of <paramref name="builder"/></returns> /// <returns>The value of <paramref name="builder"/></returns>
public static TBuilder AddJsonProtocol<TBuilder>(this TBuilder builder) where TBuilder : ISignalRBuilder public static TBuilder AddNewtonsoftJsonProtocol<TBuilder>(this TBuilder builder) where TBuilder : ISignalRBuilder
=> AddJsonProtocol(builder, _ => { }); => AddNewtonsoftJsonProtocol(builder, _ => { });
/// <summary> /// <summary>
/// Enables the JSON protocol for SignalR and allows options for the JSON protocol to be configured. /// 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. /// Any options configured here will be applied, even if the JSON protocol has already been registered with the server.
/// </remarks> /// </remarks>
/// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add JSON protocol support to.</param> /// <param name="builder">The <see cref="ISignalRBuilder"/> representing the SignalR server to add JSON protocol support to.</param>
/// <param name="configure">A delegate that can be used to configure the <see cref="JsonHubProtocolOptions"/></param> /// <param name="configure">A delegate that can be used to configure the <see cref="NewtonsoftJsonHubProtocolOptions"/></param>
/// <returns>The value of <paramref name="builder"/></returns> /// <returns>The value of <paramref name="builder"/></returns>
public static TBuilder AddJsonProtocol<TBuilder>(this TBuilder builder, Action<JsonHubProtocolOptions> configure) where TBuilder : ISignalRBuilder public static TBuilder AddNewtonsoftJsonProtocol<TBuilder>(this TBuilder builder, Action<NewtonsoftJsonHubProtocolOptions> configure) where TBuilder : ISignalRBuilder
{ {
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, JsonHubProtocol>()); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHubProtocol, NewtonsoftJsonHubProtocol>());
builder.Services.Configure(configure); builder.Services.Configure(configure);
return builder; return builder;
} }

View File

@ -17,9 +17,9 @@ using Newtonsoft.Json.Serialization;
namespace Microsoft.AspNetCore.SignalR.Protocol namespace Microsoft.AspNetCore.SignalR.Protocol
{ {
/// <summary> /// <summary>
/// Implements the SignalR Hub Protocol using JSON. /// Implements the SignalR Hub Protocol using Newtonsoft.Json.
/// </summary> /// </summary>
public class JsonHubProtocol : IHubProtocol public class NewtonsoftJsonHubProtocol : IHubProtocol
{ {
private const string ResultPropertyName = "result"; private const string ResultPropertyName = "result";
private const string ItemPropertyName = "item"; private const string ItemPropertyName = "item";
@ -41,17 +41,17 @@ namespace Microsoft.AspNetCore.SignalR.Protocol
public JsonSerializer PayloadSerializer { get; } public JsonSerializer PayloadSerializer { get; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonHubProtocol"/> class. /// Initializes a new instance of the <see cref="NewtonsoftJsonHubProtocol"/> class.
/// </summary> /// </summary>
public JsonHubProtocol() : this(Options.Create(new JsonHubProtocolOptions())) public NewtonsoftJsonHubProtocol() : this(Options.Create(new NewtonsoftJsonHubProtocolOptions()))
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JsonHubProtocol"/> class. /// Initializes a new instance of the <see cref="NewtonsoftJsonHubProtocol"/> class.
/// </summary> /// </summary>
/// <param name="options">The options used to initialize the protocol.</param> /// <param name="options">The options used to initialize the protocol.</param>
public JsonHubProtocol(IOptions<JsonHubProtocolOptions> options) public NewtonsoftJsonHubProtocol(IOptions<NewtonsoftJsonHubProtocolOptions> options)
{ {
PayloadSerializer = JsonSerializer.Create(options.Value.PayloadSerializerSettings); PayloadSerializer = JsonSerializer.Create(options.Value.PayloadSerializerSettings);
} }

View File

@ -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": [ "Types": [
{ {
"Name": "Microsoft.Extensions.DependencyInjection.JsonProtocolDependencyInjectionExtensions", "Name": "Microsoft.Extensions.DependencyInjection.NewtonsoftJsonProtocolDependencyInjectionExtensions",
"Visibility": "Public", "Visibility": "Public",
"Kind": "Class", "Kind": "Class",
"Abstract": true, "Abstract": true,
@ -12,7 +12,7 @@
"Members": [ "Members": [
{ {
"Kind": "Method", "Kind": "Method",
"Name": "AddJsonProtocol<T0>", "Name": "AddNewtonsoftJsonProtocol<T0>",
"Parameters": [ "Parameters": [
{ {
"Name": "builder", "Name": "builder",
@ -35,7 +35,7 @@
}, },
{ {
"Kind": "Method", "Kind": "Method",
"Name": "AddJsonProtocol<T0>", "Name": "AddNewtonsoftJsonProtocol<T0>",
"Parameters": [ "Parameters": [
{ {
"Name": "builder", "Name": "builder",
@ -43,7 +43,7 @@
}, },
{ {
"Name": "configure", "Name": "configure",
"Type": "System.Action<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions>" "Type": "System.Action<Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions>"
} }
], ],
"ReturnType": "T0", "ReturnType": "T0",
@ -64,7 +64,7 @@
"GenericParameters": [] "GenericParameters": []
}, },
{ {
"Name": "Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions", "Name": "Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions",
"Visibility": "Public", "Visibility": "Public",
"Kind": "Class", "Kind": "Class",
"ImplementedInterfaces": [], "ImplementedInterfaces": [],
@ -101,7 +101,7 @@
"GenericParameters": [] "GenericParameters": []
}, },
{ {
"Name": "Microsoft.AspNetCore.SignalR.Protocol.JsonHubProtocol", "Name": "Microsoft.AspNetCore.SignalR.Protocol.NewtonsoftJsonHubProtocol",
"Visibility": "Public", "Visibility": "Public",
"Kind": "Class", "Kind": "Class",
"ImplementedInterfaces": [ "ImplementedInterfaces": [
@ -240,7 +240,7 @@
"Parameters": [ "Parameters": [
{ {
"Name": "options", "Name": "options",
"Type": "Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.JsonHubProtocolOptions>" "Type": "Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.SignalR.NewtonsoftJsonHubProtocolOptions>"
} }
], ],
"Visibility": "Public", "Visibility": "Public",

View File

@ -1116,7 +1116,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public static Dictionary<string, IHubProtocol> HubProtocols => public static Dictionary<string, IHubProtocol> HubProtocols =>
new Dictionary<string, IHubProtocol> new Dictionary<string, IHubProtocol>
{ {
{ "json", new JsonHubProtocol() }, { "json", new NewtonsoftJsonHubProtocol() },
{ "messagepack", new MessagePackHubProtocol() }, { "messagepack", new MessagePackHubProtocol() },
}; };

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -14,12 +14,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public class VersionedJsonHubProtocol : IHubProtocol public class VersionedJsonHubProtocol : IHubProtocol
{ {
private readonly int _version; private readonly int _version;
private readonly JsonHubProtocol _innerProtocol; private readonly NewtonsoftJsonHubProtocol _innerProtocol;
public VersionedJsonHubProtocol(int version) public VersionedJsonHubProtocol(int version)
{ {
_version = version; _version = version;
_innerProtocol = new JsonHubProtocol(); _innerProtocol = new NewtonsoftJsonHubProtocol();
} }
public string Name => _innerProtocol.Name; public string Name => _innerProtocol.Name;
@ -84,4 +84,4 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
return version <= _version; return version <= _version;
} }
} }
} }

View File

@ -101,13 +101,13 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
public void AddJsonProtocolAddsProtocol() public void AddJsonProtocolAddsProtocol()
{ {
var connectionBuilder = new HubConnectionBuilder(); var connectionBuilder = new HubConnectionBuilder();
connectionBuilder.AddJsonProtocol(); connectionBuilder.AddNewtonsoftJsonProtocol();
var serviceProvider = connectionBuilder.Services.BuildServiceProvider(); var serviceProvider = connectionBuilder.Services.BuildServiceProvider();
var resolvedHubProtocol = serviceProvider.GetService<IHubProtocol>(); var resolvedHubProtocol = serviceProvider.GetService<IHubProtocol>();
Assert.IsType<JsonHubProtocol>(resolvedHubProtocol); Assert.IsType<NewtonsoftJsonHubProtocol>(resolvedHubProtocol);
} }
[Fact] [Fact]
@ -123,4 +123,4 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
Assert.IsType<MessagePackHubProtocol>(resolvedHubProtocol); Assert.IsType<MessagePackHubProtocol>(resolvedHubProtocol);
} }
} }
} }

View File

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Http.Connections.Client; using Microsoft.AspNetCore.Http.Connections.Client;
using Microsoft.AspNetCore.SignalR.Protocol; using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -27,16 +25,16 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact] [Fact]
public void AddJsonProtocolSetsHubProtocolToJsonWithDefaultOptions() public void AddJsonProtocolSetsHubProtocolToJsonWithDefaultOptions()
{ {
var serviceProvider = new HubConnectionBuilder().AddJsonProtocol().Services.BuildServiceProvider(); var serviceProvider = new HubConnectionBuilder().AddNewtonsoftJsonProtocol().Services.BuildServiceProvider();
var actualProtocol = Assert.IsType<JsonHubProtocol>(serviceProvider.GetService<IHubProtocol>()); var actualProtocol = Assert.IsType<NewtonsoftJsonHubProtocol>(serviceProvider.GetService<IHubProtocol>());
Assert.IsType<CamelCasePropertyNamesContractResolver>(actualProtocol.PayloadSerializer.ContractResolver); Assert.IsType<CamelCasePropertyNamesContractResolver>(actualProtocol.PayloadSerializer.ContractResolver);
} }
[Fact] [Fact]
public void AddJsonProtocolSetsHubProtocolToJsonWithProvidedOptions() public void AddJsonProtocolSetsHubProtocolToJsonWithProvidedOptions()
{ {
var serviceProvider = new HubConnectionBuilder().AddJsonProtocol(options => var serviceProvider = new HubConnectionBuilder().AddNewtonsoftJsonProtocol(options =>
{ {
options.PayloadSerializerSettings = new JsonSerializerSettings options.PayloadSerializerSettings = new JsonSerializerSettings
{ {
@ -44,7 +42,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
}; };
}).Services.BuildServiceProvider(); }).Services.BuildServiceProvider();
var actualProtocol = Assert.IsType<JsonHubProtocol>(serviceProvider.GetService<IHubProtocol>()); var actualProtocol = Assert.IsType<NewtonsoftJsonHubProtocol>(serviceProvider.GetService<IHubProtocol>());
Assert.Equal("JUST A TEST", actualProtocol.PayloadSerializer.DateFormatString); Assert.Equal("JUST A TEST", actualProtocol.PayloadSerializer.DateFormatString);
} }

View File

@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
var expectedOutput = Frame(testData.Json); var expectedOutput = Frame(testData.Json);
var protocolOptions = new JsonHubProtocolOptions var protocolOptions = new NewtonsoftJsonHubProtocolOptions
{ {
PayloadSerializerSettings = new JsonSerializerSettings() 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(); var writer = MemoryBufferWriter.Get();
try try
@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
var input = Frame(testData.Json); var input = Frame(testData.Json);
var protocolOptions = new JsonHubProtocolOptions var protocolOptions = new NewtonsoftJsonHubProtocolOptions
{ {
PayloadSerializerSettings = new JsonSerializerSettings PayloadSerializerSettings = new JsonSerializerSettings
{ {
@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
}; };
var binder = new TestBinder(testData.Message); var binder = new TestBinder(testData.Message);
var protocol = new JsonHubProtocol(Options.Create(protocolOptions)); var protocol = new NewtonsoftJsonHubProtocol(Options.Create(protocolOptions));
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
input = Frame(input); input = Frame(input);
var binder = new TestBinder(Array.Empty<Type>(), typeof(object)); var binder = new TestBinder(Array.Empty<Type>(), typeof(object));
var protocol = new JsonHubProtocol(); var protocol = new NewtonsoftJsonHubProtocol();
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
var ex = Assert.Throws<InvalidDataException>(() => protocol.TryParseMessage(ref data, binder, out var _)); var ex = Assert.Throws<InvalidDataException>(() => protocol.TryParseMessage(ref data, binder, out var _));
Assert.Equal(expectedMessage, ex.Message); Assert.Equal(expectedMessage, ex.Message);
@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
var input = Frame(testData.Json); var input = Frame(testData.Json);
var binder = new TestBinder(testData.Message); var binder = new TestBinder(testData.Message);
var protocol = new JsonHubProtocol(); var protocol = new NewtonsoftJsonHubProtocol();
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input)); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
input = Frame(input); input = Frame(input);
var binder = new TestBinder(paramTypes: new[] { typeof(int), typeof(string) }, returnType: typeof(bool)); 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<byte>(Encoding.UTF8.GetBytes(input)); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
Assert.True(protocol.TryParseMessage(ref data, binder, out var message)); Assert.True(protocol.TryParseMessage(ref data, binder, out var message));
Assert.NotNull(message); Assert.NotNull(message);
@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
input = Frame(input); input = Frame(input);
var binder = new TestBinder(paramTypes: new[] { typeof(int), typeof(string) }, returnType: typeof(bool)); 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<byte>(Encoding.UTF8.GetBytes(input)); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(input));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
var bindingFailure = Assert.IsType<InvocationBindingFailureMessage>(message); var bindingFailure = Assert.IsType<InvocationBindingFailureMessage>(message);
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
public void DateTimeArgumentPreservesUtcKind(string input) public void DateTimeArgumentPreservesUtcKind(string input)
{ {
var binder = new TestBinder(new[] { typeof(DateTime) }); var binder = new TestBinder(new[] { typeof(DateTime) });
var protocol = new JsonHubProtocol(); var protocol = new NewtonsoftJsonHubProtocol();
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input))); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input)));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
var invocationMessage = Assert.IsType<InvocationMessage>(message); var invocationMessage = Assert.IsType<InvocationMessage>(message);
@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
public void DateTimeReturnValuePreservesUtcKind(string input) public void DateTimeReturnValuePreservesUtcKind(string input)
{ {
var binder = new TestBinder(typeof(DateTime)); var binder = new TestBinder(typeof(DateTime));
var protocol = new JsonHubProtocol(); var protocol = new NewtonsoftJsonHubProtocol();
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input))); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame(input)));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
var invocationMessage = Assert.IsType<CompletionMessage>(message); var invocationMessage = Assert.IsType<CompletionMessage>(message);
@ -304,7 +304,7 @@ namespace Microsoft.AspNetCore.SignalR.Common.Tests.Internal.Protocol
public void ReadToEndOfArgumentArrayOnError() public void ReadToEndOfArgumentArrayOnError()
{ {
var binder = new TestBinder(new[] { typeof(string) }); var binder = new TestBinder(new[] { typeof(string) });
var protocol = new JsonHubProtocol(); var protocol = new NewtonsoftJsonHubProtocol();
var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame("{'type':1,'invocationId':'42','target':'foo','arguments':[[],{'target':'foo2'}]}"))); var data = new ReadOnlySequence<byte>(Encoding.UTF8.GetBytes(Frame("{'type':1,'invocationId':'42','target':'foo','arguments':[[],{'target':'foo2'}]}")));
protocol.TryParseMessage(ref data, binder, out var message); protocol.TryParseMessage(ref data, binder, out var message);
var bindingFailure = Assert.IsType<InvocationBindingFailureMessage>(message); var bindingFailure = Assert.IsType<InvocationBindingFailureMessage>(message);

View File

@ -22,17 +22,17 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
public string TestProperty { get; set; } public string TestProperty { get; set; }
} }
private RedisHubLifetimeManager<MyHub> CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, JsonHubProtocolOptions jsonOptions = null) private RedisHubLifetimeManager<MyHub> CreateLifetimeManager(TestRedisServer server, MessagePackHubProtocolOptions messagePackOptions = null, NewtonsoftJsonHubProtocolOptions jsonOptions = null)
{ {
var options = new RedisOptions() { ConnectionFactory = async (t) => await Task.FromResult(new TestConnectionMultiplexer(server)) }; var options = new RedisOptions() { ConnectionFactory = async (t) => await Task.FromResult(new TestConnectionMultiplexer(server)) };
messagePackOptions = messagePackOptions ?? new MessagePackHubProtocolOptions(); messagePackOptions = messagePackOptions ?? new MessagePackHubProtocolOptions();
jsonOptions = jsonOptions ?? new JsonHubProtocolOptions(); jsonOptions = jsonOptions ?? new NewtonsoftJsonHubProtocolOptions();
return new RedisHubLifetimeManager<MyHub>( return new RedisHubLifetimeManager<MyHub>(
NullLogger<RedisHubLifetimeManager<MyHub>>.Instance, NullLogger<RedisHubLifetimeManager<MyHub>>.Instance,
Options.Create(options), Options.Create(options),
new DefaultHubProtocolResolver(new IHubProtocol[] new DefaultHubProtocolResolver(new IHubProtocol[]
{ {
new JsonHubProtocol(Options.Create(jsonOptions)), new NewtonsoftJsonHubProtocol(Options.Create(jsonOptions)),
new MessagePackHubProtocol(Options.Create(messagePackOptions)), new MessagePackHubProtocol(Options.Create(messagePackOptions)),
}, NullLogger<DefaultHubProtocolResolver>.Instance)); }, NullLogger<DefaultHubProtocolResolver>.Instance));
} }
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests
var messagePackOptions = new MessagePackHubProtocolOptions(); var messagePackOptions = new MessagePackHubProtocolOptions();
var jsonOptions = new JsonHubProtocolOptions(); var jsonOptions = new NewtonsoftJsonHubProtocolOptions();
jsonOptions.PayloadSerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); jsonOptions.PayloadSerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
using (var client1 = new TestClient()) using (var client1 = new TestClient())

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{ {
return new HubConnectionContext(connection, TimeSpan.FromSeconds(15), NullLoggerFactory.Instance) return new HubConnectionContext(connection, TimeSpan.FromSeconds(15), NullLoggerFactory.Instance)
{ {
Protocol = protocol ?? new JsonHubProtocol(), Protocol = protocol ?? new NewtonsoftJsonHubProtocol(),
UserIdentifier = userIdentifier, UserIdentifier = userIdentifier,
}; };
} }

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -11,19 +11,19 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{ {
public static class HubProtocolHelpers 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(); private static readonly IHubProtocol MessagePackHubProtocol = new MessagePackHubProtocol();
public static readonly List<string> AllProtocolNames = new List<string> public static readonly List<string> AllProtocolNames = new List<string>
{ {
JsonHubProtocol.Name, NewtonsoftJsonHubProtocol.Name,
MessagePackHubProtocol.Name MessagePackHubProtocol.Name
}; };
public static readonly IList<IHubProtocol> AllProtocols = new List<IHubProtocol>() public static readonly IList<IHubProtocol> AllProtocols = new List<IHubProtocol>()
{ {
JsonHubProtocol, NewtonsoftJsonHubProtocol,
MessagePackHubProtocol MessagePackHubProtocol
}; };
@ -38,4 +38,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests
return protocol; return protocol;
} }
} }
} }

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
Connection.User = new ClaimsPrincipal(new ClaimsIdentity(claims)); Connection.User = new ClaimsPrincipal(new ClaimsIdentity(claims));
Connection.Items["ConnectedTask"] = new TaskCompletionSource<bool>(); Connection.Items["ConnectedTask"] = new TaskCompletionSource<bool>();
_protocol = protocol ?? new JsonHubProtocol(); _protocol = protocol ?? new NewtonsoftJsonHubProtocol();
_invocationBinder = invocationBinder ?? new DefaultInvocationBinder(); _invocationBinder = invocationBinder ?? new DefaultInvocationBinder();
_cts = new CancellationTokenSource(); _cts = new CancellationTokenSource();

View File

@ -1842,7 +1842,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client1 = new TestClient(protocol: new JsonHubProtocol())) using (var client1 = new TestClient(protocol: new NewtonsoftJsonHubProtocol()))
using (var client2 = new TestClient(protocol: new MessagePackHubProtocol())) using (var client2 = new TestClient(protocol: new MessagePackHubProtocol()))
{ {
var firstConnectionHandlerTask = await client1.ConnectAsync(connectionHandler); var firstConnectionHandlerTask = await client1.ConnectAsync(connectionHandler);
@ -1973,7 +1973,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{ {
services services
.AddSignalR() .AddSignalR()
.AddJsonProtocol(o => .AddNewtonsoftJsonProtocol(o =>
{ {
o.PayloadSerializerSettings = new JsonSerializerSettings o.PayloadSerializerSettings = new JsonSerializerSettings
{ {
@ -2237,7 +2237,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
await client.Connected.OrTimeout(); await client.Connected.OrTimeout();
@ -2266,7 +2266,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
@ -2310,7 +2310,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); options.KeepAliveInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
await client.Connected.OrTimeout(); await client.Connected.OrTimeout();
@ -2371,7 +2371,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
await client.Connected.OrTimeout(); await client.Connected.OrTimeout();
@ -2397,7 +2397,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory); options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(100)), LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
await client.Connected.OrTimeout(); await client.Connected.OrTimeout();
@ -2424,7 +2424,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(300)), LoggerFactory); options.ClientTimeoutInterval = TimeSpan.FromMilliseconds(300)), LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
await client.Connected.OrTimeout(); await client.Connected.OrTimeout();
@ -2450,7 +2450,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<MethodHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
@ -2493,7 +2493,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
}, LoggerFactory); }, LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<OnConnectedThrowsHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<OnConnectedThrowsHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler); var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
@ -2522,7 +2522,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory); var serviceProvider = HubConnectionHandlerTestUtils.CreateServiceProvider(null, LoggerFactory);
var connectionHandler = serviceProvider.GetService<HubConnectionHandler<StreamingHub>>(); var connectionHandler = serviceProvider.GetService<HubConnectionHandler<StreamingHub>>();
using (var client = new TestClient(new JsonHubProtocol())) using (var client = new TestClient(new NewtonsoftJsonHubProtocol()))
{ {
var connectionHandlerTask = await client.ConnectAsync(connectionHandler).OrTimeout(); var connectionHandlerTask = await client.ConnectAsync(connectionHandler).OrTimeout();

View File

@ -73,8 +73,8 @@ namespace Microsoft.AspNetCore.SignalR.Common.Protocol.Tests
public void RegisteringMultipleHubProtocolsFails() public void RegisteringMultipleHubProtocolsFails()
{ {
var exception = Assert.Throws<InvalidOperationException>(() => new DefaultHubProtocolResolver(new[] { var exception = Assert.Throws<InvalidOperationException>(() => new DefaultHubProtocolResolver(new[] {
new JsonHubProtocol(), new NewtonsoftJsonHubProtocol(),
new JsonHubProtocol() new NewtonsoftJsonHubProtocol()
}, NullLogger<DefaultHubProtocolResolver>.Instance)); }, NullLogger<DefaultHubProtocolResolver>.Instance));
Assert.Equal($"Multiple Hub Protocols with the name 'json' were registered.", exception.Message); Assert.Equal($"Multiple Hub Protocols with the name 'json' were registered.", exception.Message);