diff --git a/src/Microsoft.AspNetCore.SignalR.Core/HubOptions.cs b/src/Microsoft.AspNetCore.SignalR.Core/HubOptions.cs index 830056bbdd..b1d6f40cdd 100644 --- a/src/Microsoft.AspNetCore.SignalR.Core/HubOptions.cs +++ b/src/Microsoft.AspNetCore.SignalR.Core/HubOptions.cs @@ -7,6 +7,6 @@ namespace Microsoft.AspNetCore.SignalR { public class HubOptions { - public JsonSerializerSettings JsonSerializerSettings { get; set; } + public JsonSerializerSettings JsonSerializerSettings { get; set; } = new JsonSerializerSettings(); } } diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs index 33daaa4202..c95608b0cf 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/Hubs.cs @@ -4,7 +4,6 @@ using System; using System.Reactive.Linq; using System.Threading.Tasks; -using Microsoft.CSharp; namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests { diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/SignalRDependencyInjectionExtensionsTests.cs b/test/Microsoft.AspNetCore.SignalR.Tests/SignalRDependencyInjectionExtensionsTests.cs new file mode 100644 index 0000000000..a4f834f97d --- /dev/null +++ b/test/Microsoft.AspNetCore.SignalR.Tests/SignalRDependencyInjectionExtensionsTests.cs @@ -0,0 +1,23 @@ +// 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 Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Xunit; + +namespace Microsoft.AspNetCore.SignalR.Tests +{ + public class SignalRDependencyInjectionExtensionsTests + { + [Fact] + public void JSonSerializerSettingsShouldNotBeNullInOptions() + { + var services = new ServiceCollection(); + services.AddOptions(); + services.AddSignalR(); + var serviceProvider = services.BuildServiceProvider(); + var hubOptions = serviceProvider.GetService>(); + Assert.NotNull(hubOptions.Value.JsonSerializerSettings); + } + } +}