From 8136d488b26159fb132a1ad62064af54d3fda756 Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 16 Sep 2024 18:01:38 -0700 Subject: [PATCH] .NET: Move list creation into write lock --- csharp-api/REFrameworkNET/TypeDefinition.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/csharp-api/REFrameworkNET/TypeDefinition.cpp b/csharp-api/REFrameworkNET/TypeDefinition.cpp index 5e37f866..8c48cd30 100644 --- a/csharp-api/REFrameworkNET/TypeDefinition.cpp +++ b/csharp-api/REFrameworkNET/TypeDefinition.cpp @@ -302,15 +302,16 @@ namespace REFrameworkNET { System::Collections::Generic::List^ TypeDefinition::GetRuntimeMethods() { if (m_runtimeMethods == nullptr) { - m_runtimeMethods = gcnew System::Collections::Generic::List(); auto runtimeType = GetRuntimeType(); m_lock->EnterWriteLock(); + m_runtimeMethods = gcnew System::Collections::Generic::List(); + try { if (runtimeType != nullptr) { auto methods = (REFrameworkNET::ManagedObject^)runtimeType->Call("GetMethods(System.Reflection.BindingFlags)", System::Reflection::BindingFlags::Public | System::Reflection::BindingFlags::NonPublic | System::Reflection::BindingFlags::Instance | System::Reflection::BindingFlags::Static); - + if (methods != nullptr) { for each (REFrameworkNET::ManagedObject^ method in methods) { if (method == nullptr) {