Fix ContainsGenericParameters and IsGenericMethodDefinition
IsGenericMethodDefinition needs the same treatment as IsGenericTypeDefinition, i.e. it should depend on whether the class is a definition as opposed to merely checking if the type args are generic parameters (which could happen in a partially specialized method). Also, array/ref/pointer types of generic types are considered to have generic parameters, so correct ContainsGenericParameters accordingly.
This commit is contained in:
@@ -59,11 +59,11 @@ namespace Il2CppInspector.Reflection
|
|||||||
public TypeInfo[] GetGenericArguments() => genericArguments;
|
public TypeInfo[] GetGenericArguments() => genericArguments;
|
||||||
|
|
||||||
// This was added in .NET Core 2.1 and isn't properly documented yet
|
// This was added in .NET Core 2.1 and isn't properly documented yet
|
||||||
public bool IsConstructedGenericMethod => IsGenericMethod && genericArguments.All(ga => !ga.ContainsGenericParameters);
|
public bool IsConstructedGenericMethod => IsGenericMethod && !IsGenericMethodDefinition;
|
||||||
|
|
||||||
// See: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.isgenericmethod?view=netframework-4.8
|
// See: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.isgenericmethod?view=netframework-4.8
|
||||||
public bool IsGenericMethod { get; }
|
public bool IsGenericMethod { get; }
|
||||||
public bool IsGenericMethodDefinition => genericArguments.Any() && genericArguments.All(a => a.IsGenericMethodParameter);
|
public bool IsGenericMethodDefinition => (Definition != null) && genericArguments.Any();
|
||||||
|
|
||||||
// TODO: GetMethodBody()
|
// TODO: GetMethodBody()
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace Il2CppInspector.Reflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True if the type contains unresolved generic type parameters
|
// True if the type contains unresolved generic type parameters
|
||||||
public bool ContainsGenericParameters => IsGenericParameter || genericArguments.Any(ga => ga.ContainsGenericParameters);
|
public bool ContainsGenericParameters => (HasElementType && ElementType.ContainsGenericParameters) || IsGenericParameter || genericArguments.Any(ga => ga.ContainsGenericParameters);
|
||||||
|
|
||||||
// Custom attributes for this member
|
// Custom attributes for this member
|
||||||
public override IEnumerable<CustomAttributeData> CustomAttributes => CustomAttributeData.GetCustomAttributes(this);
|
public override IEnumerable<CustomAttributeData> CustomAttributes => CustomAttributeData.GetCustomAttributes(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user