Skip to content

Conversation

tarekgh
Copy link
Member

@tarekgh tarekgh commented May 6, 2025

Fixes #115343

@Copilot 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
Copy link
Contributor

@Copilot Copilot AI left a comment

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
Copy link
Contributor

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

@tarekgh tarekgh requested a review from ericstj May 6, 2025 23:16
Copy link
Member

@ericstj ericstj left a comment

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

@tarekgh tarekgh merged commit d94bcbd into dotnet:main May 7, 2025
82 of 85 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2025
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?>
2 participants