Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 ghost assigned tarekgh Oct 28, 2022
@tarekgh tarekgh requested a review from eerhardt October 28, 2022 02:12
@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