@@ -30,7 +30,7 @@ public static class ConfigurationBinder
3030 /// <returns>The new instance of T if successful, default(T) otherwise.</returns>
3131 [ RequiresUnreferencedCode ( TrimmingWarningMessage ) ]
3232 public static T ? Get < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . All ) ] T > ( this IConfiguration configuration )
33- => configuration . Get < T > ( null ) ;
33+ => configuration . Get < T > ( _ => { } ) ;
3434
3535 /// <summary>
3636 /// Attempts to bind the configuration instance to a new instance of type T.
@@ -42,12 +42,16 @@ public static class ConfigurationBinder
4242 /// <param name="configureOptions">Configures the binder options.</param>
4343 /// <returns>The new instance of T if successful, default(T) otherwise.</returns>
4444 [ RequiresUnreferencedCode ( TrimmingWarningMessage ) ]
45- public static T ? Get < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . All ) ] T > ( this IConfiguration configuration , Action < BinderOptions > ? configureOptions )
45+ public static T ? Get < [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . All ) ] T > ( this IConfiguration configuration , Action < BinderOptions > configureOptions )
4646 {
4747 if ( configuration == null )
4848 {
4949 throw new ArgumentNullException ( nameof ( configuration ) ) ;
5050 }
51+ if ( configureOptions is null )
52+ {
53+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
54+ }
5155
5256 object ? result = configuration . Get ( typeof ( T ) , configureOptions ) ;
5357 if ( result == null )
@@ -67,7 +71,7 @@ public static class ConfigurationBinder
6771 /// <returns>The new instance if successful, null otherwise.</returns>
6872 [ RequiresUnreferencedCode ( TrimmingWarningMessage ) ]
6973 public static object ? Get ( this IConfiguration configuration , Type type )
70- => configuration . Get ( type , null ) ;
74+ => configuration . Get ( type , _ => { } ) ;
7175
7276 /// <summary>
7377 /// Attempts to bind the configuration instance to a new instance of type T.
@@ -83,15 +87,15 @@ public static class ConfigurationBinder
8387 this IConfiguration configuration ,
8488 [ DynamicallyAccessedMembers ( DynamicallyAccessedMemberTypes . All ) ]
8589 Type type ,
86- Action < BinderOptions > ? configureOptions )
90+ Action < BinderOptions > configureOptions )
8791 {
8892 if ( configuration == null )
8993 {
9094 throw new ArgumentNullException ( nameof ( configuration ) ) ;
9195 }
9296
9397 var options = new BinderOptions ( ) ;
94- configureOptions ? . Invoke ( options ) ;
98+ configureOptions ( options ) ;
9599 return BindInstance ( type , instance : null , config : configuration , options : options ) ;
96100 }
97101
0 commit comments