@@ -327,7 +327,7 @@ static void CallConfigurationMethods(ILookup<string, Dictionary<string, IConfigu
327
327
if ( methodInfo != null )
328
328
{
329
329
var call = ( from p in methodInfo . GetParameters ( ) . Skip ( 1 )
330
- let directive = method . Value . FirstOrDefault ( s => s . Key == p . Name )
330
+ let directive = method . Value . FirstOrDefault ( s => s . Key . Equals ( p . Name , StringComparison . OrdinalIgnoreCase ) )
331
331
select directive . Key == null ? p . DefaultValue : directive . Value . ConvertTo ( p . ParameterType , declaredLevelSwitches ) ) . ToList ( ) ;
332
332
333
333
var parm = methodInfo . GetParameters ( ) . FirstOrDefault ( i => i . ParameterType == typeof ( IConfiguration ) ) ;
@@ -342,10 +342,15 @@ static void CallConfigurationMethods(ILookup<string, Dictionary<string, IConfigu
342
342
343
343
internal static MethodInfo SelectConfigurationMethod ( IEnumerable < MethodInfo > candidateMethods , string name , Dictionary < string , IConfigurationArgumentValue > suppliedArgumentValues )
344
344
{
345
+ // Per issue #111, it is safe to use case-insensitive matching on argument names. The CLR doesn't permit this type
346
+ // of overloading, and the Microsoft.Extensions.Configuration keys are case-insensitive (case is preserved with some
347
+ // config sources, but key-matching is case-insensitive and case-preservation does not appear to be guaranteed).
345
348
return candidateMethods
346
349
. Where ( m => m . Name == name &&
347
- m . GetParameters ( ) . Skip ( 1 ) . All ( p => p . HasDefaultValue || suppliedArgumentValues . Any ( s => s . Key == p . Name ) ) )
348
- . OrderByDescending ( m => m . GetParameters ( ) . Count ( p => suppliedArgumentValues . Any ( s => s . Key == p . Name ) ) )
350
+ m . GetParameters ( ) . Skip ( 1 )
351
+ . All ( p => p . HasDefaultValue || suppliedArgumentValues . Any ( s => s . Key . Equals ( p . Name , StringComparison . OrdinalIgnoreCase ) ) ) )
352
+ . OrderByDescending ( m =>
353
+ m . GetParameters ( ) . Count ( p => suppliedArgumentValues . Any ( s => s . Key . Equals ( p . Name , StringComparison . OrdinalIgnoreCase ) ) ) )
349
354
. FirstOrDefault ( ) ;
350
355
}
351
356
0 commit comments