add fallback if InlineArrayAttribute does not exist

This commit is contained in:
LukeFZ
2026-02-28 03:53:29 +01:00
parent 7f60c05233
commit bcd25f4b8c

View File

@@ -88,7 +88,7 @@ namespace Il2CppInspector.Outputs
private TypeDef tokenAttribute;
// Runtime attributes we need to add
private TypeInfo inlineArrayAttribute;
private TypeInfo? inlineArrayAttribute;
// The namespace for our custom types
private const string rootNamespace = "Il2CppInspector.DLL";
@@ -168,7 +168,7 @@ namespace Il2CppInspector.Outputs
{
if (model.Package.Version >= MetadataVersions.V1040)
{
inlineArrayAttribute = model.TypesByFullName["System.Runtime.CompilerServices.InlineArrayAttribute"];
inlineArrayAttribute = model.TypesByFullName.GetValueOrDefault("System.Runtime.CompilerServices.InlineArrayAttribute");
}
}
@@ -303,7 +303,7 @@ namespace Il2CppInspector.Outputs
if (model.Package.Version >= MetadataVersions.V1040)
{
// L-TODO: Verify if we actually need to add the attribute ourselves; it might just be preserved
if (type.HasInlineArray)
if (type.HasInlineArray && inlineArrayAttribute != null)
{
var typeRef = GetTypeRef(module, inlineArrayAttribute);
var ctorRef = new MemberRefUser(typeRef.Module, ".ctor",