GD0111: Il pulsante tool esportato deve essere una proprietà con corpo di espressione
ID regola |
GD0111 |
Categoria |
Utilizzo |
Soluzione è distruttiva o non-distruttiva |
Non-distruttiva |
Abilitato per predefinito |
Si |
Causa
Una proprietà è annotata con l'attributo [ExportToolButton] ma non è una expression-bodied property.
Descrizione della regola
When reloading the .NET assembly, Godot will attempt to serialize exported
members to preserve their values. A field or a property with a backing field
that stores a Callable may prevent the unloading of the assembly.
An expression-bodied property doesn't have a backing field and won't store
the Callable, so Godot won't attempt to serialize it, which should result
in the successful reloading of the .NET assembly.
[ExportToolButton("Click me!")]
public Callable ValidClickMeButton => Callable.From(ClickMe);
// Invalid because the Callable will be stored in the property's backing field.
[ExportToolButton("Click me!")]
public Callable InvalidClickMeButton { get; } = Callable.From(ClickMe);
Come risolvere le violazioni
Per correggere una violazione di questa regola, sostituire l'implementazione della proprietà con una expression-bodied property.
Quando sopprimere gli avvertimenti
Do not suppress a warning from this rule. Callable instances may prevent
the .NET assembly from unloading.