Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
GD0203: The delegate signature of the signal must return void¶
Regel-ID |
GD0203 |
Kategorie |
Verwendung |
Breaking- oder nicht-Breaking-Fix |
Breaking - If the return type is changed Non-breaking - If the |
Standardmäßig aktiviert |
Ja |
Ursache¶
A delegate annotated with the [Signal]
attribute has a return type when
void
was expected.
Beschreibung der Regel¶
Every signal must return void
. There can be multiple callbacks registered
for each signal, if signal callbacks could return something it wouldn't be
possible to determine which of the returned values to use.
// This signal delegate is invalid because it doesn't return void.
public int InvalidSignalEventHandler();
// This signal delegate is valid because it returns void.
public void ValidSignalEventHandler();
Take a look at the C# signals documentation for more information about how to declare and use signals.
Wie man Verstöße behebt¶
To fix a violation of this rule, change the delegate to return void
or
remove the [Signal]
attribute from the delegate. Note that removing the
attribute will mean the signal is not registered.
Tipp
If the signal doesn't need to interact with Godot, consider using C# events directly. Pure C# events allow you to use any C# type for its parameters.
Wann Warnungen unterdrückt werden sollten¶
Do not suppress a warning from this rule. Signal delegates that return something will result in unexpected runtime errors.