Prefer most derived member in Configuration Binder source generator#101316
Prefer most derived member in Configuration Binder source generator#101316ericstj merged 2 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
...libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.cs
Outdated
Show resolved
Hide resolved
eerhardt
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the quick fix here!
Do you think this could be backported to 8.0.x?
...raries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs
Outdated
Show resolved
Hide resolved
eiriktsarpalis
left a comment
There was a problem hiding this comment.
Per #101316 (review) I suspect that this might be introducing a slight regression.
Given that this is a likely candidate for backporting, it might make sense to investigate further.
|
I'll add a test case for an override that only overrides the Getter. We did have a test for the case where a |
|
Seems we still have a failure of the Reflection binder: @eerhardt -- does that sound right? That seems to indicate that #101273 might be broken even without the source generator. |
|
Interesting: the reflection binder has a different heuristic. It never does any resolution by name, but builds a list in order from derived to base. So it will set both the hidden and non-hidden members through reflection, using the same configuration data. That's unusual behavior - but we could replicate it if we casted the LHS in the source generator to the base type. |
|
@ericstj I think we need to keep the runtime behavior for consistency. Even if it looks unusual behavior but seems not many people complained about it. |
See my comment on #101273 (comment). For the case I hit the issue, the base enum is a superset of the derived enum. The derived class is trying to limit which values can be set. |
Do we want to? Are there tests validating this behavior? |
|
I'm not planning to change the reflection binder's behavior in this PR. Nor am I planning to change the source generator to bind many different propreties like the reflection binder does. I'm inclined to more closely match the reflection-binder's selection algorithm for finding the most-derived property. I think that will be the minimal change while unblocking @eerhardt. I'm running some tests and will make a new change to this PR shortly. |
|
Failures are known issues and don't block build or testing. |
|
/backport to release/8.0-staging |
|
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/8881506956 |
…otnet#101316) * Prefer most derived member in Configuration Binder source generator * Skip overridden properties in config source generator - include only definitions
…otnet#101316) * Prefer most derived member in Configuration Binder source generator * Skip overridden properties in config source generator - include only definitions
…otnet#101316) * Prefer most derived member in Configuration Binder source generator * Skip overridden properties in config source generator - include only definitions
Fix #101267 #101273
CC @eerhardt