Skip to content

Commit

Permalink
无参数无返回值的委托也需要绑定,不应该跳过
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsiung233 authored and liiir1985 committed Oct 7, 2022
1 parent 479793b commit d17ba04
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ internal static List<string> GenerateDelegateBinding(List<Type> 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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit d17ba04

Please sign in to comment.