[release/9.0-rc1] Fallback to treating as object if not collection #106517
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.
Backport of #106378 to release/9.0-rc1
/cc @ericstj
Customer Impact
Configuration Binder source generator cannot bind objects that implement
IEnumerable
but notICollection<>
orIDictionary<,>
. IOW an enumerable type that's not treated as a collection.Apache Kafka has a package with configuration objects like this that expose their strongly named properties as an
IEnumerable<KeyValuePair<string,string>>
: https://github.com/confluentinc/confluent-kafka-dotnet/blob/49f8188eeff4e6a77f9c1bcef68c504e773359f6/src/Confluent.Kafka/Config.cs#L28This type binds fine with the reflection binder, but fails when using the source generator.
Regression
Not a regression, but a blocker for folks wanting to enable the source generator / aot.
Testing
Unit tests added, baseline tests evaluated. No regressions, no changes to existing emitted code. New scenarios added to cover these types. Customer type validated fixed with the change.
Risk
Medium - it's enabling binding of types that were previously considered "not supported". This shouldn't break existing successful usage, but it could cause problems when we start to see types we didn't see before. For this reason we'd like to get this out in RC1 and give a chance for customer feedback.
Risk to release is low. This shouldn't risk the RC1 build / stabilization.