22// Copyright (c) The AppCore .NET project.
33
44using System ;
5+ using System . Diagnostics . CodeAnalysis ;
56using AppCoreNet . Diagnostics ;
67using AppCoreNet . Extensions . Hosting ;
78using Microsoft . Extensions . DependencyInjection ;
@@ -22,13 +23,14 @@ public static class StartupTaskServiceCollectionExtensions
2223 /// <param name="startupTaskType">The implementation of the <see cref="IStartupTask"/>.</param>
2324 /// <returns>The passed <see cref="IServiceCollection"/> to allow chaining.</returns>
2425 /// <exception cref="ArgumentNullException">Argument <paramref name="startupTaskType"/> is <c>null</c>.</exception>
25- public static IServiceCollection AddStartupTask ( this IServiceCollection services , Type startupTaskType )
26+ public static IServiceCollection AddStartupTask (
27+ this IServiceCollection services ,
28+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] Type startupTaskType )
2629 {
2730 Ensure . Arg . NotNull ( startupTaskType ) ;
2831 Ensure . Arg . OfType < IStartupTask > ( startupTaskType ) ;
2932
3033 services . TryAddEnumerable ( ServiceDescriptor . Transient ( typeof ( IStartupTask ) , startupTaskType ) ) ;
31-
3234 return services ;
3335 }
3436
@@ -38,7 +40,9 @@ public static IServiceCollection AddStartupTask(this IServiceCollection services
3840 /// <typeparam name="T">The implementation of the <see cref="IStartupTask"/>.</typeparam>
3941 /// <param name="services">The <see cref="IServiceCollection"/>.</param>
4042 /// <returns>The passed <see cref="IServiceCollection"/> to allow chaining.</returns>
41- public static IServiceCollection AddStartupTask < T > ( this IServiceCollection services )
43+ public static IServiceCollection AddStartupTask <
44+ [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] T > (
45+ this IServiceCollection services )
4246 where T : IStartupTask
4347 {
4448 return AddStartupTask ( services , typeof ( T ) ) ;
@@ -50,7 +54,9 @@ public static IServiceCollection AddStartupTask<T>(this IServiceCollection servi
5054 /// <param name="services">The <see cref="IServiceCollection"/>.</param>
5155 /// <param name="configure">The configuration delegate.</param>
5256 /// <returns>The passed <see cref="IServiceCollection"/> to allow chaining.</returns>
53- public static IServiceCollection AddStartupTasksFrom ( this IServiceCollection services , Action < IServiceDescriptorReflectionBuilder > configure )
57+ public static IServiceCollection AddStartupTasksFrom (
58+ this IServiceCollection services ,
59+ Action < IServiceDescriptorReflectionBuilder > configure )
5460 {
5561 return services . TryAddEnumerableFrom < IStartupTask > ( configure ) ;
5662 }
0 commit comments