[release/7.0] Fix Configuration Binding with Instantiated Objects #81250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #79766
Backport of #81050 to release/7.0
/cc @tarekgh
Customer Impact
When apps/services bind a configuration to a collection which is created with specific behavior (like storing elements with ignore casing to avoid duplicate items differ only in casing), the configuration binder replaces this created collection with a newly created one which not necessarily have same behavior (ignore casing). This causes the apps ends up with a collection containing a list of unexpected items which causes failures to the apps as the app getting unexpected collection elements.
This is a regression from .NET 6.0.
Testing
Done manual tests with all different types of collections. The changes passed all regression tests. Also, more tests are added for the cases we are fixing.
Risk
Medium, I scoped the changes as much as I could while ensuring I addressed the issues we are trying to fix.
IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.