Why can't I get the MonoMethod* for the method that takes an enum,
and is there a way to list the methods that mono knows about?
Here's a reduced example of what I'm trying to do. I tried different combinations of what (Windows) ildasm reported but no success.
// enum.cs
namespace EnumTest
{
class EnumClass
{
public enum HelloType { Hi, Hey, Howdy, Greetings, Aloha };
public static void SetDefault() { type_ = HelloType.Hi; }
public static void SetType(HelloType h) { type_ = h; }
public static HelloType type_;
}
}
// enum.cpp
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/debug-helpers.h>
int main(int argc, char* argv[]) {
MonoDomain* domain = mono_jit_init("enum.dll");
MonoAssembly* assembly = mono_domain_assembly_open(domain, "enum.dll");
MonoImage* image = mono_assembly_get_image(assembly);
MonoClass* enumClass = mono_class_from_name(image, "EnumTest", "EnumClass");
MonoMethodDesc* defaultDesc = mono_method_desc_new("EnumTest.EnumClass:SetDefault()", false);
MonoMethod* defaultMethod = mono_method_desc_search_in_class(defaultDesc, enumClass);
printf("defaultDesc from mono_method_desc_new() is %p\n", defaultDesc);
printf("defaultMethod from mono_method_desc_search_in_class() is %p\n\n", defaultMethod);
MonoMethodDesc* typeDesc = mono_method_desc_new("EnumTest.EnumClass:SetType(HelloType)", false);
MonoMethod* typeMethod = mono_method_desc_search_in_class(typeDesc, enumClass);
printf("typeDesc from mono_method_desc_new() is %p\n", typeDesc);
printf("typeMethod from mono_method_desc_search_in_class() is %p <------\n", typeMethod);
mono_jit_cleanup(domain);
}
$ mcs /nologo /warn:4 /debug:pdbonly /o /out:enum.dll /target:library enum.cs
$ gcc enum.cpp -g3 `pkg-config --cflags --libs mono-2` -o enum
$ ./enum
defaultDesc from mono_method_desc_new() is 0x1443920
defaultMethod from mono_method_desc_search_in_class() is 0x13dce40
typeDesc from mono_method_desc_new() is 0x1444590
typeMethod from mono_method_desc_search_in_class() is (nil) <------
$ uname -a
Linux U14-OOXML 3.16.0-37-generic #51~14.04.1-Ubuntu SMP Wed May 6 15:23:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux