Skip to content
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

Fix configuration binding with types implementing IDictionary<,> #78946

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented Nov 29, 2022

The configuration binder already working with the types which implement IDictionary<,>. The problem happens when such types include members with the same names as the members of IDictionary<,>. At that time will throw AmbiguousMatchException.

#78938

@ghost
Copy link

ghost commented Nov 29, 2022

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

Issue Details

The configuration binder already working with the types which implement IDictionary<,>. The problem happens when such types include members with the same names as the members of IDictionary<,>. At that time will throw AmbiguousMatchException.

Author: tarekgh
Assignees: tarekgh
Labels:

area-Extensions-Configuration

Milestone: -

Copy link
Contributor

@SteveDunn SteveDunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM.

I just have some nits on existing code now that this has been tweaked.

@halter73
Copy link
Member

Can we add a test case to ensure a non-settable custom IReadOnlyDictionary implementation gets skipped over?

@tarekgh
Copy link
Member Author

tarekgh commented Nov 30, 2022

CI failure is unrelated. merging it.

@tarekgh tarekgh merged commit 0be32a0 into dotnet:main Nov 30, 2022
@tarekgh
Copy link
Member Author

tarekgh commented Nov 30, 2022

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3579305346

@github-actions
Copy link
Contributor

@tarekgh backporting to release/7.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix configuration binding with types implementing IDictionary
Applying: Apply suggestions from code review
Applying: Address the feedback
Applying: more feedback
error: sha1 information is lacking or useless (src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0004 more feedback
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@tarekgh an error occurred while backporting to release/7.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants