diff --git a/Editor/MethodBridge/Generator.cs b/Editor/MethodBridge/Generator.cs index 185f05e..211dcbd 100644 --- a/Editor/MethodBridge/Generator.cs +++ b/Editor/MethodBridge/Generator.cs @@ -287,6 +287,7 @@ namespace HybridCLR.Editor.MethodBridge CollectStructDefs(_managed2NativeMethodList0, structTypeSet); CollectStructDefs(_native2ManagedMethodList0, structTypeSet); CollectStructDefs(_adjustThunkMethodList0, structTypeSet); + CollectStructDefs(_originalCalliMethodSignatures.Select(m => m.MethodSig).ToList(), structTypeSet); _structTypes0 = structTypeSet.ToList(); _structTypes0.Sort((a, b) => a.TypeId - b.TypeId); @@ -829,6 +830,38 @@ const ReversePInvokeMethodData hybridclr::interpreter::g_reversePInvokeMethodStu } + private void CollectStructDefs(List methods, HashSet structTypes) + { + ICorLibTypes corLibTypes = _genericMethods[0].Method.Module.CorLibTypes; + + foreach (var method in methods) + { + foreach (var paramInfo in method.Params) + { + var paramType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, paramInfo)); + if (paramType.IsStruct) + { + structTypes.Add(paramType); + if (paramType.Klass.ContainsGenericParameter) + { + throw new Exception($"[CollectStructDefs] method:{method} type:{paramType.Klass} contains generic parameter"); + } + } + + } + var returnType = GetSharedTypeInfo(MetaUtil.ToShareTypeSig(corLibTypes, method.RetType)); + if (returnType.IsStruct) + { + structTypes.Add(returnType); + if (returnType.Klass.ContainsGenericParameter) + { + throw new Exception($"[CollectStructDefs] method:{method} type:{returnType.Klass} contains generic parameter"); + } + } + } + + } + class FieldInfo { public FieldDef field;