.net - Mono.Cecil Import List Enumerator -
i'm doing bit of il weaving mono.cecil, , i'm running issue:
member 'system.collections.generic.list`1/enumerator' declared in module , needs imported
how go importing module has list enumerator?
i have typereference
(system.collections.generic.list`1< blah >) i'm using enumerator, so:
var instancetype = (typereference genericinstancetype); var list = instancetype.resolve(); methoddefinition getenumerator; if (!list.trygetmethod("getenumerator", out getenumerator)) throw ...
... trygetmethod
custom extension searches type in question method name.
i use getenumerator further down in code, so:
instructions.add(instruction.create(opcodes.callvirt, getenumerator));
what doing wrong?
i figured out. enumerator list, need methodreference
getenumerator
method, so:
type listtype = typeof (list<>); methodreference getenumerator = moduledefinition .import(listtype.getmethod("getenumerator"));
Comments
Post a Comment