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 Binding with IDictionary<,> implementer types #77582

Merged
merged 3 commits into from
Oct 30, 2022

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented Oct 28, 2022

Fixes #77246

In .NET 7.0 we have done some refactoring work in the configuration binding code #68133. The refactored code work fine when binding to IDictionary<,> interface or Dictionary<,> based class but it broke the case when using a type which implementing IDictionary<,> interface. The new code was always creating Dictionary<,> type and then getting the setter of the Item property from that type. But the object used in the binding is not of type Dictionary<,> at all and the property setter fails because it is used with wrong type.

@ghost
Copy link

ghost commented Oct 28, 2022

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

Issue Details

Fixes #77246

In .NET 7.0 we have done some refactoring work in the configuration binding code #68133. The refactored code work fine when binding to IDictionary<,> interface or Dictionary<,> based class but it broke the case when using a type which implementing IDictionary<,> interface. The new code was always creating Dictionary<,> type and then getting the setter of the Item property from that type. But the object used in the binding is not of type Dictionary<,> at all and the property setter fails because it is used with wrong type.

Author: tarekgh
Assignees: -
Labels:

area-Extensions-Configuration

Milestone: -

@tarekgh
Copy link
Member Author

tarekgh commented Oct 28, 2022

CC @SteveDunn

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 - sorry I didn't address the issue myself but I'm a bit busy in my day job right now.

@tarekgh tarekgh merged commit e6700ea into dotnet:main Oct 30, 2022
@tarekgh tarekgh deleted the FixConfigurationBindingWithDictionary branch October 30, 2022 17:36
@tarekgh
Copy link
Member Author

tarekgh commented Nov 9, 2022

/backport to release/7.0

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

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

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2022
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.

ConfigurationBinder fails to bind class that implements IDictionary
4 participants