You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate List<T> items when binding class with default constructor containing params keyword to IConfiguration #129760
Reading JSON configuration file (appsettings.json) and binding it to a class with default constructor containing params keyword using ConfigurationBinder.Get<T> results in a duplicate list items.
Reproduction Steps
Create a class with default constructor containing params keyword and a getter only List field that has the value from default constructor assigned
varerpConfig=configuration.GetSection(ErpConfigurationOptions.SectionName).Get<ErpConfigurationOptions>()??thrownewInvalidOperationException("ERP configuration is missing.");
The root cause is in the reflection based configuration binder. When a type is created through a constructor and the constructor parameter name differs only by case from a collection property (for example a parameter instances and a property Instances), the binder bound the property a second time in addition to the constructor, which appended the items again and produced the duplicates. The rest of the binder matches constructor parameters and properties case-insensitively, so this was an inconsistency in one comparison.
Activity
dotnet-policy-service commentedon Jun 23, 2026
Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.
MihuBot commentedon Jun 23, 2026
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
tarekgh commentedon Jun 23, 2026
Thanks for reporting this.
The root cause is in the reflection based configuration binder. When a type is created through a constructor and the constructor parameter name differs only by case from a collection property (for example a parameter
instancesand a propertyInstances), the binder bound the property a second time in addition to the constructor, which appended the items again and produced the duplicates. The rest of the binder matches constructor parameters and properties case-insensitively, so this was an inconsistency in one comparison.Plan:
paramscollection constructor). This issue will be closed when that PR is merged.Fix duplicated collection items when a constructor parameter name dif…
Fix duplicated collection items when a constructor parameter name dif…