Avoid recreating ref'd types that already exist

Because TypesByReferenceIndex can be populated in two places
(Il2CppModel constructor and GetTypeFromVirtualAddress), we need to
avoid generating the same type multiple times.
This commit is contained in:
Robert Xiao
2020-04-10 20:18:35 -07:00
committed by Katy
parent 71bf353ae0
commit 996fb1ff36

View File

@@ -73,6 +73,11 @@ namespace Il2CppInspector.Reflection
// Create and reference types from TypeRefs
// Note that you can't resolve any TypeRefs until all the TypeDefs have been processed
for (int typeRefIndex = 0; typeRefIndex < package.TypeReferences.Count; typeRefIndex++) {
if(TypesByReferenceIndex[typeRefIndex] != null) {
/* type already generated - probably by forward reference through GetTypeFromVirtualAddress */
continue;
}
var typeRef = Package.TypeReferences[typeRefIndex];
var referencedType = TypeInfo.FromTypeReference(this, typeRef);