Skip to content
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

[release/8.0] Handle binding to initialized abstract members #93120

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 6, 2023

Backport of #93090 to release/8.0

/cc @ericstj

Customer Impact

Cannot bind to abstract types when using the ConfigurationBinder source generator.

When binding to types which contain pre-initialized abstract members the ConfigurationBinder source generator will throw an exception, whereas the reflection-based binder will not. The generator also emits a diagnostic in this case.

We keep the diagnostic because the source generator cannot guarantee that the member will be pre-initialized, but the generator will emit code that uses the pre-initialized value for binding if present.
 

Testing

Tested real world application to confirm the fix. Added unit tests to cover new behavior.

Risk

There is still a discrepancy with the runtime binder, which is able to see the runtime type. I've filed #93130 to track that discrepancy. TLDR: we bind against the reference type only and not runtime type.

If an abstract member is encountered in an object graph we should only
throw if it's not already initialized.
@ghost
Copy link

ghost commented Oct 6, 2023

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

Issue Details

Backport of #93090 to release/8.0

/cc @ericstj

Customer Impact

Testing

Risk

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-Extensions-Configuration

Milestone: -

@ericstj
Copy link
Member

ericstj commented Oct 9, 2023

@artl93 can you please have a look?

Copy link
Contributor

@artl93 artl93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M2 approved

@leecow leecow added this to the 8.0.0 milestone Oct 10, 2023
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 10, 2023
@carlossanlop carlossanlop merged commit 2504043 into release/8.0 Oct 12, 2023
106 of 113 checks passed
@carlossanlop carlossanlop deleted the backport/pr-93090-to-release/8.0 branch October 12, 2023 00:06
@ghost ghost locked as resolved and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants