-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Preserve existing keys in dictionary #63834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve existing keys in dictionary #63834
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsAt the moment, binding to dictionary has two different behaviors depending on the nesting level.
This PR attempts to correct this inconsistent behavior and use the first approach as baseline.
|
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Outdated
Show resolved
Hide resolved
...aries/Microsoft.Extensions.Configuration.Binder/tests/ConfigurationCollectionBindingTests.cs
Show resolved
Hide resolved
Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
|
@eerhardt Thanks for review. I've added a unit test for a dictionary with an enum as key type |
eerhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me. Thanks for the contribution!
@maryamariyan - any thoughts?
|
OSX Failure is the same listed in #63439 (comment). |
|
There's a conflict on the ConfigurationBinder file left to resolve. I think happened after merging your other PR. Since Microsoft.Extensions.Configuration is widely used we're always very careful with taking risk on fixing/changing behaviors in it in case there are clients who already rely on the existing behavior, even if it is not correct. For the very least we'd need to document the breaking change. @mapogolions do you see any use cases where we'd have regressing behavior after taking in this change? Good thing at least seems no existing tests had to change cc @HaoK |
|
@maryamariyan |
maryamariyan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from the merge conflict that needs to be resolved
|
Failure is unrelated. Merging. |
At the moment, binding to dictionary has two different behaviors depending on the nesting level.
Behaviour 1 - add | override | preserve. Please follow the links below for each case
add new & preserve existing keys
override existing keys
Behaviour 2 - skip all existing keys & add new
Meaning that new keys from a configuration will be picked up, but already existing dropped
Please see the commit that reproduces the issue and shows in which cases this happens.
This PR attempts to correct this inconsistent behavior and use the first approach as baseline.