Skip to content

Commit

Permalink
Merge pull request #57 from BepInEx/fix-layout-unstripping
Browse files Browse the repository at this point in the history
Ensure Proper Layout for Non-ValueTypes
  • Loading branch information
ghorsington authored Dec 11, 2022
2 parents 29a6d92 + 27c3ab9 commit d76d246
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Il2CppInterop.Generator/Passes/Pass79UnstripTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ private static void ProcessType(AssemblyRewriteContext processedAssembly, TypeDe
clonedType.DeclaringType = enclosingNewType;
}

// Unity assemblies sometimes have struct layouts on classes.
// This gets overlooked on mono but not on coreclr.
if (!clonedType.IsValueType && (clonedType.IsExplicitLayout || clonedType.IsSequentialLayout))
{
clonedType.IsExplicitLayout = clonedType.IsSequentialLayout = false;
clonedType.IsAutoLayout = true;
}

processedAssembly.RegisterTypeRewrite(new TypeRewriteContext(processedAssembly, null, clonedType));
processedType = clonedType;
}
Expand Down

0 comments on commit d76d246

Please sign in to comment.