-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix binding types with optional string parameters #93563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix binding types with optional string parameters #93563
Conversation
Ensure the source generator emits the declaration with default value for all cases when we emit the bind logic.
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsFixes #93159 Previously the generator would skip emitting the default in the case the member was ParsableFromStringSpec and AssignFromSectionValue. It should have only done this for the ErrorOnFailedBinding. Most of this PR is an added test to track the code-gen for default parameters.
|
...crosoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.TestClasses.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I added a minor question.
Added a test here. I think I'd like to combine this with #94070 since both impact the source generator's ability to handle optional parameters. |
Need to update this as the baselines are now stale with #94267 merged. |
…binder-default-string-param
* Add a baseline test for constructor parameters * Fix binding types with optional string parameters Ensure the source generator emits the declaration with default value for all cases when we emit the bind logic. * Add a test case that uses a Primary Constructor with default values * Split baseline data for added test. * Fix .NETFramework test baseline * Update baselines after global namespace change # Conflicts:
…4070) * Fix Decimal literal formatting in source generators Both ConfigurationBinder and Json were not handling decimal values correctly. This shares and updates our workaround method for formatting these. * Address feedback * Fix binding types with optional string parameters (#93563) * Add a baseline test for constructor parameters * Fix binding types with optional string parameters Ensure the source generator emits the declaration with default value for all cases when we emit the bind logic. * Add a test case that uses a Primary Constructor with default values * Split baseline data for added test. * Fix .NETFramework test baseline * Update baselines after global namespace change # Conflicts: * Update added baseline after global:: change --------- Co-authored-by: Eric StJohn <ericstj@microsoft.com>
Fixes #93159
Previously the generator would skip emitting the default in the case the member was ParsableFromStringSpec and AssignFromSectionValue. It should have only done this for the ErrorOnFailedBinding.
Most of this PR is an added test to track the code-gen for default parameters.