1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

C#: Fix unhandled GD0303 error for nested generic attribute types

This commit is contained in:
Zae
2024-10-11 03:03:05 +08:00
parent 68f053bf82
commit 9c99e519c6
2 changed files with 14 additions and 1 deletions

View File

@@ -395,6 +395,11 @@ public class MustBeVariantAnnotatedMethods
public void MethodWithWrongAttribute()
{
}
[NestedGenericTypeAttributeContainer.NestedGenericTypeAttribute<bool>()]
public void MethodWithNestedAttribute()
{
}
}
[GenericTypeAttribute<bool>()]
@@ -657,3 +662,11 @@ public class ClassNonVariantAnnotated
public class GenericTypeAttribute<[MustBeVariant] T> : Attribute
{
}
public class NestedGenericTypeAttributeContainer
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class NestedGenericTypeAttribute<[MustBeVariant] T> : Attribute
{
}
}

View File

@@ -135,7 +135,7 @@ namespace Godot.SourceGenerators
{
ITypeParameterSymbol? typeParamSymbol = parentSymbol switch
{
IMethodSymbol methodSymbol when parentSyntax.Parent is AttributeSyntax &&
IMethodSymbol methodSymbol when parentSyntax.Ancestors().Any(s => s is AttributeSyntax) &&
methodSymbol.ContainingType.TypeParameters.Length > 0
=> methodSymbol.ContainingType.TypeParameters[typeArgumentIndex],