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

修复 特性获取 与 绑定泛型参数错误 #630

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion ILRuntime/CLR/Method/ILMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public List<IType> Parameters
{
get
{
if (def.HasParameters && parameters == null)
if (def.HasParameters || parameters == null)
{
InitParameters();
}
Expand Down
13 changes: 12 additions & 1 deletion ILRuntime/Reflection/ILRuntimeMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,22 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit)
List<Attribute> res = new List<Attribute>();
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<T> ( Boolean inherit ) where T : System.Attribute => this.GetCustomAttributes<T> ( inherit ).FirstOrDefault ();
public T [] GetCustomAttributes<T> ( Boolean inherit ) where T : System.Attribute
{
IList<T> aDataList = new List<T> ();
foreach ( T attribute in this.GetCustomAttributes ( inherit ) )
{
aDataList.Add ( attribute );
}
return aDataList.ToArray ();
}

public override MethodImplAttributes GetMethodImplementationFlags()
{
Expand Down
2 changes: 1 addition & 1 deletion ILRuntime/Runtime/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down