diff --git a/Source/Engine/Scripting/Internal/ManagedDictionary.cpp b/Source/Engine/Scripting/Internal/ManagedDictionary.cpp index d467fe47a..d2f74e054 100644 --- a/Source/Engine/Scripting/Internal/ManagedDictionary.cpp +++ b/Source/Engine/Scripting/Internal/ManagedDictionary.cpp @@ -3,7 +3,7 @@ #include "ManagedDictionary.h" #if USE_CSHARP -Dictionary ManagedDictionary::CachedDictionaryTypes; +Dictionary ManagedDictionary::CachedTypes; #if !USE_MONO_AOT ManagedDictionary::MakeGenericTypeThunk ManagedDictionary::MakeGenericType; ManagedDictionary::CreateInstanceThunk ManagedDictionary::CreateInstance; diff --git a/Source/Engine/Scripting/Internal/ManagedDictionary.h b/Source/Engine/Scripting/Internal/ManagedDictionary.h index af88172b6..5e2638af7 100644 --- a/Source/Engine/Scripting/Internal/ManagedDictionary.h +++ b/Source/Engine/Scripting/Internal/ManagedDictionary.h @@ -22,17 +22,18 @@ struct FLAXENGINE_API ManagedDictionary public: struct KeyValueType { - MType* keyType; - MType* valueType; + MType* KeyType; + MType* ValueType; bool operator==(const KeyValueType& other) const { - return keyType == other.keyType && valueType == other.valueType; + return KeyType == other.KeyType && ValueType == other.ValueType; } }; private: - static Dictionary CachedDictionaryTypes; + friend class Scripting; + static Dictionary CachedTypes; #if !USE_MONO_AOT typedef MTypeObject* (*MakeGenericTypeThunk)(MObject* instance, MTypeObject* genericType, MArray* genericArgs, MObject** exception); @@ -158,7 +159,7 @@ public: // Check if the generic type was generated earlier KeyValueType cacheKey = { keyType, valueType }; MTypeObject* dictionaryType; - if (CachedDictionaryTypes.TryGet(cacheKey, dictionaryType)) + if (CachedTypes.TryGet(cacheKey, dictionaryType)) return dictionaryType; MTypeObject* genericType = MUtils::GetType(StdTypesContainer::Instance()->DictionaryClass); @@ -186,7 +187,7 @@ public: ex.Log(LogType::Error, TEXT("")); return nullptr; } - CachedDictionaryTypes.Add(cacheKey, dictionaryType); + CachedTypes.Add(cacheKey, dictionaryType); return dictionaryType; } @@ -264,8 +265,8 @@ public: inline uint32 GetHash(const ManagedDictionary::KeyValueType& other) { - uint32 hash = ::GetHash((void*)other.keyType); - CombineHash(hash, ::GetHash((void*)other.valueType)); + uint32 hash = ::GetHash((void*)other.KeyType); + CombineHash(hash, ::GetHash((void*)other.ValueType)); return hash; } diff --git a/Source/Engine/Scripting/Scripting.cpp b/Source/Engine/Scripting/Scripting.cpp index 3a69a7601..a17de075b 100644 --- a/Source/Engine/Scripting/Scripting.cpp +++ b/Source/Engine/Scripting/Scripting.cpp @@ -21,6 +21,7 @@ #include "ManagedCLR/MCore.h" #include "ManagedCLR/MException.h" #include "Internal/StdTypesContainer.h" +#include "Internal/ManagedDictionary.h" #include "Engine/Core/LogContext.h" #include "Engine/Core/ObjectsRemovalService.h" #include "Engine/Core/Types/TimeSpan.h" @@ -720,6 +721,7 @@ void Scripting::Reload(bool canTriggerSceneReload) modules.Clear(); _nonNativeModules.ClearDelete(); _hasGameModulesLoaded = false; + ManagedDictionary::CachedTypes.Clear(); // Release and create a new assembly load context for user assemblies MCore::UnloadScriptingAssemblyLoadContext();