Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
more feedback
  • Loading branch information
tarekgh committed Nov 29, 2022
commit e5db199911cd82823623d3b3523eacd59a0a2916
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ private static bool CanBindToTheseConstructorParameters(ParameterInfo[] construc
return dictionary;
}

// Binds and potentially overwrites a concrete dictionary.
// Binds and potentially overwrites a dictionary object.
// This differs from BindDictionaryInterface because this method doesn't clone
// the dictionary; it sets and/or overwrites values directly.
// When a user specifies a concrete dictionary or a concrete class implementing IDictionary<,>
Expand All @@ -563,7 +563,7 @@ private static bool CanBindToTheseConstructorParameters(ParameterInfo[] construc
[RequiresDynamicCode(DynamicCodeWarningMessage)]
[RequiresUnreferencedCode("Cannot statically analyze what the element type is of the value objects in the dictionary so its members may be trimmed.")]
private static void BindDictionary(
object? dictionary,
object dictionary,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)]
Type dictionaryType,
IConfiguration config, BinderOptions options)
Expand Down Expand Up @@ -594,9 +594,9 @@ private static void BindDictionary(


MethodInfo tryGetValue = dictionaryType.GetMethod("TryGetValue", DeclaredOnlyLookup)!;
PropertyInfo? setter = dictionaryType.GetProperty("Item", DeclaredOnlyLookup);
PropertyInfo? indexerProperty = dictionaryType.GetProperty("Item", DeclaredOnlyLookup);

if (setter is null || !setter.CanWrite)
if (indexerProperty is null || !indexerProperty.CanWrite)
{
// Cannot set any item on the dictionary object.
return;
Expand Down Expand Up @@ -624,7 +624,7 @@ private static void BindDictionary(
options: options);
if (valueBindingPoint.HasNewValue)
{
setter.SetValue(dictionary, valueBindingPoint.Value, new object[] { key });
indexerProperty.SetValue(dictionary, valueBindingPoint.Value, new object[] { key });
}
}
catch(Exception ex)
Expand Down