diff options
| author | Raul Santos <raulsntos@gmail.com> | 2022-08-28 18:16:57 +0200 |
|---|---|---|
| committer | Raul Santos <raulsntos@gmail.com> | 2022-08-28 18:16:57 +0200 |
| commit | 761e2b1a65d40ffc8f8b6912e44c4fcfdb164b6f (patch) | |
| tree | f509d0c52b0c50ea7ab820d6c81d4ffa68cf222c /modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs | |
| parent | f38ea254f334ffa02fb501b336b1a60374c7f945 (diff) | |
| download | redot-engine-761e2b1a65d40ffc8f8b6912e44c4fcfdb164b6f.tar.gz | |
C#: Ignore property indexers and report if exported
Ignore property indexers since they are unsupported and report a
diagnostic if an user tries to export it.
Diffstat (limited to 'modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs')
| -rw-r--r-- | modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs index 3dfa8000ba..e28788ec0b 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs @@ -168,6 +168,32 @@ namespace Godot.SourceGenerators location?.SourceTree?.FilePath)); } + public static void ReportExportedMemberIsIndexer( + GeneratorExecutionContext context, + ISymbol exportedMemberSymbol + ) + { + var locations = exportedMemberSymbol.Locations; + var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); + + string message = $"Attempted to export indexer property: " + + $"'{exportedMemberSymbol.ToDisplayString()}'"; + + string description = $"{message}. Indexer properties can't be exported." + + " Remove the '[Export]' attribute."; + + context.ReportDiagnostic(Diagnostic.Create( + new DiagnosticDescriptor(id: "GD0105", + title: message, + messageFormat: message, + category: "Usage", + DiagnosticSeverity.Error, + isEnabledByDefault: true, + description), + location, + location?.SourceTree?.FilePath)); + } + public static void ReportSignalDelegateMissingSuffix( GeneratorExecutionContext context, INamedTypeSymbol delegateSymbol) |
