Skip to content

Clarify how configuration binder binds types - #55762

Open
svick wants to merge 1 commit into
mainfrom
configuration-binder-types
Open

Clarify how configuration binder binds types#55762
svick wants to merge 1 commit into
mainfrom
configuration-binder-types

Conversation

@svick

@svick svick commented Aug 27, 2026

Copy link
Copy Markdown
Member

The old list was incomplete and inaccurate (especially for the source generator binder).

The new list should be accurate and complete, without going into too much detail (it's probably not useful to explicitly list the types supported by the source generator binder here).


Internal previews

File Preview link
docs/core/extensions/configuration.md Learn preview

Build report

@svick
svick requested review from mrek-msft and rosebyte and a lite review from Copilot August 27, 2026 15:44
@svick
svick requested review from a team and gewarren as code owners August 27, 2026 15:44
@dotnetrepoman dotnetrepoman Bot added this to the August 2026 milestone Aug 27, 2026

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

Updates the Binding section in configuration.md to replace an incomplete/inaccurate list with a clearer, more complete summary of how the configuration binder binds different target shapes and types (including a note about a source-generator limitation).

Changes:

  • Replaces the prior high-level binder “approaches” list with a more concrete set of binding behaviors (scalar conversion, hierarchical binding, collection binding, section passthrough, and custom conversion).
  • Adds an explicit note that TypeConverter-based custom conversions aren’t supported by the source generator binder.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +78 to +82
- Use a single configuration value directly for a `string` or `object` target, or convert it to a common .NET type, such as a numeric type, an enumeration, or a nullable type. The binder converts a Base64-encoded string to a byte array.
- Bind hierarchical configuration to an object's properties or constructor parameters.
- Bind child configuration sections to arrays, collections, sets, and dictionaries.
- Use the matching configuration section directly when the target type is <xref:Microsoft.Extensions.Configuration.IConfigurationSection>.
- Convert a single configuration value to a custom type. The default binder uses a <xref:System.ComponentModel.TypeConverter> when the custom type defines one. The source generator binder doesn't support this.

@rosebyte rosebyte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot has a good point with the ...s suffixes, otherwise LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants