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

Allow CreateInstanceForAnotherGenericParameter to take multi args #45085

Merged

Conversation

GrabYourPitchforks
Copy link
Member

@GrabYourPitchforks GrabYourPitchforks commented Nov 22, 2020

Based on a comment at https://github.com/dotnet/runtime/pull/32520/files#r451611457. This PR adds another overload to CreateInstanceForAnotherGenericParameter so that the caller can pass 2 parameters instead of just one. I've also hooked it up through ArraySortHelper so that it avoids the call to RuntimeTypeHandle.Allocate. This also allows #32520 to cleanly delete the RuntimeTypeHandle.Allocate method.

Also converts the unmanaged side to a QCALL, because why not.

Alternative design

I could introduce a method that takes params RuntimeType[] genericArgs. If we did this, it should have a defensive copy in order to guard against mutation (see changes in RuntimeTypeHandle.Instantiate, also in this PR). I figured that there wasn't a real need to add this just yet since the simplest thing to do for now was to add the 2-param overload. The unmanaged side is already set up now to take as many parameters as needed, so any future changes here can be fully managed.

@GrabYourPitchforks
Copy link
Member Author

I can back out the commit 5a6682d and send it as another PR if desired. But this PR seemed like a decent place to put it since I was touching those files anyway.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for fixing this.

@GrabYourPitchforks
Copy link
Member Author

Thanks for the review! I'll leave it open for another day or so in case the other reviewers want to chime in.

Copy link
Member

@steveharter steveharter left a comment

Choose a reason for hiding this comment

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

A couple misc questions, but otherwise LGTM

@GrabYourPitchforks GrabYourPitchforks merged commit 3f89665 into dotnet:master Nov 23, 2020
@GrabYourPitchforks GrabYourPitchforks deleted the createinstance_generic branch November 23, 2020 23:53
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2020
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