[fix] 修复计算 MonoPInvokeCallback的CallingConvention时,如果delegate在其他程序集中定义,会被错误当作Winapi,导致wrapper签名计算错误的bug

main
walon 2024-05-30 12:10:52 +08:00
parent d431aeb019
commit fc685a99ca
1 changed files with 3 additions and 3 deletions

View File

@ -404,7 +404,7 @@ namespace HybridCLR.Editor.MethodBridge
TypeDef delegateTypeDef;
if (delegateTypeSig is ClassSig classSig)
{
delegateTypeDef = classSig.TypeDef;
delegateTypeDef = classSig.TypeDefOrRef.ResolveTypeDefThrow();
}
else if (delegateTypeSig is GenericInstSig genericInstSig)
{
@ -412,12 +412,12 @@ namespace HybridCLR.Editor.MethodBridge
}
else
{
throw new NotSupportedException($"Unsupported delegate type {delegateTypeSig.GetType()}");
delegateTypeDef = null;
}
if (delegateTypeDef == null)
{
return CallingConvention.Winapi;
throw new NotSupportedException($"Unsupported delegate type: {delegateTypeSig}");
}
var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute");
if (attr == null)