diff --git a/ILRuntime/CLR/Method/ILMethod.cs b/ILRuntime/CLR/Method/ILMethod.cs index dbf305a1..202e82fa 100644 --- a/ILRuntime/CLR/Method/ILMethod.cs +++ b/ILRuntime/CLR/Method/ILMethod.cs @@ -390,7 +390,7 @@ public List Parameters { get { - if (def.HasParameters && parameters == null) + if (def.HasParameters || parameters == null) { InitParameters(); } diff --git a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs index 48b92455..22dc2960 100644 --- a/ILRuntime/Reflection/ILRuntimeMethodInfo.cs +++ b/ILRuntime/Reflection/ILRuntimeMethodInfo.cs @@ -136,11 +136,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)) + 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 + { + IList aDataList = new List (); + foreach ( T attribute in this.GetCustomAttributes ( inherit ) ) + { + aDataList.Add ( attribute ); + } + return aDataList.ToArray (); + } public override MethodImplAttributes GetMethodImplementationFlags() { 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();