From 761e2b1a65d40ffc8f8b6912e44c4fcfdb164b6f Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Sun, 28 Aug 2022 18:16:57 +0200 Subject: 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. --- .../Godot.NET.Sdk/Godot.SourceGenerators/Common.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs') 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) -- cgit v1.2.3