F# 中 function/delegate 的 ConstructorInfo

ConstructorInfo of a function/delegate in F#

如何在 F# 中获得以下 CIL 构造函数(如 System.Relection.ConstructorInfo)?

[mscorlib]System.Func`3<int32,int32,int32>::.ctor(object, native int)

我尝试了以下方法,但得到的结果为空:

typeof<int * int * int>.GetConstructor([|typeof<obj> ; typeof<nativeint>|]);;
val it : System.Reflection.ConstructorInfo = <null>

另外,是否可以动态进行?假设不是 3 种 int 类型,而是随机 System.Type list。怎么样?

发现:

System.Linq.Expressions.Expression.GetDelegateType([|typeof<int> ; typeof<int> ; typeof<int>|]).GetConstructor([|typeof<obj> ; typeof<nativeint>|]).DeclaringType;;

GetDelegateType方法采用类型数组,因此可以动态使用。