diff --git a/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs b/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs index b6a50e0..e72002f 100644 --- a/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs +++ b/Il2CppInspector.Common/Next/Metadata/Il2CppTypeDefinition.cs @@ -1,4 +1,5 @@ using System.Reflection; +using VersionedSerialization; using VersionedSerialization.Attributes; namespace Il2CppInspector.Next.Metadata; @@ -82,4 +83,9 @@ public partial record struct Il2CppTypeDefinition public uint Token { get; private set; } public readonly bool IsValid => NameIndex != 0; + + public int GetEnumElementTypeIndex(StructVersion version) + => version >= MetadataVersions.V350 + ? ParentIndex + : ElementTypeIndex; } \ No newline at end of file diff --git a/Il2CppInspector.Common/Reflection/TypeInfo.cs b/Il2CppInspector.Common/Reflection/TypeInfo.cs index b2af0ce..8c991d7 100644 --- a/Il2CppInspector.Common/Reflection/TypeInfo.cs +++ b/Il2CppInspector.Common/Reflection/TypeInfo.cs @@ -786,10 +786,7 @@ namespace Il2CppInspector.Reflection if (Definition.Bitfield.EnumType) { IsEnum = true; - var enumUnderlyingTypeIndex = Assembly.Model.Package.Version >= MetadataVersions.V350 - ? Definition.ParentIndex - : Definition.ElementTypeIndex; - + var enumUnderlyingTypeIndex = Definition.GetEnumElementTypeIndex(Assembly.Model.Package.Version); enumUnderlyingTypeReference = TypeRef.FromReferenceIndex(Assembly.Model, enumUnderlyingTypeIndex); } diff --git a/Il2CppInspector.Common/Utils/BlobReader.cs b/Il2CppInspector.Common/Utils/BlobReader.cs index ba507d9..0d6705c 100644 --- a/Il2CppInspector.Common/Utils/BlobReader.cs +++ b/Il2CppInspector.Common/Utils/BlobReader.cs @@ -163,9 +163,7 @@ public static class BlobReader var typeHandle = inspector.TypeReferences[typeIndex].Data.KlassIndex; enumType = inspector.TypeDefinitions[typeHandle]; - var elementTypeIndex = inspector.Version >= MetadataVersions.V350 - ? enumType.ParentIndex - : enumType.ElementTypeIndex; + var elementTypeIndex = enumType.GetEnumElementTypeIndex(inspector.Version); var elementTypeHandle = inspector.TypeReferences[elementTypeIndex].Data.KlassIndex; var elementType = inspector.TypeDefinitions[elementTypeHandle]; diff --git a/VersionedSerialization.Generator/VersionedSerialization.Generator.csproj b/VersionedSerialization.Generator/VersionedSerialization.Generator.csproj index ba0dd08..b4f91a5 100644 --- a/VersionedSerialization.Generator/VersionedSerialization.Generator.csproj +++ b/VersionedSerialization.Generator/VersionedSerialization.Generator.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0 latest 4.10 4.10.0