Skip to content

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

Merged
merged 9 commits into from
Nov 6, 2023

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Oct 16, 2023

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.

Ensure the source generator emits the declaration with default value for
all cases when we emit the bind logic.
@ghost
Copy link

ghost commented Oct 16, 2023

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

Issue Details

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.

Author: ericstj
Assignees: ericstj
Labels:

area-Extensions-Configuration

Milestone: -

Copy link
Member

@tarekgh tarekgh left a 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.

@ericstj
Copy link
Member Author

ericstj commented Oct 27, 2023

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.

@ericstj
Copy link
Member Author

ericstj commented Nov 2, 2023

Need to update this as the baselines are now stale with #94267 merged.

@ericstj ericstj added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Nov 2, 2023
@ericstj ericstj removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Nov 6, 2023
@ericstj ericstj merged commit cf47d9f into dotnet:main Nov 6, 2023
@eiriktsarpalis eiriktsarpalis deleted the config-binder-default-string-param branch November 6, 2023 16:31
ericstj added a commit that referenced this pull request Nov 7, 2023
* 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:
ericstj added a commit that referenced this pull request Nov 8, 2023
…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>
@ghost ghost locked as resolved and limited conversation to collaborators Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants