Skip to content

Commit 688f307

Browse files
committed
Core: Fix byref types not being handled
1 parent 84f5a0a commit 688f307

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Cpp2IL.Core/Utils/Il2CppTypeToContext.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ private static TypeAnalysisContext GetPrimitive(this SystemTypesContext context,
4444
return context.AppContext.SystemTypes.GetPrimitive(type.Type);
4545

4646
if (type.Type is Il2CppTypeEnum.IL2CPP_TYPE_CLASS or Il2CppTypeEnum.IL2CPP_TYPE_VALUETYPE)
47-
return context.AppContext.ResolveContextForType(type.AsClass()) ?? throw new($"Could not resolve type context for type {type.AsClass().FullName}");
47+
{
48+
var typeDefContext = context.AppContext.ResolveContextForType(type.AsClass()) ?? throw new($"Could not resolve type context for type {type.AsClass().FullName}");
49+
50+
if (type.Byref == 1)
51+
// Byref types need to be wrapped
52+
return typeDefContext.MakeByReferenceType();
53+
54+
return typeDefContext;
55+
}
4856

4957
if (type.Type is Il2CppTypeEnum.IL2CPP_TYPE_GENERICINST)
5058
return new GenericInstanceTypeAnalysisContext(type, context);

0 commit comments

Comments
 (0)