The operations on MonoClass* allow you to
query a number of properties of a .NET class from the C API.
This page contains information for how to obtain a MonoClass*, how to probe for different features of a MonoClass* and APIs to access class members and access fields. To access methods, see the method documentation API.
You typically would obtain a MonoClass*
pointer by using a combination of the MonoImage*
where the type is located, the namespace and name using the
mono_class_from_name
or
the mono_class_from_name_case
APIs or by using
the mono_class_from_typeref
or mono_class_from_typeref_checked
methods.
For low-level access, you can get the MonoClass
* from an image and an ECMA type token relative to
the MonoImage* by using mono_class_get.
mono_class_get
| image | image where the class token will be looked up. |
| type_token | a type token from the image |
Returns the MonoClass with the given type_token on the image
mono_class_from_mono_type
| type | describes the type to return |
This returns a MonoClass for the specified MonoType, the value is never NULL.
mono_class_from_name
| image | The MonoImage where the type is looked up in |
| name_space | the type namespace |
| name | the type short name. |
Obtains a MonoClass with a given namespace and a given name which is located in the given MonoImage.
To reference nested classes, use the "/" character as a separator. For example use "Foo/Bar" to reference the class Bar that is nested inside Foo, like this: "class Foo { class Bar {} }".
mono_class_from_name_case
| image | The MonoImage where the type is looked up in |
| name_space | the type namespace |
| name | the type short name. |
| error | if |
NULL if it
was not found. The error object will contain information about the problem
in that case.Obtains a MonoClass with a given namespace and a given name which is located in the given MonoImage. The namespace and name lookups are case insensitive.
mono_class_from_typeref
| image | a MonoImage |
| type_token | a TypeRef token |
NULL ifcould
not be loaded.Creates the MonoClass* structure representing the type defined by the typeref token valid inside image.
mono_class_from_typeref_checked
| image | a MonoImage |
| type_token | a TypeRef token |
| error | error return code, if any. |
NULL if it could
not be loaded with the error value filled with the information about the
error.Creates the MonoClass* structure representing the type defined by the typeref token valid inside image.
mono_class_from_generic_parameter
| param | Parameter to find/construct a class for. |
| arg2 | Is ignored. |
| arg3 | Is ignored. |
mono_class_array_element_size
| klass |
mono_class_data_size
| klass | a class |
mono_class_enum_basetype
| klass | the MonoClass to act on |
Use this function to get the underlying type for an enumeration value.
mono_class_get_byref_type
| klass | the MonoClass to act on |
mono_class_get_element_class
| klass | the MonoClass to act on |
Use this function to get the element class of an array.
mono_class_get_event_token
mono_class_get_field
| class | the class to lookup the field. |
| field_token | the field token |
NULL value if the field does not belong to this
class.
mono_class_get_field_token
| field | the field we need the token of |
Get the token of a field. Note that the tokesn is only valid for the image the field was loaded from. Don't use this function for fields in dynamic types.
mono_class_get_flags
| klass | the MonoClass to act on |
The type flags from the TypeDef table from the metadata. see the TYPE_ATTRIBUTE_* definitions on tabledefs.h for the different values.
mono_class_get_full
| image | the image where the class resides |
| type_token | the token for the class |
| context | the generic context used to evaluate generic instantiations in |
mono_class_get_image
Use this method to get the MonoImage* where this class came from.
mono_class_get_interfaces
| klass | the MonoClass to act on |
NULL when no more are available.
This routine is an iterator routine for retrieving the interfaces implemented by this class.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_class_get_name
| klass | the MonoClass to act on |
mono_class_get_namespace
| klass | the MonoClass to act on |
mono_class_get_nesting_type
| klass | the MonoClass to act on |
NULL if this type is not a nested type.
Use this function to obtain the class that the provided MonoClass* is nested on.
If the return is NULL, this indicates that this class is not nested.
mono_class_get_parent
| klass | the MonoClass to act on |
mono_class_get_property_token
| prop | MonoProperty to query |
mono_class_get_rank
| klass | the MonoClass to act on |
mono_class_get_type
| klass | the MonoClass to act on |
This method returns the internal Type representation for the class.
mono_class_get_type_token
| klass | the MonoClass to act on |
This method returns type token for the class.
mono_class_implements_interface
| klass | The MonoClass to act on |
| interface | The interface to check if klass implements. |
TRUE if klass implements interface.
mono_class_inflate_generic_method
mono_class_inflate_generic_type
mono_class_init
| class | the class to initialize |
Compute the instance_size, class_size and other infos that cannot be
computed at mono_class_get() time. Also compute vtable_size if possible.
Returns TRUE on success or FALSE if there was a problem in loading
the type (incorrect assemblies, missing assemblies, methods, etc).
LOCKING: Acquires the loader lock.
mono_class_instance_size
| klass | a class |
Use to get the size of a class in bytes.
mono_class_is_assignable_from
| klass | the class to be assigned to |
| oklass | the source class |
TRUE if an instance of object oklass can be assigned to an
instance of object klass
mono_class_is_delegate
| klass | the MonoClass to act on |
TRUE if the MonoClass represents a System.Delegate.
mono_class_is_enum
| klass | the MonoClass to act on |
TRUE if the MonoClass represents an enumeration.
Use this function to determine if the provided MonoClass* represents an enumeration.
mono_class_is_subclass_of
| klass | class to probe if it is a subclass of another one |
| klassc | the class we suspect is the base class |
| check_interfaces | whether we should perform interface checks |
This method determines whether klass is a subclass of klassc.
If the check_interfaces flag is set, then if klassc is an interface
this method return TRUE if the klass implements the interface or
if klass is an interface, if one of its base classes is klass.
If check_interfaces is false then, then if klass is not an interface
then it returns TRUE if the klass is a subclass of klassc.
if klass is an interface and klassc is System.Object, then this function return true.
mono_class_is_valuetype
| klass | the MonoClass to act on |
TRUE if the MonoClass represents a ValueType, FALSE if it represents a reference type.
Use this method to determine if the provided MonoClass* represents a value type,
or a reference type.
mono_class_min_align
| klass | a class |
Use to get the computed minimum alignment requirements for the specified class.
mono_class_name_from_token
mono_class_num_events
| klass | the MonoClass to act on |
mono_class_num_fields
| klass | the MonoClass to act on |
mono_class_num_methods
| klass | the MonoClass to act on |
mono_class_num_properties
| klass | the MonoClass to act on |
mono_class_value_size
| klass | a class |
This function is used for value types, and return the space and the alignment to store that kind of value object.
mono_class_vtable
| domain | the application domain |
| class | the class to initialize |
VTables are domain specific because we create domain specific code, and
they contain the domain specific static class data.
On failure, NULL is returned, and class->exception_type is set.
mono_class_get_fields
| klass | the MonoClass to act on |
NULL when no more fields are available.
This routine is an iterator routine for retrieving the fields in a class.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_class_get_field_from_name
| klass | the class to lookup the field. |
| name | the field name |
NULL
Search the class klass and it's parents for a field with the name name.
mono_class_get_methods
| klass | the MonoClass to act on |
NULL when no more methods are available.
This routine is an iterator routine for retrieving the fields in a class.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_class_get_method_from_name
| klass | where to look for the method |
| name | name of the method |
| param_count | number of parameters. -1 for any number. |
Obtains a MonoMethod with a given name and number of parameters. It only works if there are no multiple signatures for any given method name.
mono_class_get_method_from_name_flags
| klass | where to look for the method |
| name_space | name of the method |
| param_count | number of parameters. -1 for any number. |
| flags | flags which must be set in the method |
Obtains a MonoMethod with a given name and number of parameters. It only works if there are no multiple signatures for any given method name.
mono_class_get_nested_types
| klass | the MonoClass to act on |
NULL when no more are available.
This routine is an iterator routine for retrieving the nested types of a class. This works only if klass is non-generic, or a generic type definition.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_class_get_properties
| klass | the MonoClass to act on |
NULL when no more are available.
This routine is an iterator routine for retrieving the properties in a class.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_class_get_property_from_name
| klass | a class |
| name | name of the property to lookup in the specified class |
NULL if the property
does not exist on the klass.Use this method to lookup a property in a class
mono_class_get_events
| klass | the MonoClass to act on |
NULL when no more are available.
This routine is an iterator routine for retrieving the properties in a class.
You must pass a gpointer that points to zero and is treated as an opaque handle to
iterate over all of the elements. When no more values are
available, the return value is NULL.
mono_field_get_data
| field | the MonoClassField to act on |
mono_field_get_offset
| field | the MonoClassField to act on |
mono_field_full_name
| field | field to retrieve information for |
mono_method_can_access_field
| method | Method that will attempt to access the field |
| field | the field to access |
TRUE if the given method is allowed to access the field while following
the accessibility rules of the CLI.Used to determine if a method is allowed to access the specified field.
mono_method_can_access_method
| method | Method that will attempt to access the other method |
| called | the method that we want to probe for accessibility. |
TRUE if the given method is allowed to invoke the called while following
the accessibility rules of the CLI.Used to determine if the method is allowed to access the specified called method.