Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无参数无返回值的委托也需要绑定,不应该跳过 #714

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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