Skip to content

Don't report unsupported types for never bound properties - #132455

Merged
rosebyte merged 4 commits into
dotnet:mainfrom
rosebyte:rosebyte-config-binder-ignore-unbindable-property
Aug 21, 2026
Merged

rosebyte merged 4 commits into
dotnet:mainfrom
rosebyte:rosebyte-config-binder-ignore-unbindable-property

Conversation

@rosebyte

Copy link
Copy Markdown
Member

Fixes #132377.

Problem

The configuration binder source generator reports SYSLIB1101 ("Property 'X' on type 'Y' is not supported.") and SYSLIB1100 at the Bind/Get call site for properties the generated binder never binds:

  • properties annotated with [ConfigurationIgnore]
  • properties with no public accessor

Root cause

CreateObjectSpec queued every property's type via EnqueueTransitiveType, passing the PropertyNotSupported descriptor, before isIgnored was 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, in TypeIndex.ShouldBindTo.

Fix

Build the PropertySpec first, 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.

ShouldBindTo now short-circuits on the ignore flag and accessibility before resolving the type spec, because excluded types are no longer in the index.

Copilot AI lite review requested due to automatic review settings August 18, 2026 07:54
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CreateObjectSpec to enqueue transitive property types only for properties that can participate in binding (with a carve-out for properties backing constructor parameters).
  • Short-circuit TypeIndex.ShouldBindTo on 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.

Copilot AI review requested due to automatic review settings August 18, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 21, 2026 09:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@rosebyte
rosebyte merged commit 597c07c into dotnet:main Aug 21, 2026
78 checks passed
@rosebyte

Copy link
Copy Markdown
Member Author

/backport to release/11.0-rc1

Note

This backport request was generated with GitHub Copilot.

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-rc1 (link to workflow run)

@rosebyte

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

mrek-msft pushed a commit that referenced this pull request Sep 3, 2026
…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>
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SYSLIB1101 being emitted inappropriately for configuration binder in 11.0.0-preview.7.26381.103

3 participants