Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Configuration Binder source generator’s type-graph construction so it doesn’t report SYSLIB1100/SYSLIB1101 for property types that the generated binder will never bind (e.g., ignored or non-public properties), and updates the binding eligibility check to avoid resolving type specs for excluded members.
Changes:
- Update
CreateObjectSpecto enqueue transitive property types only for properties that can participate in binding (with a carve-out for properties backing constructor parameters). - Short-circuit
TypeIndex.ShouldBindToon ignore/accessibility before resolving the property’s effective type spec. - Add regression tests covering ignored/non-public properties and constructor-parameter-backed properties.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs | Adds regression tests ensuring excluded properties don’t trigger diagnostics, while still reporting when the type is reachable via a bindable property or ctor parameter. |
| src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/TypeIndex.cs | Avoids type resolution for ignored/inaccessible properties by short-circuiting earlier in ShouldBindTo. |
| src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs | Defers/enables transitive type enqueueing only for bind-participating properties and ctor-parameter-backed properties. |
|
/backport to release/11.0-rc1 Note This backport request was generated with GitHub Copilot. |
|
Started backporting to |
|
/backport to release/11.0 |
|
Started backporting to |
…ies (#132783) Backport of #132455 to release/11.0 /cc @rosebyte ## Customer Impact - [x] Customer reported - [ ] Found internally Customers using Configuration Binder source generation in .NET 11 can receive false `SYSLIB1100` or `SYSLIB1101` diagnostics when a configuration type contains a property that cannot participate in binding, including a property marked `[ConfigurationIgnore]` or one without a public accessor. This can fail builds that treat warnings as errors, even though the generated binder behaves correctly at run time. This was reported in #132377. ## Regression - [ ] Yes - [x] No The source generator has always evaluated unsupported property types before filtering properties that cannot participate in binding. The `[ConfigurationIgnore]` case has existed since the attribute was introduced in #126396 as new .NET 11 functionality. ## Testing Source-generation tests cover private, internal, protected, and `[ConfigurationIgnore]` properties. Additional tests verify that unsupported types still produce diagnostics when reached through a bindable property or constructor parameter. The original change in #132455 passed its required checks before being merged into `main`. ## Risk Low. The change is limited to source-generator type indexing and diagnostic eligibility. Run-time binding behaviour and public APIs are unchanged. The filtering follows the existing binding rules, while tests ensure diagnostics remain for types that are actually reachable by generated binding. Co-authored-by: Jaroslav Ruzicka <14963300+rosebyte@users.noreply.github.com> Co-authored-by: rosebyte <jaroslav.ruzicka@hotmail.com>
Fixes #132377.
Problem
The configuration binder source generator reports
SYSLIB1101("Property 'X' on type 'Y' is not supported.") andSYSLIB1100at theBind/Getcall site for properties the generated binder never binds:[ConfigurationIgnore]Root cause
CreateObjectSpecqueued every property's type viaEnqueueTransitiveType, passing thePropertyNotSupporteddescriptor, beforeisIgnoredwas computed and without consulting accessibility. When that type was later found unbindable, the attached diagnostic info was reported against the property. Both checks were only honoured later, at emit time, inTypeIndex.ShouldBindTo.Fix
Build the
PropertySpecfirst, then enqueue its type only when the property can take part in binding. A property backing a constructor parameter is still registered, since those are bound regardless of the accessibility of the property describing them.ShouldBindTonow short-circuits on the ignore flag and accessibility before resolving the type spec, because excluded types are no longer in the index.