11// Copyright (c) Six Labors.
22// Licensed under the Six Labors Split License.
33
4+ using System . Diagnostics . CodeAnalysis ;
45using Microsoft . Extensions . Configuration ;
56using Microsoft . Extensions . DependencyInjection ;
67using Microsoft . Extensions . DependencyInjection . Extensions ;
@@ -23,7 +24,7 @@ public static class ImageSharpBuilderExtensions
2324 /// <typeparam name="TParser">The type of class implementing <see cref="IRequestParser"/> to add.</typeparam>
2425 /// <param name="builder">The core builder.</param>
2526 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
26- public static IImageSharpBuilder SetRequestParser < TParser > ( this IImageSharpBuilder builder )
27+ public static IImageSharpBuilder SetRequestParser < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TParser > ( this IImageSharpBuilder builder )
2728 where TParser : class , IRequestParser
2829 {
2930 builder . Services . Replace ( ServiceDescriptor . Singleton < IRequestParser , TParser > ( ) ) ;
@@ -50,7 +51,7 @@ public static IImageSharpBuilder SetRequestParser(this IImageSharpBuilder builde
5051 /// <typeparam name="TCache">The type of class implementing <see cref="IImageCache"/> to add.</typeparam>
5152 /// <param name="builder">The core builder.</param>
5253 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
53- public static IImageSharpBuilder SetCache < TCache > ( this IImageSharpBuilder builder )
54+ public static IImageSharpBuilder SetCache < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TCache > ( this IImageSharpBuilder builder )
5455 where TCache : class , IImageCache
5556 {
5657 builder . Services . Replace ( ServiceDescriptor . Singleton < IImageCache , TCache > ( ) ) ;
@@ -77,7 +78,7 @@ public static IImageSharpBuilder SetCache(this IImageSharpBuilder builder, Func<
7778 /// <typeparam name="TCacheKey">The type of class implementing <see cref="ICacheKey"/> to add.</typeparam>
7879 /// <param name="builder">The core builder.</param>
7980 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
80- public static IImageSharpBuilder SetCacheKey < TCacheKey > ( this IImageSharpBuilder builder )
81+ public static IImageSharpBuilder SetCacheKey < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TCacheKey > ( this IImageSharpBuilder builder )
8182 where TCacheKey : class , ICacheKey
8283 {
8384 builder . Services . Replace ( ServiceDescriptor . Singleton < ICacheKey , TCacheKey > ( ) ) ;
@@ -104,7 +105,7 @@ public static IImageSharpBuilder SetCacheKey(this IImageSharpBuilder builder, Fu
104105 /// <typeparam name="TCacheHash">The type of class implementing <see cref="ICacheHash"/> to add.</typeparam>
105106 /// <param name="builder">The core builder.</param>
106107 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
107- public static IImageSharpBuilder SetCacheHash < TCacheHash > ( this IImageSharpBuilder builder )
108+ public static IImageSharpBuilder SetCacheHash < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TCacheHash > ( this IImageSharpBuilder builder )
108109 where TCacheHash : class , ICacheHash
109110 {
110111 builder . Services . Replace ( ServiceDescriptor . Singleton < ICacheHash , TCacheHash > ( ) ) ;
@@ -131,7 +132,7 @@ public static IImageSharpBuilder SetCacheHash(this IImageSharpBuilder builder, F
131132 /// <typeparam name="TProvider">The type of class implementing <see cref="IImageProvider"/> to add.</typeparam>
132133 /// <param name="builder">The core builder.</param>
133134 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
134- public static IImageSharpBuilder AddProvider < TProvider > ( this IImageSharpBuilder builder )
135+ public static IImageSharpBuilder AddProvider < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TProvider > ( this IImageSharpBuilder builder )
135136 where TProvider : class , IImageProvider
136137 {
137138 builder . Services . TryAddEnumerable ( ServiceDescriptor . Singleton < IImageProvider , TProvider > ( ) ) ;
@@ -161,7 +162,7 @@ public static IImageSharpBuilder AddProvider<TProvider>(this IImageSharpBuilder
161162 /// <param name="builder">The core builder.</param>
162163 /// <param name="index">The zero-based index at which the provider should be inserted.</param>
163164 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
164- public static IImageSharpBuilder InsertProvider < TProvider > ( this IImageSharpBuilder builder , int index )
165+ public static IImageSharpBuilder InsertProvider < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TProvider > ( this IImageSharpBuilder builder , int index )
165166 where TProvider : class , IImageProvider
166167 {
167168 List < ServiceDescriptor > descriptors = builder . Services . Where ( x => x . ServiceType == typeof ( IImageProvider ) ) . ToList ( ) ;
@@ -231,7 +232,7 @@ public static IImageSharpBuilder ClearProviders(this IImageSharpBuilder builder)
231232 /// <typeparam name="T">The type of class implementing <see cref="IImageWebProcessor"/> to add.</typeparam>
232233 /// <param name="builder">The core builder.</param>
233234 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
234- public static IImageSharpBuilder AddProcessor < T > ( this IImageSharpBuilder builder )
235+ public static IImageSharpBuilder AddProcessor < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] T > ( this IImageSharpBuilder builder )
235236 where T : class , IImageWebProcessor
236237 {
237238 builder . Services . TryAddEnumerable ( ServiceDescriptor . Singleton < IImageWebProcessor , T > ( ) ) ;
@@ -290,7 +291,7 @@ public static IImageSharpBuilder ClearProcessors(this IImageSharpBuilder builder
290291 /// <typeparam name="TConverter">The type of class implementing <see cref="ICommandConverter"/> to add.</typeparam>
291292 /// <param name="builder">The core builder.</param>
292293 /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
293- public static IImageSharpBuilder AddConverter < TConverter > ( this IImageSharpBuilder builder )
294+ public static IImageSharpBuilder AddConverter < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . PublicConstructors ) ] TConverter > ( this IImageSharpBuilder builder )
294295 where TConverter : class , ICommandConverter
295296 {
296297 builder . Services . TryAddEnumerable ( ServiceDescriptor . Singleton < ICommandConverter , TConverter > ( ) ) ;
@@ -343,21 +344,6 @@ public static IImageSharpBuilder ClearConverters(this IImageSharpBuilder builder
343344 return builder ;
344345 }
345346
346- /// <summary>
347- /// Registers an action used to configure a particular type of options.
348- /// </summary>
349- /// <typeparam name="TOptions">The options type to be configured.</typeparam>
350- /// <param name="builder">The core builder.</param>
351- /// <param name="config">The configuration being bound.</param>
352- /// <returns>The <see cref="IImageSharpBuilder"/>.</returns>
353- public static IImageSharpBuilder Configure < TOptions > ( this IImageSharpBuilder builder , IConfiguration config )
354- where TOptions : class
355- {
356- builder . Services . Configure < TOptions > ( config ) ;
357-
358- return builder ;
359- }
360-
361347 /// <summary>
362348 /// Registers an action used to configure a particular type of options.
363349 /// </summary>
0 commit comments