1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Improve C# signal analyzer errors

Report the specific parameters that are not supported.
This commit is contained in:
Raul Santos
2022-08-13 06:21:27 +02:00
parent 8a1e598011
commit 3b201c2b04
2 changed files with 52 additions and 7 deletions

View File

@@ -192,15 +192,15 @@ namespace Godot.SourceGenerators
location?.SourceTree?.FilePath));
}
public static void ReportSignalDelegateSignatureNotSupported(
public static void ReportSignalParameterTypeNotSupported(
GeneratorExecutionContext context,
INamedTypeSymbol delegateSymbol)
IParameterSymbol parameterSymbol)
{
var locations = delegateSymbol.Locations;
var locations = parameterSymbol.Locations;
var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault();
string message = "The delegate signature of the signal " +
$"is not supported: '{delegateSymbol.ToDisplayString()}'";
string message = "The parameter of the delegate signature of the signal " +
$"is not supported: '{parameterSymbol.ToDisplayString()}'";
string description = $"{message}. Use supported types only or remove the '[Signal]' attribute.";
@@ -215,5 +215,29 @@ namespace Godot.SourceGenerators
location,
location?.SourceTree?.FilePath));
}
public static void ReportSignalDelegateSignatureMustReturnVoid(
GeneratorExecutionContext context,
INamedTypeSymbol delegateSymbol)
{
var locations = delegateSymbol.Locations;
var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault();
string message = "The delegate signature of the signal " +
$"must return void: '{delegateSymbol.ToDisplayString()}'";
string description = $"{message}. Return void or remove the '[Signal]' attribute.";
context.ReportDiagnostic(Diagnostic.Create(
new DiagnosticDescriptor(id: "GODOT-G0203",
title: message,
messageFormat: message,
category: "Usage",
DiagnosticSeverity.Error,
isEnabledByDefault: true,
description),
location,
location?.SourceTree?.FilePath));
}
}
}