diff --git a/src/Passwordless.AspNetCore/IdentityBuilderExtensions.cs b/src/Passwordless.AspNetCore/IdentityBuilderExtensions.cs index 6798974..3c8b237 100644 --- a/src/Passwordless.AspNetCore/IdentityBuilderExtensions.cs +++ b/src/Passwordless.AspNetCore/IdentityBuilderExtensions.cs @@ -24,6 +24,8 @@ public static class IdentityBuilderExtensions /// The . /// Configures the . /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IServiceCollection AddPasswordless(this IServiceCollection services, Action configure) where TUser : class, new() { @@ -36,12 +38,16 @@ public static IServiceCollection AddPasswordless(this IServiceCollection /// The current instance. /// Configures the . /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IdentityBuilder AddPasswordless(this IdentityBuilder builder, Action configure) { builder.Services.AddPasswordlessCore(builder.UserType, configure, IdentityConstants.ApplicationScheme); return builder; } + [RequiresDynamicCode("Calls Microsoft.Extensions.DependencyInjection.IdentityBuilderExtensions.AddShared(Type, OptionsBuilder, String)")] + [RequiresUnreferencedCode("Calls Microsoft.Extensions.DependencyInjection.IdentityBuilderExtensions.AddShared(Type, OptionsBuilder, String)")] private static IServiceCollection AddPasswordlessCore(this IServiceCollection services, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type userType, Action configure, @@ -71,6 +77,8 @@ private static IServiceCollection AddPasswordlessCore(this IServiceCollection se /// The current instance. /// The to use to bind to . Generally it's own section. /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IServiceCollection AddPasswordless(this IdentityBuilder builder, IConfiguration configuration) { return builder.AddPasswordless(configuration, builder.UserType, IdentityConstants.ApplicationScheme); @@ -82,11 +90,15 @@ public static IServiceCollection AddPasswordless(this IdentityBuilder builder, I /// The current instance. /// The to use to bind to . Generally it's own section. /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IServiceCollection AddPasswordless(this IdentityBuilder builder, IConfiguration configuration) { return builder.AddPasswordless(configuration, typeof(TUserType), null); } + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] private static IServiceCollection AddPasswordless(this IdentityBuilder builder, IConfiguration configuration, Type? userType, string? defaultScheme) { var optionsBuilder = builder.Services @@ -104,6 +116,8 @@ private static IServiceCollection AddPasswordless(this IdentityBuilder builder, /// The current instance. /// The configuration path to use to bind to . /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IServiceCollection AddPasswordless(this IdentityBuilder builder, string path) { return builder.AddPasswordless(path, builder.UserType, IdentityConstants.ApplicationScheme); @@ -115,11 +129,15 @@ public static IServiceCollection AddPasswordless(this IdentityBuilder builder, s /// The current instance. /// The configuration path to use to bind to . /// The . + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static IServiceCollection AddPasswordless(this IdentityBuilder builder, string path) { return builder.AddPasswordless(path, typeof(TUserType), null); } + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] private static IServiceCollection AddPasswordless(this IdentityBuilder builder, string path, Type userType, string? defaultScheme) { var optionsBuilder = builder.Services @@ -131,6 +149,8 @@ private static IServiceCollection AddPasswordless(this IdentityBuilder builder, return builder.Services.AddShared(userType ?? builder.UserType, optionsBuilder, IdentityConstants.ApplicationScheme); } + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] private static IServiceCollection AddShared(this IServiceCollection services, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type userType, diff --git a/src/Passwordless.AspNetCore/Passwordless.AspNetCore.csproj b/src/Passwordless.AspNetCore/Passwordless.AspNetCore.csproj index 0b4d8fb..67b152c 100644 --- a/src/Passwordless.AspNetCore/Passwordless.AspNetCore.csproj +++ b/src/Passwordless.AspNetCore/Passwordless.AspNetCore.csproj @@ -3,7 +3,8 @@ net7.0 true - true + true + true diff --git a/src/Passwordless.AspNetCore/PasswordlessApiEndpointRouteBuilderExtensions.cs b/src/Passwordless.AspNetCore/PasswordlessApiEndpointRouteBuilderExtensions.cs index ff470ed..8f988ce 100644 --- a/src/Passwordless.AspNetCore/PasswordlessApiEndpointRouteBuilderExtensions.cs +++ b/src/Passwordless.AspNetCore/PasswordlessApiEndpointRouteBuilderExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; @@ -15,8 +16,10 @@ namespace Passwordless.AspNetCore; public static class PasswordlessApiEndpointRouteBuilderExtensions { /// - /// + /// /// + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static PasswordlessEndpointConventionBuilder MapPasswordless(this IEndpointRouteBuilder endpoints, bool enableRegisterEndpoint = false) { // TODO: When a custom register body isn't passed in, we can make a reasonable assumption @@ -26,24 +29,30 @@ public static PasswordlessEndpointConventionBuilder MapPasswordless(this IEndpoi } /// - /// + /// /// + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static PasswordlessEndpointConventionBuilder MapPasswordless(this IEndpointRouteBuilder endpoints, PasswordlessEndpointOptions endpointOptions) { return endpoints.MapPasswordless(endpointOptions); } /// - /// + /// /// + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static PasswordlessEndpointConventionBuilder MapPasswordless(this IEndpointRouteBuilder endpoints) { return endpoints.MapPasswordless(new PasswordlessEndpointOptions(enableRegisterEndpoint: true)); } /// - /// + /// /// + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] public static PasswordlessEndpointConventionBuilder MapPasswordless(this IEndpointRouteBuilder endpoints, PasswordlessEndpointOptions endpointOptions) { var routeGroup = endpoints diff --git a/src/Passwordless/Passwordless.csproj b/src/Passwordless/Passwordless.csproj index 153d3d3..596810c 100644 --- a/src/Passwordless/Passwordless.csproj +++ b/src/Passwordless/Passwordless.csproj @@ -3,6 +3,8 @@ net462;net6.0;net7.0;netstandard2.0 true + true + true diff --git a/src/Passwordless/ServiceCollectionExtensions.cs b/src/Passwordless/ServiceCollectionExtensions.cs index 98f139b..8a11e76 100644 --- a/src/Passwordless/ServiceCollectionExtensions.cs +++ b/src/Passwordless/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Options; using Passwordless; @@ -31,6 +32,12 @@ public static IServiceCollection AddPasswordlessSdk( /// /// Adds and configures Passwordless-related services. /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] +#endif +#if NET7_0_OR_GREATER + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] +#endif public static IServiceCollection AddPasswordlessSdk( this IServiceCollection services, IConfiguration configuration) @@ -44,13 +51,18 @@ public static IServiceCollection AddPasswordlessSdk( return services; } - /// /// Adds and configures Passwordless-related services. /// /// /// /// +#if NET6_0_OR_GREATER + [RequiresUnreferencedCode("This method is incompatible with assembly trimming.")] +#endif +#if NET7_0_OR_GREATER + [RequiresDynamicCode("This method is incompatible with native AOT compilation.")] +#endif public static IServiceCollection AddPasswordlessSdk( this IServiceCollection services, string section)