diff options
| author | Zae <zaevi@live.com> | 2024-10-11 03:03:05 +0800 |
|---|---|---|
| committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-01 18:10:51 -0400 |
| commit | 9b426095641910f8fb0208d38ac0dc4051756c3d (patch) | |
| tree | c4f613b2f61df3e8c4c3560228bde8a06ddc3e48 | |
| parent | 00ee33b2f9efdcf28c690501593f76ed38a609f5 (diff) | |
| download | redot-engine-9b426095641910f8fb0208d38ac0dc4051756c3d.tar.gz | |
C#: Fix unhandled GD0303 error for nested generic attribute types
(cherry picked from commit 9c99e519c61323f0972fb0aa4b3c59cb889ee970)
2 files changed, 14 insertions, 1 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs index 053ae36ae7..5654060d38 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0301.cs @@ -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 + { + } +} diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs index e894e7a86c..a72a8c5880 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MustBeVariantAnalyzer.cs @@ -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], |
