Search code examples
c#c++mono

How can I get a list of all methods in a certain class from c++ in mono?


I've loaded my assembly "monoass.dll" using

mono_domain_assembly_open(domain, "C:/monoass.dll");

then I found my class which name is "MainClass" using

mono_class_from_name(mono_assembly_get_image(ass), "monoass", "MainClass"); // where "monoass" is the name of namespace

then I need to find all methods in "MainClass" class as MonoMethod** array. How can I do this?

Mono version is: Mono-3.2.3

Additional questions:

1) How can I output the MonoMethod's name, arguments and return value to the console? Is there any mono_method_to_string(MonoMethod* method) function?

2) How can I get all namespaces in my assembly (and print each name to the console) and then for each namespace get the array of all clases which are in the namespace?


Solution

  • you can get all methods like this:

    void* iter = NULL;
    MonoMethod* method;
    while(method = mono_class_get_methods(mono_class, &iter))
    {
        cout << mono_method_full_name(method, 1);
    }