You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user