Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Implement Delegate.DynamicInvoke - #1460

Merged
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:dynamicInvoke
Jul 7, 2016
Merged

MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:dynamicInvoke

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

This has three logical parts (separated in three commits):

  • Implement InvokeUtils intrinsics. This is a general purpose dynamic invoke support class used by Delegate.DynamicInvoke, MethodInfo.Invoke, and the calling convention converter (not in the repo yet)
  • Implement the dynamic invocation delegate thunk
  • Add tests

I had to make the DynamicInvokeParamHelper intrinsic a StubMethod
because the declaration of the intrinsic can't be expressed in C#
(needs ByRef returns). This can be converted to a real intrinsic
when we switch to C# 7. .NET Native for UWP does IL rewriting
to make the return type match.

else
{
// This is in an else branch for a reason:
// Not treating e.g. void*& as IntPtr& is intentinal.

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.

typo: intentional

These intrinsics support functionality in:

* Delegate.DynamicInvoke
* MethodInfo.Invoke
* Calling convention converter

I had to make the DynamicInvokeParamHelper intrinsic a StubMethod
because the declaration of the intrinsic can't be expressed in C#
(needs ByRef returns). This can be converted to a real intrinsic
when we switch to C# 7.

.NET Native for UWP does IL rewriting to make the return type match.
This is implemented with a new thunk that calls into InvokeUtils
intrinsics to set up the callsite, unbox arguments, and replace default
values in the signature.

I'm not implementing the LoadDefaultValueString() override, so default
value in the delegate signature are not supported yet. This code is
undergoing changes on the TFS side right now.
@MichalStrehovsky
MichalStrehovsky merged commit 02f1c01 into dotnet:master Jul 7, 2016
@MichalStrehovsky
MichalStrehovsky deleted the dynamicInvoke branch July 7, 2016 17:26
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