Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GD0201: The name of the delegate must end with 'EventHandler'

规则 ID

GD0201

类别

用法

修复是中断修复还是非中断修复

中断

默认启用

原因

A delegate annotated with the [Signal] attribute has a name that doesn't end with 'EventHandler'.

规则说明

Godot source generators will generate C# events using the name of the delegate with the 'EventHandler' suffix removed. Adding the 'EventHandler' suffix to the name of delegates used in events is a .NET naming convention.

Using a suffix for the delegate allows the generated event to use the name without the suffix avoiding a naming conflict.

// 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();

Take a look at the C# signals documentation for more information about how to declare and use signals.

如何解决冲突

To fix a violation of this rule, add 'EventHandler' to the end of the delegate name.

何时禁止显示警告

Do not suppress a warning from this rule. Signal delegates without the suffix will be ignored by the source generator, so the signal won't be registered.