@@ -13,8 +13,8 @@ namespace Cpp2IL.Core.Utils.AsmResolver;
1313
1414public static class AsmResolverUtils
1515{
16- private static readonly Dictionary < string , TypeDefinition ? > CachedTypeDefsByName = new ( ) ;
17- private static readonly Dictionary < string , TypeSignature ? > CachedTypeSignaturesByName = new ( ) ;
16+ private static readonly ConcurrentDictionary < string , TypeDefinition ? > CachedTypeDefsByName = new ( ) ;
17+ private static readonly ConcurrentDictionary < string , TypeSignature ? > CachedTypeSignaturesByName = new ( ) ;
1818 private static readonly ConcurrentDictionary < AssemblyDefinition , ReferenceImporter > ImportersByAssembly = new ( ) ;
1919
2020 public static readonly ConcurrentDictionary < long , TypeDefinition > TypeDefsByIndex = new ( ) ;
@@ -222,7 +222,13 @@ public static ITypeDefOrRef ImportReferenceFromIl2CppType(ModuleDefinition modul
222222 && string . Equals ( t . Definition . FullName . Replace ( '/' , '.' ) , name , StringComparison . OrdinalIgnoreCase ) ;
223223 } ) ;
224224
225- return definedType ? . GetExtraData < TypeDefinition > ( "AsmResolverType" ) ;
225+ ret = definedType ? . GetExtraData < TypeDefinition > ( "AsmResolverType" ) ;
226+
227+ if ( ret == null )
228+ return null ;
229+
230+ CachedTypeDefsByName . TryAdd ( key , ret ) ;
231+ return ret ;
226232 }
227233
228234 public static TypeSignature ? TryLookupTypeSignatureByName ( string ? name , ReadOnlySpan < string > genericParameterNames = default )
@@ -238,7 +244,7 @@ public static ITypeDefOrRef ImportReferenceFromIl2CppType(ModuleDefinition modul
238244 var result = InternalTryLookupTypeSignatureByName ( name , genericParameterNames ) ;
239245
240246 if ( genericParameterNames . Length == 0 )
241- CachedTypeSignaturesByName [ key ] = result ;
247+ CachedTypeSignaturesByName . TryAdd ( key , result ) ;
242248
243249 return result ;
244250 }
0 commit comments