From 846d7103a3ae371759d10c421e1d0949e963d5b3 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 30 May 2024 12:26:48 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E8=AE=A1=E7=AE=97=20?= =?UTF-8?q?MonoPInvokeCallback=E7=9A=84CallingConvention=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9Cdelegate=E5=9C=A8=E5=85=B6=E4=BB=96=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E9=9B=86=E4=B8=AD=E5=AE=9A=E4=B9=89=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E8=A2=AB=E9=94=99=E8=AF=AF=E5=BD=93=E4=BD=9CWinapi=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4wrapper=E7=AD=BE=E5=90=8D=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/ReversePInvokeWrap/Analyzer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Editor/ReversePInvokeWrap/Analyzer.cs b/Editor/ReversePInvokeWrap/Analyzer.cs index f3ef62a..891c1c6 100644 --- a/Editor/ReversePInvokeWrap/Analyzer.cs +++ b/Editor/ReversePInvokeWrap/Analyzer.cs @@ -93,7 +93,7 @@ namespace HybridCLR.Editor.ReversePInvokeWrap TypeDef delegateTypeDef; if (delegateTypeSig is ClassSig classSig) { - delegateTypeDef = classSig.TypeDef; + delegateTypeDef = classSig.TypeDefOrRef.ResolveTypeDefThrow(); } else if (delegateTypeSig is GenericInstSig genericInstSig) { @@ -101,12 +101,12 @@ namespace HybridCLR.Editor.ReversePInvokeWrap } else { - throw new NotSupportedException($"Unsupported delegate type {delegateTypeSig.GetType()}"); + delegateTypeDef = null; } if (delegateTypeDef == null) { - return CallingConvention.Winapi; + throw new NotSupportedException($"Unsupported delegate type {delegateTypeSig.GetType()}"); } var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"); if (attr == null)