IL2CPP: Fix regression in Metadata.Sizeof relating to #148

This commit is contained in:
Katy Coe
2021-04-12 18:59:33 +02:00
parent 98157c99ed
commit 0844d4b6bd

View File

@@ -221,14 +221,10 @@ namespace Il2CppInspector
int size = 0; int size = 0;
foreach (var i in type.GetTypeInfo().GetFields()) foreach (var i in type.GetTypeInfo().GetFields())
{ {
// Only process fields for our selected object versioning // Only process fields for our selected object versioning (always process if none supplied)
var versionAttr = i.GetCustomAttribute<VersionAttribute>(false); var versions = i.GetCustomAttributes<VersionAttribute>(false).Select(v => (v.Min, v.Max)).ToList();
if (versionAttr != null) { if (versions.Any() && !versions.Any(v => (v.Min <= metadataVersion || v.Min == -1) && (v.Max >= metadataVersion || v.Max == -1)))
if (versionAttr.Min != -1 && versionAttr.Min > metadataVersion)
continue; continue;
if (versionAttr.Max != -1 && versionAttr.Max < metadataVersion)
continue;
}
if (i.FieldType == typeof(long) || i.FieldType == typeof(ulong)) if (i.FieldType == typeof(long) || i.FieldType == typeof(ulong))
size += longSizeBytes; size += longSizeBytes;