[fix] 修复StructLayout中只指定LayoutKind参数时,struct的ClassLayout为空,计算type size和aligment错误的bug
parent
b40d62e16e
commit
947b15e7d9
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HybridCLR.Editor.ABI
|
||||
{
|
||||
|
@ -74,6 +75,10 @@ namespace HybridCLR.Editor.ABI
|
|||
case ElementType.ValueType:
|
||||
{
|
||||
TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef();
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new Exception($"type:{type} 未能找到定义。请尝试 `HybridCLR/Genergate/LinkXml`,然后Build一次生成AOT dll,再重新生成桥接函数");
|
||||
}
|
||||
if (typeDef.IsEnum)
|
||||
{
|
||||
return CreateTypeInfo(typeDef.GetEnumUnderlyingType());
|
||||
|
|
|
@ -74,11 +74,11 @@ namespace HybridCLR.Editor.ABI
|
|||
{
|
||||
continue;
|
||||
}
|
||||
if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout))
|
||||
if (typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout))
|
||||
{
|
||||
int offset = (int)field.FieldOffset.Value;
|
||||
totalSize = Math.Max(totalSize, offset + fs);
|
||||
if (offset > sa.ClassSize)
|
||||
if (sa != null && offset > sa.ClassSize)
|
||||
{
|
||||
useSLSize = false;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace HybridCLR.Editor.ABI
|
|||
totalSize = (totalSize + fa - 1) / fa * fa;
|
||||
}
|
||||
totalSize += fs;
|
||||
if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.SequentialLayout) && totalSize > sa.ClassSize)
|
||||
if (sa != null && totalSize > sa.ClassSize)
|
||||
{
|
||||
useSLSize = false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "1.1.12",
|
||||
"version": "1.1.13",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
|
Loading…
Reference in New Issue