diff --git a/src/SignalR/server/Core/src/HubOptionsExtensions.cs b/src/SignalR/server/Core/src/HubOptionsExtensions.cs
index 6db3e87e1f..b83d1ec9ea 100644
--- a/src/SignalR/server/Core/src/HubOptionsExtensions.cs
+++ b/src/SignalR/server/Core/src/HubOptionsExtensions.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.SignalR.Internal;
namespace Microsoft.AspNetCore.SignalR
@@ -37,7 +38,7 @@ namespace Microsoft.AspNetCore.SignalR
///
/// The type that will be added to the options.
/// The options to add a filter to.
- public static void AddFilter(this HubOptions options) where TFilter : IHubFilter
+ public static void AddFilter<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]TFilter>(this HubOptions options) where TFilter : IHubFilter
{
_ = options ?? throw new ArgumentNullException(nameof(options));
@@ -49,7 +50,7 @@ namespace Microsoft.AspNetCore.SignalR
///
/// The options to add a filter to.
/// The type that will be added to the options.
- public static void AddFilter(this HubOptions options, Type filterType)
+ public static void AddFilter(this HubOptions options, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type filterType)
{
_ = options ?? throw new ArgumentNullException(nameof(options));
_ = filterType ?? throw new ArgumentNullException(nameof(filterType));
diff --git a/src/SignalR/server/Core/src/Internal/HubFilterFactory.cs b/src/SignalR/server/Core/src/Internal/HubFilterFactory.cs
index 83a17acb2b..91a1b7fb71 100644
--- a/src/SignalR/server/Core/src/Internal/HubFilterFactory.cs
+++ b/src/SignalR/server/Core/src/Internal/HubFilterFactory.cs
@@ -4,6 +4,7 @@
#nullable enable
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
@@ -12,9 +13,11 @@ namespace Microsoft.AspNetCore.SignalR.Internal
internal class HubFilterFactory : IHubFilter
{
private readonly ObjectFactory _objectFactory;
+
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
private readonly Type _filterType;
- public HubFilterFactory(Type filterType)
+ public HubFilterFactory([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type filterType)
{
_objectFactory = ActivatorUtilities.CreateFactory(filterType, Array.Empty());
_filterType = filterType;