Output: Don't include nested generic type parameters in generic type usages (CS0305)
This commit is contained in:
@@ -66,18 +66,22 @@ namespace Il2CppInspector.Reflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// C# name as it would be written in a type declaration
|
// C# name as it would be written in a type declaration
|
||||||
public string CSharpTypeDeclarationName =>
|
public string CSharpTypeDeclarationName {
|
||||||
(IsByRef? "ref " : "")
|
get {
|
||||||
+ (HasElementType?
|
var gtp = IsNested? GenericTypeParameters?.Where(p => DeclaringType.GenericTypeParameters?.All(dp => dp.Name != p.Name) ?? true) : GenericTypeParameters;
|
||||||
ElementType.CSharpTypeDeclarationName :
|
|
||||||
((GenericParameterAttributes & GenericParameterAttributes.Contravariant) == GenericParameterAttributes.Contravariant? "in " : "")
|
return (IsByRef ? "ref " : "")
|
||||||
+ ((GenericParameterAttributes & GenericParameterAttributes.Covariant) == GenericParameterAttributes.Covariant? "out ":"")
|
+ (HasElementType
|
||||||
+ (base.Name.IndexOf("`", StringComparison.Ordinal) == -1 ? base.Name : base.Name.Remove(base.Name.IndexOf("`", StringComparison.Ordinal)))
|
? ElementType.CSharpTypeDeclarationName
|
||||||
+ ((IsNested? GenericTypeParameters?.Where(p => DeclaringType.GenericTypeParameters?.All(dp => dp.Name != p.Name) ?? true) : GenericTypeParameters)?.Any() ?? false?
|
: ((GenericParameterAttributes & GenericParameterAttributes.Contravariant) == GenericParameterAttributes.Contravariant ? "in " : "")
|
||||||
"<" + string.Join(", ", GenericTypeParameters.Select(x => x.CSharpTypeDeclarationName)) + ">" : "")
|
+ ((GenericParameterAttributes & GenericParameterAttributes.Covariant) == GenericParameterAttributes.Covariant ? "out " : "")
|
||||||
+ (GenericTypeArguments != null ? "<" + string.Join(", ", GenericTypeArguments.Select(x => (!x.IsGenericTypeParameter? x.Namespace + "." : "") + x.CSharpTypeDeclarationName)) + ">" : ""))
|
+ (base.Name.IndexOf("`", StringComparison.Ordinal) == -1 ? base.Name : base.Name.Remove(base.Name.IndexOf("`", StringComparison.Ordinal)))
|
||||||
+ (IsArray ? "[" + new string(',', GetArrayRank() - 1) + "]" : "")
|
+ (gtp?.Any() ?? false? "<" + string.Join(", ", gtp.Select(x => x.CSharpTypeDeclarationName)) + ">" : "")
|
||||||
+ (IsPointer ? "*" : "");
|
+ (GenericTypeArguments != null ? "<" + string.Join(", ", GenericTypeArguments.Select(x => (!x.IsGenericTypeParameter ? x.Namespace + "." : "") + x.CSharpTypeDeclarationName)) + ">" : ""))
|
||||||
|
+ (IsArray ? "[" + new string(',', GetArrayRank() - 1) + "]" : "")
|
||||||
|
+ (IsPointer ? "*" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
@@ -138,20 +138,20 @@ namespace Il2CppTests.TestSources
|
|||||||
public NestedWithAutomaticConstraints() {}
|
public NestedWithAutomaticConstraints() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameter<R, T> // TypeDefIndex: 1823
|
private class NestedWithNewGenericParameter<T> // TypeDefIndex: 1823
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameter() {}
|
public NestedWithNewGenericParameter() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndConstraint<R, T> // TypeDefIndex: 1824
|
private class NestedWithNewGenericParameterAndConstraint<T> // TypeDefIndex: 1824
|
||||||
where T : new()
|
where T : new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameterAndConstraint() {}
|
public NestedWithNewGenericParameterAndConstraint() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndDependentConstraint<R, T> // TypeDefIndex: 1825
|
private class NestedWithNewGenericParameterAndDependentConstraint<T> // TypeDefIndex: 1825
|
||||||
where T : G<R>, new()
|
where T : G<R>, new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
@@ -211,7 +211,7 @@ namespace Il2CppTests.TestSources
|
|||||||
public SubInnerGeneric2() {}
|
public SubInnerGeneric2() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SubInnerGeneric3<T1, T2, V> // TypeDefIndex: 1832
|
public class SubInnerGeneric3<V> // TypeDefIndex: 1832
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public SubInnerGeneric3() {}
|
public SubInnerGeneric3() {}
|
||||||
|
|||||||
@@ -138,20 +138,20 @@ namespace Il2CppTests.TestSources
|
|||||||
public NestedWithAutomaticConstraints() {}
|
public NestedWithAutomaticConstraints() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameter<R, T> // TypeDefIndex: 1823
|
private class NestedWithNewGenericParameter<T> // TypeDefIndex: 1823
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameter() {}
|
public NestedWithNewGenericParameter() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndConstraint<R, T> // TypeDefIndex: 1824
|
private class NestedWithNewGenericParameterAndConstraint<T> // TypeDefIndex: 1824
|
||||||
where T : new()
|
where T : new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameterAndConstraint() {}
|
public NestedWithNewGenericParameterAndConstraint() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndDependentConstraint<R, T> // TypeDefIndex: 1825
|
private class NestedWithNewGenericParameterAndDependentConstraint<T> // TypeDefIndex: 1825
|
||||||
where T : G<R>, new()
|
where T : G<R>, new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
@@ -211,7 +211,7 @@ namespace Il2CppTests.TestSources
|
|||||||
public SubInnerGeneric2() {}
|
public SubInnerGeneric2() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SubInnerGeneric3<T1, T2, V> // TypeDefIndex: 1832
|
public class SubInnerGeneric3<V> // TypeDefIndex: 1832
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public SubInnerGeneric3() {}
|
public SubInnerGeneric3() {}
|
||||||
|
|||||||
@@ -138,20 +138,20 @@ namespace Il2CppTests.TestSources
|
|||||||
public NestedWithAutomaticConstraints() {}
|
public NestedWithAutomaticConstraints() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameter<R, T> // TypeDefIndex: 1823
|
private class NestedWithNewGenericParameter<T> // TypeDefIndex: 1823
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameter() {}
|
public NestedWithNewGenericParameter() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndConstraint<R, T> // TypeDefIndex: 1824
|
private class NestedWithNewGenericParameterAndConstraint<T> // TypeDefIndex: 1824
|
||||||
where T : new()
|
where T : new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public NestedWithNewGenericParameterAndConstraint() {}
|
public NestedWithNewGenericParameterAndConstraint() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NestedWithNewGenericParameterAndDependentConstraint<R, T> // TypeDefIndex: 1825
|
private class NestedWithNewGenericParameterAndDependentConstraint<T> // TypeDefIndex: 1825
|
||||||
where T : G<R>, new()
|
where T : G<R>, new()
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
@@ -211,7 +211,7 @@ namespace Il2CppTests.TestSources
|
|||||||
public SubInnerGeneric2() {}
|
public SubInnerGeneric2() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SubInnerGeneric3<T1, T2, V> // TypeDefIndex: 1832
|
public class SubInnerGeneric3<V> // TypeDefIndex: 1832
|
||||||
{
|
{
|
||||||
// Constructors
|
// Constructors
|
||||||
public SubInnerGeneric3() {}
|
public SubInnerGeneric3() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user