Skip to content

Fix config source gen binding with SslClientAuthenticationOptions#107579

Merged
tarekgh merged 2 commits intodotnet:mainfrom
tarekgh:FixConfigSourceGenWithBindingWithSslClientAuthenticationOptions
Sep 11, 2024
Merged

Fix config source gen binding with SslClientAuthenticationOptions#107579
tarekgh merged 2 commits intodotnet:mainfrom
tarekgh:FixConfigSourceGenWithBindingWithSslClientAuthenticationOptions

Conversation

@tarekgh
Copy link
Copy Markdown
Member

@tarekgh tarekgh commented Sep 9, 2024

Fixes #107003

@tarekgh tarekgh added this to the 10.0.0 milestone Sep 9, 2024
@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Sep 9, 2024

This is a candidate to port to 9.0.

CC @ericstj @eerhardt

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
if (!_typeIndex.HasBindableMembers(complexType) &&
!_typeIndex.GetEffectiveTypeSpec(complexType).IsValueType &&
complexType is not CollectionSpec &&
((ObjectSpec)complexType).InstantiationStrategy == ObjectInstantiationStrategy.ParameterizedConstructor)
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.

Can you explain all these conditions? I only understand the first, why the others?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

complexType is not CollectionSpec we have special handling to the collections so we should not change how we do it especially it should work in most cases. look at

for more details.

((ObjectSpec)complexType).InstantiationStrategy == ObjectInstantiationStrategy.ParameterizedConstructor) is needed because if it is different ObjectInstantiationStrategy value means we can still create and handle the object. look at

if (strategy is ObjectInstantiationStrategy.ParameterlessConstructor)
to see that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

_typeIndex.GetEffectiveTypeSpec(complexType).IsValueType can be handled too,

shows what we do with that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was trying to scope the change to exact failure cases to reduce any risk of breaking anything.

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.

I see - I was surprised we'd even get this far with a type that has no bindable members and we're trying to construct with a parameterized constructor. I would have expected us to discover that in parsing and use a different spec type (not supported or something) - why do we miss this in parsing?

Copy link
Copy Markdown
Member Author

@tarekgh tarekgh Sep 11, 2024

Choose a reason for hiding this comment

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

That is because we want use _typeIndex which is created and filled in the emitter. If we want to do the detection earlier, we'll need to do more involving refactoring which will make the change risky for 9.0. Note, the parser fills some data structures which expect to see the type specs supported by _typeIndex later during the emission. so refactoring will not be simple IMO.

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.

I see - given that it seems like the parser isn't even capable of completely deciding which types will be handled. It can only decide which may be handled and we filter further during emit. That feels like something we'd need to fix to address other issues.

@tarekgh tarekgh merged commit c4cc794 into dotnet:main Sep 11, 2024
@tarekgh
Copy link
Copy Markdown
Member Author

tarekgh commented Sep 11, 2024

/backport to release/9.0

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10818391044

jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 17, 2024
…tnet#107579)

* Fix config source gen binding with SslClientAuthenticationOptions

* Apply suggestions from code review

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>

---------

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
sirntar pushed a commit to sirntar/runtime that referenced this pull request Sep 30, 2024
…tnet#107579)

* Fix config source gen binding with SslClientAuthenticationOptions

* Apply suggestions from code review

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>

---------

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2024
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.

Configuration Binder source generator generates uncompilable code for SslClientAuthenticationOptions

3 participants