Skip to content

Add support for types with parameterized ctors to config binder gen#86365

Merged
layomia merged 3 commits into
dotnet:mainfrom
layomia:binder-gen-ctors
May 26, 2023
Merged

Add support for types with parameterized ctors to config binder gen#86365
layomia merged 3 commits into
dotnet:mainfrom
layomia:binder-gen-ctors

Conversation

@layomia

@layomia layomia commented May 17, 2023

Copy link
Copy Markdown
Contributor

This PR adds support for config types that are bound using parameterized ctors, required properties, and/or init-only properties.

@layomia layomia added this to the 8.0.0 milestone May 17, 2023
@layomia layomia self-assigned this May 17, 2023
@ghost

ghost commented May 17, 2023

Copy link
Copy Markdown

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

Issue Details

This PR adds initial support for config types that are bound using parameterized ctors, required properties, and/or init-only properties.

Needs a follow up to

  • sync exception handling and property-parameter matching with reflection implementation. Right now, partial binding may be done if properties & parameters do not match perfectly (but there are no compilation issues given the project tests).
  • issue diagnostic warnings where appropriate
Author: layomia
Assignees: layomia
Labels:

area-Extensions-Configuration

Milestone: 8.0.0

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

Added a couple of comments please address them before merging.

@layomia
layomia force-pushed the binder-gen-ctors branch 2 times, most recently from 8640d25 to 6cd9bf7 Compare May 17, 2023 21:29
@layomia
layomia marked this pull request as draft May 17, 2023 22:57
@layomia

layomia commented May 17, 2023

Copy link
Copy Markdown
Contributor Author

Will request review again after addressing #86365 (comment).

@layomia
layomia force-pushed the binder-gen-ctors branch 2 times, most recently from b5bf629 to 3b4c0b6 Compare May 25, 2023 11:33
@layomia
layomia force-pushed the binder-gen-ctors branch from 3b4c0b6 to 3fd46fd Compare May 25, 2023 11:36
@layomia
layomia requested a review from tarekgh May 25, 2023 11:43
@layomia
layomia requested a review from eiriktsarpalis May 25, 2023 11:43
@layomia
layomia marked this pull request as ready for review May 25, 2023 11:43
@layomia

layomia commented May 25, 2023

Copy link
Copy Markdown
Contributor Author

Implementation is now in sync with reflection; including exception handling, parameter-property binding... PTAL.

@tarekgh

tarekgh commented May 25, 2023

Copy link
Copy Markdown
Member
    public void ExceptionWhenTryingToBindClassWithoutParameterlessConstructor()

this test cannot be enabled for source gen now?


Refers to: src/libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.cs:907 in 3fd46fd. [](commit_id = 3fd46fd, deletion_comment = False)

@layomia

layomia commented May 25, 2023

Copy link
Copy Markdown
Contributor Author
    public void ExceptionWhenTryingToBindClassWithoutParameterlessConstructor()

this test cannot be enabled for source gen now?

Refers to: src/libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.cs:907 in 3fd46fd. [](commit_id = 3fd46fd, deletion_comment = False)

Missed that, thanks. It passes.

@layomia
layomia merged commit 93c8be6 into dotnet:main May 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jun 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants