Fix config source gen with Dictionary with nullable Enum value#115350
Merged
tarekgh merged 3 commits intodotnet:mainfrom May 7, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 |
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs
Outdated
Show resolved
Hide resolved
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
…itter/CoreBindingHelpers.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ericstj
reviewed
May 6, 2025
src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs
Outdated
Show resolved
Hide resolved
ericstj
approved these changes
May 7, 2025
Member
ericstj
left a comment
There was a problem hiding this comment.
LGTM, thanks for considering my feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #115343