[.NET] Disallow [ExportToolButton] on members thay may store the Callable

Ensures the user doesn't store the Callable so the .NET assembly can be reloaded.
This commit is contained in:
Raul Santos 2025-02-13 22:10:26 +01:00
parent 36d90c73a8
commit f4094b554d
No known key found for this signature in database
GPG key ID: B532473AE3A803E4
14 changed files with 263 additions and 38 deletions

View file

@ -137,6 +137,16 @@ namespace Godot.SourceGenerators
"The exported tool button is not a Callable. The '[ExportToolButton]' attribute is only supported on members of type Callable.",
helpLinkUri: string.Format(_helpLinkFormat, "GD0110"));
public static readonly DiagnosticDescriptor ExportToolButtonMustBeExpressionBodiedProperty =
new DiagnosticDescriptor(id: "GD0111",
title: "The exported tool button must be an expression-bodied property",
messageFormat: "The exported tool button '{0}' must be an expression-bodied property",
category: "Usage",
DiagnosticSeverity.Error,
isEnabledByDefault: true,
"The exported tool button must be an expression-bodied property. The '[ExportToolButton]' attribute is only supported on expression-bodied properties with a 'new Callable(...)' or 'Callable.From(...)' expression.",
helpLinkUri: string.Format(_helpLinkFormat, "GD0111"));
public static readonly DiagnosticDescriptor SignalDelegateMissingSuffixRule =
new DiagnosticDescriptor(id: "GD0201",
title: "The name of the delegate must end with 'EventHandler'",