mono-api-type.html

## Type support

### Synopsis

#include <metadata/metadata.h> #include <metadata/class.h> typedef struct _MonoType MonoType;

The MonoType represents the unmanaged version of System.Type.
`mono_type_get_object`
Syntax
MonoReflectionType* mono_type_get_object (MonoDomain *domain, MonoType *type)

Parameters

domain | an app domain
type | a type

Return value
A `System.MonoType` object representing the type type.
`mono_type_create_from_typespec`
Deprecated: use `mono_type_create_from_typespec_checked` that has proper error handling
Syntax
MonoType* mono_type_create_from_typespec (MonoImage *image, guint32 type_spec)

Parameters

image | context where the image is created
type_spec | typespec token

Description

Creates a `MonoType` representing the `TypeSpec` indexed by the type_spec token.
`mono_type_full_name`
Syntax
char* mono_type_full_name (MonoType *type)

`mono_type_get_array_type`
Syntax
MonoArrayType* mono_type_get_array_type (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
a `MonoArrayType` struct describing the array type that type represents. The info includes details such as rank, array element type and the sizes and bounds of multidimensional arrays.
Description
It is only valid to call this function if type is a `MONO_TYPE_ARRAY` .
`mono_type_get_class`
Syntax
MonoClass* mono_type_get_class (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
the `MonoClass` pointer that describes the class that type represents.
Description
It is only valid to call this function if type is a `MONO_TYPE_CLASS` or a `MONO_TYPE_VALUETYPE` . For more general functionality, use `mono_class_from_mono_type`, instead.
`mono_type_get_modifiers`
Syntax
MonoClass* mono_type_get_modifiers (MonoType *type, gboolean *is_required, gpointer *iter)

`mono_type_get_name`
Syntax
char* mono_type_get_name (MonoType *type)

Parameters

type | a type

Return value
The string representation for type as it would be represented in IL code.
`mono_type_get_ptr_type`
Syntax
MonoType* mono_type_get_ptr_type (MonoType *type)

Return value
the `MonoType` pointer that describes the type that type represents a pointer to.
Description
\pararm type the `MonoType` operated on It is only valid to call this function if type is a `MONO_TYPE_PTR` .
`mono_type_get_signature`
Syntax
MonoMethodSignature* mono_type_get_signature (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
the `MonoMethodSignature` pointer that describes the signature of the function pointer type represents.
Description
It is only valid to call this function if type is a `MONO_TYPE_FNPTR` .
`mono_type_get_type`
Syntax
int mono_type_get_type (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
the IL type value for type. This is one of the `MonoTypeEnum` enum members like `MONO_TYPE_I4` or `MONO_TYPE_STRING`.
`mono_type_get_underlying_type`
Syntax
MonoType* mono_type_get_underlying_type (MonoType *type)

Parameters

type | a type

Return value
The `MonoType` for the underlying integer type if type is an enum and byref is false, otherwise the type itself.
`mono_type_is_byref`
Syntax
mono_bool mono_type_is_byref (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
`TRUE` if type represents a type passed by reference, `FALSE` otherwise.
`mono_type_is_pointer`
Syntax
mono_bool mono_type_is_pointer (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
`TRUE` if type is a managed or unmanaged pointer type. `FALSE` otherwise.
`mono_type_is_reference`
Syntax
mono_bool mono_type_is_reference (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
`TRUE` if type represents an object reference. `FALSE` otherwise.
`mono_type_is_struct`
Syntax
mono_bool mono_type_is_struct (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
`TRUE` if type is a struct, that is a `ValueType` but not an enum or a basic type like `System.Int32` . `FALSE` otherwise.
`mono_type_is_void`
Syntax
mono_bool mono_type_is_void (MonoType *type)

Parameters

type | the `MonoType` operated on

Return value
`TRUE` if type is `System.Void` . `FALSE` otherwise.
`mono_type_size`
Syntax
int mono_type_size (MonoType *t, int *align)

Parameters

t | the type to return the size of

Return value
The number of bytes required to hold an instance of this type in memory
`mono_type_stack_size`
Syntax
int mono_type_stack_size (MonoType *t, int *align)

Parameters

t | the type to return the size it uses on the stack

Return value
The number of bytes required to hold an instance of this type on the runtime stack
`mono_type_to_unmanaged`
Syntax
guint32 mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_field, gboolean unicode, MonoMarshalConv *conv)

Return value
A `MonoMarshalNative` enumeration value (`MONO_NATIVE_`) value describing the underlying native reprensetation of the type.
Description
The value pointed to by conv will contain the kind of marshalling required for this particular type one of the `MONO_MARSHAL_CONV_` enumeration values.