Merge pull request #3056 from BrzVlad/fix-multiple-binprot
[mono.git] / mono / metadata / domain.c
index e2dd18816663f8b13fa565a958a9168d4ff16e3f..a3ba4a76e0492b35533b95791df77c3eab1a235c 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  * Copyright 2011-2012 Xamarin, Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <config.h>
@@ -267,6 +268,8 @@ mono_install_free_domain_hook (MonoFreeDomainFunc func)
  * @s1: First string to compare
  * @s2: Second string to compare
  *
+ * Compares two `MonoString*` instances ordinally for equality.
+ *
  * Returns FALSE if the strings differ.
  */
 gboolean
@@ -287,6 +290,7 @@ mono_string_equal (MonoString *s1, MonoString *s2)
  * mono_string_hash:
  * @s: the string to hash
  *
+ * Compute the hash for a `MonoString*`
  * Returns the hash for the string.
  */
 guint
@@ -621,258 +625,181 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
        }
        mono_defaults.corlib = mono_assembly_get_image (ass);
 
-       mono_defaults.object_class = mono_class_from_name (
+       mono_defaults.object_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Object");
-       g_assert (mono_defaults.object_class != 0);
 
-       mono_defaults.void_class = mono_class_from_name (
+       mono_defaults.void_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Void");
-       g_assert (mono_defaults.void_class != 0);
 
-       mono_defaults.boolean_class = mono_class_from_name (
+       mono_defaults.boolean_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Boolean");
-       g_assert (mono_defaults.boolean_class != 0);
 
-       mono_defaults.byte_class = mono_class_from_name (
+       mono_defaults.byte_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Byte");
-       g_assert (mono_defaults.byte_class != 0);
 
-       mono_defaults.sbyte_class = mono_class_from_name (
+       mono_defaults.sbyte_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "SByte");
-       g_assert (mono_defaults.sbyte_class != 0);
 
-       mono_defaults.int16_class = mono_class_from_name (
+       mono_defaults.int16_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Int16");
-       g_assert (mono_defaults.int16_class != 0);
 
-       mono_defaults.uint16_class = mono_class_from_name (
+       mono_defaults.uint16_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "UInt16");
-       g_assert (mono_defaults.uint16_class != 0);
 
-       mono_defaults.int32_class = mono_class_from_name (
+       mono_defaults.int32_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Int32");
-       g_assert (mono_defaults.int32_class != 0);
 
-       mono_defaults.uint32_class = mono_class_from_name (
+       mono_defaults.uint32_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "UInt32");
-       g_assert (mono_defaults.uint32_class != 0);
 
-       mono_defaults.uint_class = mono_class_from_name (
+       mono_defaults.uint_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "UIntPtr");
-       g_assert (mono_defaults.uint_class != 0);
 
-       mono_defaults.int_class = mono_class_from_name (
+       mono_defaults.int_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "IntPtr");
-       g_assert (mono_defaults.int_class != 0);
 
-       mono_defaults.int64_class = mono_class_from_name (
+       mono_defaults.int64_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Int64");
-       g_assert (mono_defaults.int64_class != 0);
 
-       mono_defaults.uint64_class = mono_class_from_name (
+       mono_defaults.uint64_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "UInt64");
-       g_assert (mono_defaults.uint64_class != 0);
 
-       mono_defaults.single_class = mono_class_from_name (
+       mono_defaults.single_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Single");
-       g_assert (mono_defaults.single_class != 0);
 
-       mono_defaults.double_class = mono_class_from_name (
+       mono_defaults.double_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Double");
-       g_assert (mono_defaults.double_class != 0);
 
-       mono_defaults.char_class = mono_class_from_name (
+       mono_defaults.char_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Char");
-       g_assert (mono_defaults.char_class != 0);
 
-       mono_defaults.string_class = mono_class_from_name (
+       mono_defaults.string_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "String");
-       g_assert (mono_defaults.string_class != 0);
 
-       mono_defaults.enum_class = mono_class_from_name (
+       mono_defaults.enum_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Enum");
-       g_assert (mono_defaults.enum_class != 0);
 
-       mono_defaults.array_class = mono_class_from_name (
+       mono_defaults.array_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Array");
-       g_assert (mono_defaults.array_class != 0);
 
-       mono_defaults.delegate_class = mono_class_from_name (
+       mono_defaults.delegate_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "Delegate");
-       g_assert (mono_defaults.delegate_class != 0 );
 
-       mono_defaults.multicastdelegate_class = mono_class_from_name (
+       mono_defaults.multicastdelegate_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "MulticastDelegate");
-       g_assert (mono_defaults.multicastdelegate_class != 0 );
 
-       mono_defaults.asyncresult_class = mono_class_from_name (
+       mono_defaults.asyncresult_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Runtime.Remoting.Messaging", 
                "AsyncResult");
-       g_assert (mono_defaults.asyncresult_class != 0 );
 
-       mono_defaults.manualresetevent_class = mono_class_from_name (
+       mono_defaults.manualresetevent_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Threading", "ManualResetEvent");
-       g_assert (mono_defaults.manualresetevent_class != 0 );
 
-       mono_defaults.typehandle_class = mono_class_from_name (
+       mono_defaults.typehandle_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeTypeHandle");
-       g_assert (mono_defaults.typehandle_class != 0);
 
-       mono_defaults.methodhandle_class = mono_class_from_name (
+       mono_defaults.methodhandle_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeMethodHandle");
-       g_assert (mono_defaults.methodhandle_class != 0);
 
-       mono_defaults.fieldhandle_class = mono_class_from_name (
+       mono_defaults.fieldhandle_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeFieldHandle");
-       g_assert (mono_defaults.fieldhandle_class != 0);
 
-       mono_defaults.systemtype_class = mono_class_from_name (
+       mono_defaults.systemtype_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Type");
-       g_assert (mono_defaults.systemtype_class != 0);
-
-       mono_defaults.monotype_class = mono_class_from_name (
-                mono_defaults.corlib, "System", "MonoType");
-       g_assert (mono_defaults.monotype_class != 0);
 
-       mono_defaults.runtimetype_class = mono_class_from_name (
+       mono_defaults.runtimetype_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeType");
-       g_assert (mono_defaults.runtimetype_class != 0);
 
-       mono_defaults.exception_class = mono_class_from_name (
+       mono_defaults.exception_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Exception");
-       g_assert (mono_defaults.exception_class != 0);
 
-       mono_defaults.threadabortexception_class = mono_class_from_name (
+       mono_defaults.threadabortexception_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Threading", "ThreadAbortException");
-       g_assert (mono_defaults.threadabortexception_class != 0);
 
-       mono_defaults.thread_class = mono_class_from_name (
+       mono_defaults.thread_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Threading", "Thread");
-       g_assert (mono_defaults.thread_class != 0);
 
-       mono_defaults.internal_thread_class = mono_class_from_name (
+       mono_defaults.internal_thread_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Threading", "InternalThread");
-       if (!mono_defaults.internal_thread_class) {
-               /* This can happen with an old mscorlib */
-               fprintf (stderr, "Corlib too old for this runtime.\n");
-               fprintf (stderr, "Loaded from: %s\n",
-                                mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown");
-               exit (1);
-       }
 
-       mono_defaults.appdomain_class = mono_class_from_name (
+       mono_defaults.appdomain_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "AppDomain");
-       g_assert (mono_defaults.appdomain_class != 0);
 
 #ifndef DISABLE_REMOTING
-       mono_defaults.transparent_proxy_class = mono_class_from_name (
+       mono_defaults.transparent_proxy_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Runtime.Remoting.Proxies", "TransparentProxy");
-       g_assert (mono_defaults.transparent_proxy_class != 0);
 
-       mono_defaults.real_proxy_class = mono_class_from_name (
+       mono_defaults.real_proxy_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Runtime.Remoting.Proxies", "RealProxy");
-       g_assert (mono_defaults.real_proxy_class != 0);
 
-       mono_defaults.marshalbyrefobject_class =  mono_class_from_name (
+       mono_defaults.marshalbyrefobject_class =  mono_class_load_from_name (
                mono_defaults.corlib, "System", "MarshalByRefObject");
-       g_assert (mono_defaults.marshalbyrefobject_class != 0);
 
-       mono_defaults.iremotingtypeinfo_class = mono_class_from_name (
+       mono_defaults.iremotingtypeinfo_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Runtime.Remoting", "IRemotingTypeInfo");
-       g_assert (mono_defaults.iremotingtypeinfo_class != 0);
+
 #endif
 
-       mono_defaults.mono_method_message_class = mono_class_from_name (
+       mono_defaults.mono_method_message_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "MonoMethodMessage");
-       g_assert (mono_defaults.mono_method_message_class != 0);
 
-       mono_defaults.field_info_class = mono_class_from_name (
+       mono_defaults.field_info_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Reflection", "FieldInfo");
-       g_assert (mono_defaults.field_info_class != 0);
 
-       mono_defaults.method_info_class = mono_class_from_name (
+       mono_defaults.method_info_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Reflection", "MethodInfo");
-       g_assert (mono_defaults.method_info_class != 0);
 
-       mono_defaults.stringbuilder_class = mono_class_from_name (
+       mono_defaults.stringbuilder_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Text", "StringBuilder");
-       g_assert (mono_defaults.stringbuilder_class != 0);
 
-       mono_defaults.math_class = mono_class_from_name (
+       mono_defaults.math_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "Math");
-       g_assert (mono_defaults.math_class != 0);
 
-       mono_defaults.stack_frame_class = mono_class_from_name (
+       mono_defaults.stack_frame_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Diagnostics", "StackFrame");
-       g_assert (mono_defaults.stack_frame_class != 0);
 
-       mono_defaults.stack_trace_class = mono_class_from_name (
+       mono_defaults.stack_trace_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Diagnostics", "StackTrace");
-       g_assert (mono_defaults.stack_trace_class != 0);
 
-       mono_defaults.marshal_class = mono_class_from_name (
+       mono_defaults.marshal_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Runtime.InteropServices", "Marshal");
-       g_assert (mono_defaults.marshal_class != 0);
 
-       mono_defaults.typed_reference_class =  mono_class_from_name (
+       mono_defaults.typed_reference_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "TypedReference");
-       g_assert (mono_defaults.typed_reference_class != 0);
 
-       mono_defaults.argumenthandle_class =  mono_class_from_name (
+       mono_defaults.argumenthandle_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "RuntimeArgumentHandle");
-       g_assert (mono_defaults.argumenthandle_class != 0);
 
-       mono_defaults.monitor_class =  mono_class_from_name (
+       mono_defaults.monitor_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Threading", "Monitor");
-       g_assert (mono_defaults.monitor_class != 0);
-
-       mono_defaults.runtimesecurityframe_class = mono_class_from_name (
-               mono_defaults.corlib, "System.Security", "RuntimeSecurityFrame");
-
-       mono_defaults.executioncontext_class = mono_class_from_name (
-               mono_defaults.corlib, "System.Threading", "ExecutionContext");
-
-       mono_defaults.internals_visible_class = mono_class_from_name (
-               mono_defaults.corlib, "System.Runtime.CompilerServices", "InternalsVisibleToAttribute");
-
-       mono_defaults.critical_finalizer_object = mono_class_from_name (
-               mono_defaults.corlib, "System.Runtime.ConstrainedExecution", "CriticalFinalizerObject");
-
        /*
-        * mscorlib needs a little help, only now it can load its friends list (after we have
-        * loaded the InternalsVisibleToAttribute), load it now
-        */
+       Not using GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL as this type is heavily checked by sgen when computing finalization.
+       */
+       mono_defaults.critical_finalizer_object = mono_class_try_load_from_name (mono_defaults.corlib,
+                       "System.Runtime.ConstrainedExecution", "CriticalFinalizerObject");
+
        mono_assembly_load_friends (ass);
-       
-       mono_defaults.safehandle_class = mono_class_from_name (
-               mono_defaults.corlib, "System.Runtime.InteropServices", "SafeHandle");
 
-       mono_defaults.handleref_class = mono_class_from_name (
+       mono_defaults.handleref_class = mono_class_try_load_from_name (
                mono_defaults.corlib, "System.Runtime.InteropServices", "HandleRef");
 
-       mono_defaults.attribute_class = mono_class_from_name (
+       mono_defaults.attribute_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "Attribute");
 
-       mono_defaults.customattribute_data_class = mono_class_from_name (
+       mono_defaults.customattribute_data_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Reflection", "CustomAttributeData");
 
        mono_class_init (mono_defaults.array_class);
-       mono_defaults.generic_nullable_class = mono_class_from_name (
+       mono_defaults.generic_nullable_class = mono_class_load_from_name (
                mono_defaults.corlib, "System", "Nullable`1");
-       mono_defaults.generic_ilist_class = mono_class_from_name (
+       mono_defaults.generic_ilist_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Collections.Generic", "IList`1");
-       mono_defaults.generic_ireadonlylist_class = mono_class_from_name (
+       mono_defaults.generic_ireadonlylist_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Collections.Generic", "IReadOnlyList`1");
 
-       mono_defaults.threadpool_wait_callback_class = mono_class_from_name (
+       mono_defaults.threadpool_wait_callback_class = mono_class_load_from_name (
                mono_defaults.corlib, "System.Threading", "_ThreadPoolWaitCallback");
-       if (!mono_defaults.threadpool_wait_callback_class) {
-               /* This can happen with an old mscorlib */
-               fprintf (stderr, "Corlib too old for this runtime.\n");
-               fprintf (stderr, "Loaded from: %s\n",
-                                mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown");
-               exit (1);
-       }
+
        mono_defaults.threadpool_perform_wait_callback_method = mono_class_get_method_from_name (
                mono_defaults.threadpool_wait_callback_class, "PerformWaitCallback", 0);
 
@@ -888,6 +815,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
  * 
  * Creates the initial application domain and initializes the mono_defaults
  * structure.
+ *
  * This function is guaranteed to not run any IL code.
  * The runtime is initialized using the default runtime version.
  *
@@ -956,8 +884,8 @@ mono_cleanup (void)
        mono_loader_cleanup ();
        mono_classes_cleanup ();
        mono_assemblies_cleanup ();
-       mono_images_cleanup ();
        mono_debug_cleanup ();
+       mono_images_cleanup ();
        mono_metadata_cleanup ();
 
        mono_native_tls_free (appdomain_thread_id);
@@ -1123,7 +1051,7 @@ unregister_vtable_reflection_type (MonoVTable *vtable)
 {
        MonoObject *type = (MonoObject *)vtable->type;
 
-       if (type->vtable->klass != mono_defaults.monotype_class)
+       if (type->vtable->klass != mono_defaults.runtimetype_class)
                MONO_GC_UNREGISTER_ROOT_IF_MOVING (vtable->type);
 }
 
@@ -1238,12 +1166,6 @@ mono_domain_free (MonoDomain *domain, gboolean force)
        g_slist_free (domain->domain_assemblies);
        domain->domain_assemblies = NULL;
 
-       /* 
-        * Send this after the assemblies have been unloaded and the domain is still in a 
-        * usable state.
-        */
-       mono_profiler_appdomain_event (domain, MONO_PROFILE_END_UNLOAD);
-
        if (free_domain_hook)
                free_domain_hook (domain);
 
@@ -1495,58 +1417,6 @@ mono_domain_code_commit (MonoDomain *domain, void *data, int size, int newsize)
        mono_domain_unlock (domain);
 }
 
-#if defined(__native_client_codegen__) && defined(__native_client__)
-/*
- * Given the temporary buffer (allocated by mono_domain_code_reserve) into which
- * we are generating code, return a pointer to the destination in the dynamic 
- * code segment into which the code will be copied when mono_domain_code_commit
- * is called.
- * LOCKING: Acquires the domain lock.
- */
-void *
-nacl_domain_get_code_dest (MonoDomain *domain, void *data)
-{
-       void *dest;
-       mono_domain_lock (domain);
-       dest = nacl_code_manager_get_code_dest (domain->code_mp, data);
-       mono_domain_unlock (domain);
-       return dest;
-}
-
-/* 
- * Convenience function which calls mono_domain_code_commit to validate and copy
- * the code. The caller sets *buf_base and *buf_size to the start and size of
- * the buffer (allocated by mono_domain_code_reserve), and *code_end to the byte
- * after the last instruction byte. On return, *buf_base will point to the start
- * of the copied in the code segment, and *code_end will point after the end of 
- * the copied code.
- */
-void
-nacl_domain_code_validate (MonoDomain *domain, guint8 **buf_base, int buf_size, guint8 **code_end)
-{
-       guint8 *tmp = nacl_domain_get_code_dest (domain, *buf_base);
-       mono_domain_code_commit (domain, *buf_base, buf_size, *code_end - *buf_base);
-       *code_end = tmp + (*code_end - *buf_base);
-       *buf_base = tmp;
-}
-
-#else
-
-/* no-op versions of Native Client functions */
-
-void *
-nacl_domain_get_code_dest (MonoDomain *domain, void *data)
-{
-       return data;
-}
-
-void
-nacl_domain_code_validate (MonoDomain *domain, guint8 **buf_base, int buf_size, guint8 **code_end)
-{
-}
-
-#endif
-
 /*
  * mono_domain_code_foreach:
  * Iterate over the code thunks of the code manager of @domain.
@@ -1641,132 +1511,286 @@ mono_domain_add_class_static_data (MonoDomain *domain, MonoClass *klass, gpointe
        domain->static_data_array [0] = GINT_TO_POINTER (next);
 }
 
+/**
+ * mono_get_corlib:
+ *
+ * Use this function to get the `MonoImage*` for the mscorlib.dll assembly
+ *
+ * Returns: The MonoImage for mscorlib.dll
+ */
 MonoImage*
 mono_get_corlib (void)
 {
        return mono_defaults.corlib;
 }
 
+/**
+ * mono_get_object_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Object`.
+ *
+ * Returns: The `MonoClass*` for the `System.Object` type.
+ */
 MonoClass*
 mono_get_object_class (void)
 {
        return mono_defaults.object_class;
 }
 
+/**
+ * mono_get_byte_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Byte`.
+ *
+ * Returns: The `MonoClass*` for the `System.Byte` type.
+ */
 MonoClass*
 mono_get_byte_class (void)
 {
        return mono_defaults.byte_class;
 }
 
+/**
+ * mono_get_void_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Void`.
+ *
+ * Returns: The `MonoClass*` for the `System.Void` type.
+ */
 MonoClass*
 mono_get_void_class (void)
 {
        return mono_defaults.void_class;
 }
 
+/**
+ * mono_get_boolean_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Boolean`.
+ *
+ * Returns: The `MonoClass*` for the `System.Boolean` type.
+ */
 MonoClass*
 mono_get_boolean_class (void)
 {
        return mono_defaults.boolean_class;
 }
 
+/**
+ * mono_get_sbyte_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.SByte`.
+ *
+ * Returns: The `MonoClass*` for the `System.SByte` type.
+ */
 MonoClass*
 mono_get_sbyte_class (void)
 {
        return mono_defaults.sbyte_class;
 }
 
+/**
+ * mono_get_int16_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Int16`.
+ *
+ * Returns: The `MonoClass*` for the `System.Int16` type.
+ */
 MonoClass*
 mono_get_int16_class (void)
 {
        return mono_defaults.int16_class;
 }
 
+/**
+ * mono_get_uint16_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt16`.
+ *
+ * Returns: The `MonoClass*` for the `System.UInt16` type.
+ */
 MonoClass*
 mono_get_uint16_class (void)
 {
        return mono_defaults.uint16_class;
 }
 
+/**
+ * mono_get_int32_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Int32`.
+ *
+ * Returns: The `MonoClass*` for the `System.Int32` type.
+ */
 MonoClass*
 mono_get_int32_class (void)
 {
        return mono_defaults.int32_class;
 }
 
+/**
+ * mono_get_uint32_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt32`.
+ *
+ * Returns: The `MonoClass*` for the `System.UInt32` type.
+ */
 MonoClass*
 mono_get_uint32_class (void)
 {
        return mono_defaults.uint32_class;
 }
 
+/**
+ * mono_get_intptr_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.IntPtr`.
+ *
+ * Returns: The `MonoClass*` for the `System.IntPtr` type.
+ */
 MonoClass*
 mono_get_intptr_class (void)
 {
        return mono_defaults.int_class;
 }
 
+/**
+ * mono_get_uintptr_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.UIntPtr`.
+ *
+ * Returns: The `MonoClass*` for the `System.UIntPtr` type.
+ */
 MonoClass*
 mono_get_uintptr_class (void)
 {
        return mono_defaults.uint_class;
 }
 
+/**
+ * mono_get_int64_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Int64`.
+ *
+ * Returns: The `MonoClass*` for the `System.Int64` type.
+ */
 MonoClass*
 mono_get_int64_class (void)
 {
        return mono_defaults.int64_class;
 }
 
+/**
+ * mono_get_uint64_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.UInt64`.
+ *
+ * Returns: The `MonoClass*` for the `System.UInt64` type.
+ */
 MonoClass*
 mono_get_uint64_class (void)
 {
        return mono_defaults.uint64_class;
 }
 
+/**
+ * mono_get_single_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Single` (32-bit floating points).
+ *
+ * Returns: The `MonoClass*` for the `System.Single` type.
+ */
 MonoClass*
 mono_get_single_class (void)
 {
        return mono_defaults.single_class;
 }
 
+/**
+ * mono_get_double_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Double` (64-bit floating points).
+ *
+ * Returns: The `MonoClass*` for the `System.Double` type.
+ */
 MonoClass*
 mono_get_double_class (void)
 {
        return mono_defaults.double_class;
 }
 
+/**
+ * mono_get_char_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Char`.
+ *
+ * Returns: The `MonoClass*` for the `System.Char` type.
+ */
 MonoClass*
 mono_get_char_class (void)
 {
        return mono_defaults.char_class;
 }
 
+/**
+ * mono_get_string_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.String`.
+ *
+ * Returns: The `MonoClass*` for the `System.String` type.
+ */
 MonoClass*
 mono_get_string_class (void)
 {
        return mono_defaults.string_class;
 }
 
+/**
+ * mono_get_enum_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Enum`.
+ *
+ * Returns: The `MonoClass*` for the `System.Enum` type.
+ */
 MonoClass*
 mono_get_enum_class (void)
 {
        return mono_defaults.enum_class;
 }
 
+/**
+ * mono_get_array_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Array`.
+ *
+ * Returns: The `MonoClass*` for the `System.Array` type.
+ */
 MonoClass*
 mono_get_array_class (void)
 {
        return mono_defaults.array_class;
 }
 
+/**
+ * mono_get_thread_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Threading.Thread`.
+ *
+ * Returns: The `MonoClass*` for the `System.Threading.Thread` type.
+ */
 MonoClass*
 mono_get_thread_class (void)
 {
        return mono_defaults.thread_class;
 }
 
+/**
+ * mono_get_exception_class:
+ *
+ * Use this function to get the `MonoClass*` that the runtime is using for `System.Exception`.
+ *
+ * Returns: The `MonoClass*` for the `` type.
+ */
 MonoClass*
 mono_get_exception_class (void)
 {