[API Proposal]: Reflection invoke support for FunctionPointer #75347
Labels
api-needs-work
API needs work before it is approved, it is NOT ready for implementation
area-System.Reflection
Cost:M
Work that requires one engineer up to 2 weeks
Milestone
[primarily a placeholder for now for planning]
This adds invoke capability to function pointers, layering on See also #69273.
This will likely create a new
MethodSignature
class that will have anInvoke()
method, analogous to Delegate.DynamicInvoke(https://docs.microsoft.com/dotnet/api/system.delegate.dynamicinvoke) and MethodBase.Invoke(https://docs.microsoft.com/dotnet/api/system.reflection.methodbase.invoke).This enable dynamic invoke while supporting the
CallConv*
types for both existing function pointers and ones created dynamically.Existing function pointers are be obtained from
typeof(SomeFunctionPointer)
Type.GetType()
ifType
is a function pointerFieldInfo.GetMethodSignature()
PropertyInfo.GetMethodSignature()
ParameterInfo.GetMethodSignature()
A
MethodSignature
can be created dynamically:The
Invoke()
takes the function pointer as anIntPtr
orvoid*
along with the parameter values:note that the sample below uses
object
-based parameters, but is expected to use strongly-typedTypedReference
and collections once that is available to avoid unnecessary allocations and to support by-ref-like types`:The text was updated successfully, but these errors were encountered: