Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix config source gen with Dictionary with nullable Enum value - #115350

#115350
Merged
tarekgh merged 3 commits into
dotnet:maindotnet/runtime:mainfrom
tarekgh:FixConfigSourceGenWithDictionaryWithNullableEnumValuetarekgh/runtime:FixConfigSourceGenWithDictionaryWithNullableEnumValueCopy head branch name to clipboard
May 7, 2025
Merged

Fix config source gen with Dictionary with nullable Enum value#115350
tarekgh merged 3 commits into
dotnet:maindotnet/runtime:mainfrom
tarekgh:FixConfigSourceGenWithDictionaryWithNullableEnumValuetarekgh/runtime:FixConfigSourceGenWithDictionaryWithNullableEnumValueCopy head branch name to clipboard

Conversation

@tarekgh

@tarekgh tarekgh commented May 6, 2025

Copy link
Copy Markdown
Member

Fixes #115343

Copilot AI review requested due to automatic review settings May 6, 2025 23:08
@tarekgh tarekgh added this to the 10.0.0 milestone May 6, 2025

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 addresses the issue with configuration source generation for dictionaries that have nullable enum values. The changes include adding a new test to verify this behavior, introducing supporting test classes and enums, and updating the code generation logic to unwrap nullable types correctly.

  • Added new test case in ConfigurationBinderTests.cs to verify dictionary binding with nullable enum values
  • Introduced OptionsWithDictionaryWithNullableEnumValue and MyValue enum in the test classes
  • Modified CoreBindingHelpers.cs to unwrap NullableSpec for dictionary element types

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/Common/ConfigurationBinderTests.cs Added test for dictionary binding with nullable enum values
src/libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.TestClasses.cs Added supporting test classes and enum for nullable enum dictionary values
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs Updated to unwrap nullable types for proper binding

@tarekgh tarekgh added the source-generator Indicates an issue with a source generator feature label May 6, 2025
@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.

…itter/CoreBindingHelpers.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tarekgh
tarekgh requested a review from ericstj May 6, 2025 23:16

@ericstj ericstj 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.

LGTM, thanks for considering my feedback

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

Labels

area-Extensions-Configuration source-generator Indicates an issue with a source generator feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration-binding source generator doesn't bind Dictionary<string, Enum?>

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.