diff --git a/Source/Engine/Scripting/DotNet/MonoApi.cpp b/Source/Engine/Scripting/DotNet/MonoApi.cpp index 5a3faa9bb..d1150daca 100644 --- a/Source/Engine/Scripting/DotNet/MonoApi.cpp +++ b/Source/Engine/Scripting/DotNet/MonoApi.cpp @@ -161,6 +161,7 @@ private: Array _properties; bool _cachedInterfaces = false; Array _interfaces; + int _monoType; public: CoreCLRClass(void* typeHandle, StringAnsi name, StringAnsi fullname, StringAnsi namespace_, uint32 typeAttributes, CoreCLRAssembly* image) @@ -339,6 +340,16 @@ public: _cachedInterfaces = true; return _interfaces; } + + int GetMonoType() + { + if (_monoType == 0) + { + static void* GetTypeMonoTypeEnumPtr = CoreCLR::GetStaticMethodPointer(TEXT("GetTypeMonoTypeEnum")); + _monoType = CoreCLR::CallStaticMethod(GetTypeMonoTypeEnumPtr, _typeHandle); + } + return _monoType; + } }; struct CoreCLRMethod @@ -1450,8 +1461,8 @@ MONO_API mono_bool mono_type_is_byref(MonoType* type) MONO_API int mono_type_get_type(MonoType* type) { - static void* GetTypeMonoTypeEnumPtr = CoreCLR::GetStaticMethodPointer(TEXT("GetTypeMonoTypeEnum")); - return CoreCLR::CallStaticMethod(GetTypeMonoTypeEnumPtr, type); + CoreCLRClass* klass = GetOrCreateClass((void*)type); + return klass->GetMonoType(); } MONO_API MonoClass* mono_type_get_class(MonoType* type)