我想要做的是创建一个提供的类型,在C#中调用它的基本构造函数:
public class SubclassController : BaseClass
{
    public SubclassController (IntPtr handle) : base (handle)
    {}
}
我目前最接近的是:
public sealed class SubclassController : BaseClass
{
    public SubclassController (IntPtr handle)
    {
        this;
        base..ctor (handle);
    }
虽然具有相同的功能但并不完全相同.
我用来构建ProvideConstructor的代码如下:
let providedConstructor = ProvidedConstructor([ProvidedParameter("handle", typeof<IntPtr>)])
let ctorInfo = typeof<SubclassController>.GetConstructor(BindingFlags.Public ||| BindingFlags.Instance, null, [|typeof<IntPtr>|], null)
providedConstructor.BaseConstructorCall <- fun args -> ctorInfo, args
providedConstructor.InvokeCode <- fun args -> <@@ () @@>
这实际上是 ProvidedTypes.fs 中的一个错误,现已在最新版本中修复。可以从Codeplex的老地方购买感谢@desco,
因此,此代码实际上是正确形成的基本构造函数调用所需的全部内容:
let providedConstructor = ProvidedConstructor([ProvidedParameter("handle", typeof<IntPtr>)])
let ctorInfo = typeof<SubclassController>.GetConstructor(BindingFlags.Public |||         BindingFlags.Instance, null, [|typeof<IntPtr>|], null)
providedConstructor.BaseConstructorCall <- fun args -> ctorInfo, args
providedConstructor.InvokeCode <- fun args -> <@@ () @@>