Come si fornisce correttamente il codice a in un provider di tipo generativo che farebbe l'equivalente di quanto segue?Metodo di chiamata corretta che fa riferimento all'istanza in ProvidedConstructor
Dato:
module Utils =
let someFun (s : string) (inst : obj) =
// Does something here...
()
ho bisogno di avere il tipo generato in modo efficace fare:
type NewGeneratedType() as self =
inherit BaseType()
do
Utils.someFun "Foo" (box self)
ho la chiamata al costruttore di base di lavoro, ma non so come tagliare correttamente l'istanza e ottenere la funzione chiamata:
let ctor = ProvidedConstructor([])
let ci = baseType.GetConstructor(BindingFlags.Public ||| BindingFlags.Instance, null, [| |], null)
ctor.BaseConstructorCall <- fun args -> ci, args
// I do not know how to properly call this to match the constructor above
ctor.InvokeCode <- fun args -> <@@() @@>
Sfortunatamente, aggiungendo 'ctor.Invoke' riporta l'errore' ... ha riportato un errore: costante sconosciuta 'ProviderImplementation.ProvidedTypes.ProvidedConstructor' nel metodo generato' –