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

[release/7.0] Fix configuration binding with types implementing IDictionary<,> #79019

Merged
merged 2 commits into from
Nov 30, 2022

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented Nov 30, 2022

Fixes #78938

Backport of #78946 to release/7.0

/cc @tarekgh

Customer Impact

This issue is reported by the app-compat runs when running mixcore/mix.core app. The app will throw System.Reflection.AmbiguousMatchException during the configuration binding. This is a regression from the fix #78118 we had in 7.0.1 servicing. This problem occur only if the app is using a type implementing IDictionary<,> and include members with the same names as IDictionary<,> members. Like class indexer this[] or TryGetValue method. When using such class with the configuration, we use the reflection to bind to such class using the type indexer and TryGetValue method. If there is multiple members with the same name, the reflection will throw AmbiguousMatchException.

Testing

I have tested the exact code used to repro the issue with the app-compat run with referencing the packages Quartz.AspNetCore v3.3.3 and Quartz.Extensions.DependencyInjection v3.3.3 which causing the problem. I have run all our tests against the fix which is covering all cases we fixed before to ensure no other regressions. Also, I have added extra test to catch the issue we are fixing here.

Risk

Medium, touching configuration code comes with some risk but I tried my best testing the change to ensure will not cause any other regressions.

@ghost
Copy link

ghost commented Nov 30, 2022

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

Issue Details

Backport of #78946 to release/7.0

/cc @tarekgh

Customer Impact

This issue is reported by the app-compat runs when running mixcore/mix.core app. The app will throw System.Reflection.AmbiguousMatchException during the configuration binding. This is a regression from the fix #78118 we had in 7.0.1 servicing. This problem occur only if the app is using a type implementing IDictionary<,> and include members with the same names as IDictionary<,> members. Like class indexer this[] or TryGetValue method. When using such class with the configuration, we use the reflection to bind to such class using the type indexer and TryGetValue method. If there is multiple members with the same name, the reflection will throw AmbiguousMatchException.

Testing

I have tested the exact code used to repro the issue with the app-compat run with referencing the packages Quartz.AspNetCore v3.3.3 and Quartz.Extensions.DependencyInjection v3.3.3 which causing the problem. I have run all our tests against the fix which is covering all cases we fixed before to ensure no other regressions. Also, I have added extra test to catch the issue we are fixing here.

Risk

Medium, touching configuration code comes with some risk but I tried my best testing the change to ensure will not cause any other regressions.

Author: tarekgh
Assignees: -
Labels:

area-Extensions-Configuration

Milestone: -

@tarekgh tarekgh added this to the 7.0.x milestone Nov 30, 2022
@tarekgh tarekgh added the Servicing-consider Issue for next servicing release review label Nov 30, 2022
@carlossanlop
Copy link
Member

It's missing the OOB package authoring changes. I'll add them.

@carlossanlop carlossanlop modified the milestones: 7.0.x, 7.0.2 Nov 30, 2022
@tarekgh
Copy link
Member Author

tarekgh commented Nov 30, 2022

Thanks @carlossanlop for adding OOB authoring change.

@tarekgh tarekgh added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 30, 2022
@tarekgh
Copy link
Member Author

tarekgh commented Nov 30, 2022

This is approved offline by the email.

@carlossanlop
Copy link
Member

runtime-staging not required, and passed in the previous run.
The only CI failure is known and unrelated #78778

@carlossanlop carlossanlop merged commit 30426a7 into dotnet:release/7.0 Nov 30, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants