From e764b3936d87dc4313ad0d666059f5bb5d8341f9 Mon Sep 17 00:00:00 2001 From: m1stm4o <16450904+m1stm4o@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:52:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix=20=E7=94=9F=E6=88=90=E7=9A=84=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=99=A8=E4=B8=AD=E5=90=AB=E6=9C=89=E6=9C=AA=E7=9F=A5?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20TResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs index 73bde9d2..f2e5e3b0 100644 --- a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs +++ b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs @@ -531,7 +531,7 @@ static void GenerateCrossBindingMethodClass(StringBuilder sb, string funcName, i sb.AppendLine(" }"); if (hasReturn) sb.AppendLine(@" else - return default(TResult);"); + return default;"); sb.AppendLine(@" } public override void Invoke(ILTypeInstance instance) From d7ee161b0a096bc5f8da41395c5486bc2510ae4c Mon Sep 17 00:00:00 2001 From: m1stm4o <16450904+m1stm4o@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:53:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix=20=E7=94=9F=E6=88=90=E7=9A=84=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=99=A8=E4=B8=AD=E5=87=BD=E6=95=B0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=88=97=E8=A1=A8=E5=8C=85=E5=90=AB=E4=BA=86?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Enviorment/CrossBindingCodeGenerator.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs index f2e5e3b0..298b8cf6 100644 --- a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs +++ b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs @@ -373,15 +373,6 @@ static string GetParametersTypeString(ParameterInfo[] param, Type returnType) if (isByRef) sb.Append(".MakeByRefType()"); } - if (returnType != typeof(void)) - { - if (!first) - sb.Append(", "); - string clsName, realClsName; - bool isByRef; - returnType.GetClassName(out clsName, out realClsName, out isByRef, true); - sb.Append(realClsName); - } return sb.ToString(); } From 98ca3f5cbaf64e6ac4196ce0776486b82f2a5037 Mon Sep 17 00:00:00 2001 From: m1stm4o <16450904+m1stm4o@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:55:25 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix=20=E7=94=9F=E6=88=90=E7=9A=84=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=99=A8=E4=B8=AD=20out=20=E5=8F=82=E6=95=B0=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=80=BC=E7=B1=BB=E5=9E=8B=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs index 298b8cf6..8035dfb1 100644 --- a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs +++ b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs @@ -593,7 +593,8 @@ static void GenInitParams(StringBuilder sb, ParameterInfo[] param) { if (p.IsOut) { - sb.AppendLine(string.Format(" {0} = default({1});", p.Name, p.ParameterType.GetElementType().FullName)); + p.ParameterType.GetClassName(out var clsName, out var realClsName, out var isByRef, true); + sb.AppendLine(string.Format(" {0} = default({1});", p.Name, realClsName)); } } } From 77273bb59db505702dc1b4afc5e6e503a1818f6b Mon Sep 17 00:00:00 2001 From: m1stm4o <16450904+m1stm4o@users.noreply.github.com> Date: Sun, 26 Mar 2023 23:58:01 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=20protected=20=E8=99=9A?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=8C=85=E5=90=AB=20protected=20=E5=86=85?= =?UTF-8?q?=E5=B5=8C=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs index 8035dfb1..49e5cd8a 100644 --- a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs +++ b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs @@ -322,7 +322,7 @@ static bool ShouldSkip(MethodInfo info) var returnType = info.ReturnType; if (returnType.IsByRef) returnType = returnType.GetElementType(); - if (returnType.IsNotPublic || returnType.IsNested && !returnType.IsNestedPublic) + if (returnType.IsNotPublic || returnType.IsNested && !returnType.IsNestedPublic && !returnType.IsNestedFamily && !returnType.IsNestedFamORAssem) return true; return false; From ceb326545b50cf6dc491e49a3d8caa2bb4890163 Mon Sep 17 00:00:00 2001 From: m1stm4o <16450904+m1stm4o@users.noreply.github.com> Date: Mon, 27 Mar 2023 00:07:32 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix=20=E7=94=9F=E6=88=90=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E5=9F=BA=E7=B1=BB=E7=9A=84=20Property=20?= =?UTF-8?q?=E7=9A=84=20get=20set=20=E8=AE=BF=E9=97=AE=E4=BF=AE=E9=A5=B0?= =?UTF-8?q?=E7=AC=A6=E4=B8=8D=E4=B8=80=E8=87=B4=E6=97=B6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enviorment/CrossBindingCodeGenerator.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs index 49e5cd8a..4023439e 100644 --- a/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs +++ b/ILRuntime/Runtime/Enviorment/CrossBindingCodeGenerator.cs @@ -18,7 +18,8 @@ class PropertyGenerateInfo public Type ReturnType; public string GetterBody; public string SettingBody; - public string Modifier; + public string GetterModifier; + public string SettingModifier; public string OverrideString; } @@ -188,7 +189,6 @@ static void GenerateCrossBindingMethodBody(StringBuilder sb, List vi } else { - pInfo.Modifier = modifier; pInfo.OverrideString = overrideStr; } if (!i.IsAbstract) @@ -221,10 +221,12 @@ static void GenerateCrossBindingMethodBody(StringBuilder sb, List vi { if (isGetter) { + pInfo.GetterModifier = modifier; pInfo.GetterBody = sb.ToString(); } else { + pInfo.SettingModifier = modifier; pInfo.SettingBody = sb.ToString(); } sb = oriBuilder; @@ -243,11 +245,13 @@ static void GenerateCrossBindingMethodBody(StringBuilder sb, List vi string clsName, realClsName; bool isByRef; pInfo.ReturnType.GetClassName(out clsName, out realClsName, out isByRef, true); - sb.AppendLine(string.Format(" {0} {3}{1} {2}", pInfo.Modifier, realClsName, pInfo.Name, pInfo.OverrideString)); + var modifier = pInfo.GetterModifier == "public" || string.IsNullOrEmpty(pInfo.SettingModifier) ? pInfo.GetterModifier : pInfo.SettingModifier; + sb.AppendLine(string.Format(" {0} {3}{1} {2}", modifier, realClsName, pInfo.Name, pInfo.OverrideString)); sb.AppendLine(" {"); if (!string.IsNullOrEmpty(pInfo.GetterBody)) { - sb.AppendLine(" get"); + if (pInfo.GetterModifier == modifier) sb.AppendLine(" get"); + else sb.AppendLine($" {pInfo.GetterModifier} get"); sb.AppendLine(" {"); sb.AppendLine(pInfo.GetterBody); sb.AppendLine(" }"); @@ -255,7 +259,8 @@ static void GenerateCrossBindingMethodBody(StringBuilder sb, List vi } if (!string.IsNullOrEmpty(pInfo.SettingBody)) { - sb.AppendLine(" set"); + if (pInfo.SettingModifier == modifier) sb.AppendLine(" set"); + else sb.AppendLine($" {pInfo.SettingModifier} set"); sb.AppendLine(" {"); sb.AppendLine(pInfo.SettingBody); sb.AppendLine(" }");