From d17ba04dedf4d7e57bcf3736e6fada39917345e7 Mon Sep 17 00:00:00 2001 From: Hsiung <848277602@qq.com> Date: Wed, 13 Jul 2022 15:12:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=E5=8F=82=E6=95=B0=E6=97=A0=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC=E7=9A=84=E5=A7=94=E6=89=98=E4=B9=9F=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=BB=91=E5=AE=9A=EF=BC=8C=E4=B8=8D=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E8=B7=B3=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CLRBinding/BindingCodeGenerator.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs b/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs index 4f42b809..8aafdebb 100755 --- a/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs +++ b/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs @@ -648,8 +648,8 @@ internal static List GenerateDelegateBinding(List types, string ou { var mi = i.GetMethod("Invoke"); var miParameters = mi.GetParameters(); - if (mi.ReturnType == typeof(void) && miParameters.Length == 0) - continue; + //if (mi.ReturnType == typeof(void) && miParameters.Length == 0) + // continue; string clsName, realClsName, paramClsName, paramRealClsName; bool isByRef, paramIsByRef; @@ -704,8 +704,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) mi.ReturnType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef); sb.Append(paramRealClsName); sb.AppendLine("> ();"); + sb.AppendLine(); } - else + else if (miParameters.Length != 0) { sb.Append(" app.DelegateManager.RegisterMethodDelegate<"); first = true; @@ -721,8 +722,8 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) sb.Append(paramRealClsName); } sb.AppendLine("> ();"); + sb.AppendLine(); } - sb.AppendLine(); sb.Append(" app.DelegateManager.RegisterDelegateConvertor<"); sb.Append(realClsName); @@ -763,10 +764,14 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) sb.Append(", "); mi.ReturnType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef); sb.Append(paramRealClsName); + sb.Append(">)act)("); } else { - sb.Append(" ((Action<"); + if (miParameters.Length != 0) + sb.Append(" ((Action<"); + else + sb.Append(" ((Action"); first = true; foreach (var j in miParameters) { @@ -779,8 +784,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) j.ParameterType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef); sb.Append(paramRealClsName); } + if (miParameters.Length != 0) + sb.Append(">)act)("); + else + sb.Append(")act)("); } - sb.Append(">)act)("); first = true; foreach (var j in miParameters) {