From d3fc2025a74e77e63343bbef9801ea6da53f3d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=B9=96=E5=B7=9D?= Date: Mon, 20 Dec 2021 16:37:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/CLR/Method/ILMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILRuntime/CLR/Method/ILMethod.cs b/ILRuntime/CLR/Method/ILMethod.cs index 6423d78b..ff9dd988 100644 --- a/ILRuntime/CLR/Method/ILMethod.cs +++ b/ILRuntime/CLR/Method/ILMethod.cs @@ -365,7 +365,7 @@ public List Parameters { get { - if (def.HasParameters && parameters == null) + if (def.HasParameters || parameters == null) { InitParameters(); } From cce351d0be2df453df13bc205ea4deb4a61c78e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=B9=96=E5=B7=9D?= Date: Mon, 20 Dec 2021 17:07:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=89=B9=E6=80=A7=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Reflection/ILRuntimeMethodInfo.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs index ed2218bc..7a1c13c7 100644 --- a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs +++ b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs @@ -135,11 +135,14 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit) List res = new List(); for (int i = 0; i < customAttributes.Length; i++) { - if (attributeTypes[i].Equals(attributeType)) + if (attributeTypes[i].Equals(attributeType)||attributeType.IsAssignableFrom ( attributeTypes[i] )) res.Add(customAttributes[i]); } return res.ToArray(); } + public Object GetCustomAttribute ( Type oType, Boolean inherit ) => this.GetCustomAttributes ( oType, inherit ).FirstOrDefault (); + public T GetCustomAttribute ( Boolean inherit ) where T : System.Attribute => this.GetCustomAttributes ( inherit ).FirstOrDefault (); + public T [] GetCustomAttributes ( Boolean inherit ) where T : System.Attribute => this.GetCustomAttributes ( typeof ( T ), inherit ).Select ( t => ( T ) t ).ToArray (); public override MethodImplAttributes GetMethodImplementationFlags() { From 170a3efbbf509e612c25c24dc26eaa89a4e5a3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=B9=96=E5=B7=9D?= Date: Thu, 23 Dec 2021 02:15:41 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E7=BB=91=E5=AE=9A=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20=E6=B3=9B=E5=9E=8B=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Runtime/Extensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILRuntime/Runtime/Extensions.cs b/ILRuntime/Runtime/Extensions.cs index e9d4f1c3..4cecb37c 100644 --- a/ILRuntime/Runtime/Extensions.cs +++ b/ILRuntime/Runtime/Extensions.cs @@ -375,7 +375,7 @@ public static bool MatchGenericParameters(this Type[] args, Type type, Type q, T if (q.IsGenericType) { var t1 = type.GetGenericTypeDefinition(); - var t2 = type.GetGenericTypeDefinition(); + var t2 = q.GetGenericTypeDefinition(); if (t1 == t2) { var argA = type.GetGenericArguments(); From 72f1bb78d14d050357ea9df100e6ff2f32956716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=B9=96=E5=B7=9D?= Date: Fri, 18 Feb 2022 20:55:06 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ILRuntime/Reflection/ILRuntimeMethodInfo.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs index 7a1c13c7..cb2ed115 100644 --- a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs +++ b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs @@ -135,14 +135,22 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit) List res = new List(); for (int i = 0; i < customAttributes.Length; i++) { - if (attributeTypes[i].Equals(attributeType)||attributeType.IsAssignableFrom ( attributeTypes[i] )) + if (attributeTypes[i].Equals(attributeType)||(inherit&&(attributeType.IsAssignableFrom(attributeTypes[i])||attributeTypes[i].BaseType!=null&&attributeType.IsAssignableFrom(attributeTypes[i].BaseType)))) res.Add(customAttributes[i]); } return res.ToArray(); } public Object GetCustomAttribute ( Type oType, Boolean inherit ) => this.GetCustomAttributes ( oType, inherit ).FirstOrDefault (); public T GetCustomAttribute ( Boolean inherit ) where T : System.Attribute => this.GetCustomAttributes ( inherit ).FirstOrDefault (); - public T [] GetCustomAttributes ( Boolean inherit ) where T : System.Attribute => this.GetCustomAttributes ( typeof ( T ), inherit ).Select ( t => ( T ) t ).ToArray (); + public T [] GetCustomAttributes ( Boolean inherit ) where T : System.Attribute + { + IList aDataList = new List (); + foreach ( T attribute in this.GetCustomAttributes ( inherit ) ) + { + aDataList.Add ( attribute ); + } + return aDataList.ToArray (); + } public override MethodImplAttributes GetMethodImplementationFlags() {