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
Address the feedback
  • Loading branch information
tarekgh committed Jan 11, 2023
commit 5c3c6fa645168d68d1b91bbb4550659695aa361f
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ private static void BindProperty(PropertyInfo property, object instance, IConfig
config.GetSection(GetPropertyName(property)),
options);

if (propertyBindingPoint.HasNewValue)
// For property binding, there are some cases when HasNewValue is not set in BindingPoint while a non-null Value inside that object can be retrieved from the property getter.
// As example, when binding a property which not having a configuration entry matching this property and the getter can initialize the Value.
// It is important to call the property setter as the setters can have a logic adjusting the Value.
if (!propertyBindingPoint.IsReadOnly && propertyBindingPoint.Value is not null)
{
property.SetValue(instance, propertyBindingPoint.Value);
}
Expand Down Expand Up @@ -384,14 +387,6 @@ private static void BindInstance(
}
}
}

if (!bindingPoint.HasNewValue && !bindingPoint.IsReadOnly && bindingPoint.Value is not null)
{
// For property binding, there are some cases when HasNewValue is not set in BindingPoint while a non-null Value inside that object can be retrieved
// from the property getter. As example, when binding a property which not having a configuration entry matching this property and the getter can initialize the Value.
// It is important to set the HasNewValue to true at this time to force the property setter to run. The reason is the setters can have a logic adjusting the Value.
bindingPoint.SetValue(bindingPoint.Value);
}
}

[RequiresDynamicCode(DynamicCodeWarningMessage)]
Expand Down