Methods are represented by the MonoMethod*
instances. Various APIs surface these instances, but usually
you will use the method description
API to get a handle to a Mono Method. You can invoke those methods from C,
or you can probe probe various properties of a method, and in particular
its method signature or get
some low-level information about them.
The following code snippet from the Mono runtime shows you
how to create a managed System.Version
instance
with four integers by looking up the constructor in the
managed implementation of System.Version, creating an instance
of the object, and then invoking the constructor on it.
Methods are represented by the MonoMethod*
instances. To simplify the process of getting
a MonoMethod*
, you use Method Descriptors, which
are C-strings that describe the method that you are looking
for, and then you perform a search in either
a type, or a
loaded image.
To describe a method, you use the Method Description API. Method descriptions are used to locate a method in the executing program. They can either be fully specified, that is, they would include the namespace, class, method name and all of its arguments or they omit the namespace and arguments and even use wildcard matches for the class name and method names.
You use the fully specified version to identify a particular method, or you can use the partial version to find a method or a family of methods in the code.
Method descriptions are typically created from a C string representation, and take the following form:
[namespace.]classname:methodname[(args...)]
Both classname and methodname can contain the '*' character which can be used to match anything. Arguments are separated by commas.
You can use the type shortcuts to match the fully qualified
parameter types. The supported type shortcuts are:
char
,
bool
,
byte
,
sbyte
,
uint16
,
int16
,
uint
,
int
,
ulong
,
long
,
uintptr
,
intptr
,
single
,
double
,
string
and
object
.
The type parameters can use the "&" and "*" type modifiers.
Examples of method descriptions:
You can then search for methods in MonoImages or search for methods in classes.