diff --git a/src/Http/Authentication.Abstractions/src/AuthenticationOptions.cs b/src/Http/Authentication.Abstractions/src/AuthenticationOptions.cs
index ee76d6d1e0..ca512b0c5f 100644
--- a/src/Http/Authentication.Abstractions/src/AuthenticationOptions.cs
+++ b/src/Http/Authentication.Abstractions/src/AuthenticationOptions.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;
@@ -54,7 +55,7 @@ namespace Microsoft.AspNetCore.Authentication
/// The responsible for the scheme.
/// The name of the scheme being added.
/// The display name for the scheme.
- public void AddScheme(string name, string displayName) where THandler : IAuthenticationHandler
+ public void AddScheme<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]THandler>(string name, string displayName) where THandler : IAuthenticationHandler
=> AddScheme(name, b =>
{
b.DisplayName = displayName;
diff --git a/src/Http/Authentication.Abstractions/src/AuthenticationScheme.cs b/src/Http/Authentication.Abstractions/src/AuthenticationScheme.cs
index a268cce022..2749c2daa2 100644
--- a/src/Http/Authentication.Abstractions/src/AuthenticationScheme.cs
+++ b/src/Http/Authentication.Abstractions/src/AuthenticationScheme.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.Authentication
{
@@ -17,7 +18,7 @@ namespace Microsoft.AspNetCore.Authentication
/// The name for the authentication scheme.
/// The display name for the authentication scheme.
/// The type that handles this scheme.
- public AuthenticationScheme(string name, string? displayName, Type handlerType)
+ public AuthenticationScheme(string name, string? displayName, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type handlerType)
{
if (name == null)
{
@@ -50,6 +51,7 @@ namespace Microsoft.AspNetCore.Authentication
///
/// The type that handles this scheme.
///
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public Type HandlerType { get; }
}
}
diff --git a/src/Http/Authentication.Abstractions/src/AuthenticationSchemeBuilder.cs b/src/Http/Authentication.Abstractions/src/AuthenticationSchemeBuilder.cs
index 7139de0a2f..aef5417376 100644
--- a/src/Http/Authentication.Abstractions/src/AuthenticationSchemeBuilder.cs
+++ b/src/Http/Authentication.Abstractions/src/AuthenticationSchemeBuilder.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNetCore.Authentication
{
@@ -32,6 +33,7 @@ namespace Microsoft.AspNetCore.Authentication
///
/// The type responsible for this scheme.
///
+ [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
public Type? HandlerType { get; set; }
///
diff --git a/src/Security/Authentication/Core/src/AuthenticationBuilder.cs b/src/Security/Authentication/Core/src/AuthenticationBuilder.cs
index c89c153003..ba461dc4c3 100644
--- a/src/Security/Authentication/Core/src/AuthenticationBuilder.cs
+++ b/src/Security/Authentication/Core/src/AuthenticationBuilder.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@@ -25,7 +26,7 @@ namespace Microsoft.AspNetCore.Authentication
///
public virtual IServiceCollection Services { get; }
- private AuthenticationBuilder AddSchemeHelper(string authenticationScheme, string? displayName, Action? configureOptions)
+ private AuthenticationBuilder AddSchemeHelper(string authenticationScheme, string? displayName, Action? configureOptions)
where TOptions : AuthenticationSchemeOptions, new()
where THandler : class, IAuthenticationHandler
{
@@ -57,7 +58,7 @@ namespace Microsoft.AspNetCore.Authentication
/// The display name of this scheme.
/// Used to configure the scheme options.
/// The builder.
- public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string? displayName, Action? configureOptions)
+ public virtual AuthenticationBuilder AddScheme(string authenticationScheme, string? displayName, Action? configureOptions)
where TOptions : AuthenticationSchemeOptions, new()
where THandler : AuthenticationHandler
=> AddSchemeHelper(authenticationScheme, displayName, configureOptions);
@@ -70,7 +71,7 @@ namespace Microsoft.AspNetCore.Authentication
/// The name of this scheme.
/// Used to configure the scheme options.
/// The builder.
- public virtual AuthenticationBuilder AddScheme(string authenticationScheme, Action? configureOptions)
+ public virtual AuthenticationBuilder AddScheme(string authenticationScheme, Action? configureOptions)
where TOptions : AuthenticationSchemeOptions, new()
where THandler : AuthenticationHandler
=> AddScheme(authenticationScheme, displayName: null, configureOptions: configureOptions);
@@ -85,7 +86,7 @@ namespace Microsoft.AspNetCore.Authentication
/// The display name of this scheme.
/// Used to configure the scheme options.
/// The builder.
- public virtual AuthenticationBuilder AddRemoteScheme(string authenticationScheme, string? displayName, Action? configureOptions)
+ public virtual AuthenticationBuilder AddRemoteScheme(string authenticationScheme, string? displayName, Action? configureOptions)
where TOptions : RemoteAuthenticationOptions, new()
where THandler : RemoteAuthenticationHandler
{
diff --git a/src/Security/Authentication/OAuth/src/OAuthExtensions.cs b/src/Security/Authentication/OAuth/src/OAuthExtensions.cs
index 22c541a0ac..aca0634cb1 100644
--- a/src/Security/Authentication/OAuth/src/OAuthExtensions.cs
+++ b/src/Security/Authentication/OAuth/src/OAuthExtensions.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -17,12 +18,12 @@ namespace Microsoft.Extensions.DependencyInjection
public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions)
=> builder.AddOAuth>(authenticationScheme, displayName, configureOptions);
- public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions)
+ public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, Action configureOptions)
where TOptions : OAuthOptions, new()
where THandler : OAuthHandler
=> builder.AddOAuth(authenticationScheme, OAuthDefaults.DisplayName, configureOptions);
- public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions)
+ public static AuthenticationBuilder AddOAuth(this AuthenticationBuilder builder, string authenticationScheme, string displayName, Action configureOptions)
where TOptions : OAuthOptions, new()
where THandler : OAuthHandler
{