From 9c9b8fcd34f21fb8a754621c5a6ae21cddaca9d9 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Fri, 26 Aug 2022 00:49:14 +0200 Subject: [PATCH] Remove `[Signal]` attribute from events - Remove event as a valid target of `SignalAttribute` - Stop adding the `[Signal]` attribute to events in bindings_generator - Make bindings_generator use the `EventHandler` suffix to be consistent with the C# source generator - Remove obsolete comment about the signal's delegate name --- .../Godot.SourceGenerators/ScriptSignalsGenerator.cs | 4 ---- modules/mono/editor/bindings_generator.cpp | 4 ++-- .../GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs index 161834a4bee..6b06f10db13 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptSignalsGenerator.cs @@ -117,10 +117,6 @@ namespace Godot.SourceGenerators source.Append(symbol.NameWithTypeParameters()); source.Append("\n{\n"); - // TODO: - // The delegate name already needs to end with 'Signal' to avoid collision with the event name. - // Requiring SignalAttribute is redundant. Should we remove it to make declaration shorter? - var members = symbol.GetMembers(); var signalDelegateSymbols = members diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 5e51a285516..d70a1e6c881 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2257,7 +2257,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf } String delegate_name = p_isignal.proxy_name; - delegate_name += "Handler"; // Delegate name is [SignalName]Handler + delegate_name += "EventHandler"; // Delegate name is [SignalName]EventHandler // Generate delegate p_output.append(MEMBER_BEGIN "public delegate void "); @@ -2271,7 +2271,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf // If so, we could store the pointer we get from `data_unique_pointer()` instead of allocating StringName here. // Generate event - p_output.append(MEMBER_BEGIN "[Signal]" MEMBER_BEGIN "public "); + p_output.append(MEMBER_BEGIN "public "); if (p_itype.is_singleton) { p_output.append("static "); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs index 07a214f543f..38e68a89d51 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/SignalAttribute.cs @@ -2,6 +2,6 @@ using System; namespace Godot { - [AttributeUsage(AttributeTargets.Delegate | AttributeTargets.Event)] + [AttributeUsage(AttributeTargets.Delegate)] public class SignalAttribute : Attribute { } }