Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
GD0201:委托的名称必须以“EventHandler”结尾
规则 ID |
GD0201 |
类别 |
用法 |
修复是破坏性的还是非破坏性的 |
破坏性的 |
默认启用 |
是 |
原因
用 [Signal]
属性注解的委托拥有不以“EventHandler”结尾的名称。
规则说明
Godot 源生成器将使用移除了“EventHandler”后缀的委托名称生成 C# 事件。在事件中使用的委托名称中添加“EventHandler”后缀是 .NET 命名约定。
对委托使用后缀允许生成的事件使用不带后缀的名称,从而避免命名冲突。
// This delegate is invalid since the name doesn't end with 'EventHandler'.
[Signal]
public void InvalidSignal();
// This delegate is valid since the name ends with 'EventHandler'.
[Signal]
public void ValidSignalEventHandler();
查看 C# 信号文档以获取有关如何声明和使用信号的更多信息。
如何解决违规情况
要修复违反该规则的情况,请将“EventHandler”添加到委托名称的末尾。
何时抑制警告
不要抑制该规则的警告。没有后缀的信号委托将被源生成器忽略,因此该信号不会被注册。