diff options
| author | Alberto Vilches <194074+avilches@users.noreply.github.com> | 2023-12-25 23:21:09 +0100 |
|---|---|---|
| committer | Alberto Vilches <194074+avilches@users.noreply.github.com> | 2024-01-15 11:31:12 +0100 |
| commit | 7a90c56c00e7d63199bd3abe409622c3c24e0ec5 (patch) | |
| tree | e2ce1d0d75ab6b2ea6a2eafaeab7037ab67a7641 /modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs | |
| parent | 13a0d6e9b253654f5cc2a44f3d0b3cae10440443 (diff) | |
| download | redot-engine-7a90c56c00e7d63199bd3abe409622c3c24e0ec5.tar.gz | |
C# Add test suite for Diagnostic Analyzers: GlobalClass and MustBeVariant
Diffstat (limited to 'modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs')
| -rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs new file mode 100644 index 0000000000..ce182e8c62 --- /dev/null +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/MustBeVariant.GD0302.cs @@ -0,0 +1,27 @@ +using Godot; + +public class MustBeVariantGD0302 +{ + public void MethodOk<[MustBeVariant] T>() + { + // T is guaranteed to be a Variant-compatible type because it's annotated with the [MustBeVariant] attribute, so it can be used here. + new ExampleClass<T>(); + Method<T>(); + } + + public void MethodFail<T>() + { + // These two calls raise a GD0302 diagnostic error: T is not valid here because it may not a Variant type and method call and class require it. + new ExampleClass<{|GD0302:T|}>(); + Method<{|GD0302:T|}>(); + } + + public void Method<[MustBeVariant] T>() + { + } +} + +public class ExampleClass<[MustBeVariant] T> +{ + +} |
