Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Generate signal delegates with typed arrays #94953

Merged

Conversation

raulsntos
Copy link
Member

I found out we were generating the C# signal delegates without using the type generic parameters. This means for a signal with a parameter of type TypedArray<StringName> we were using type Array. The signal delegate generation now matches the method generation more closely.

Changing this would normally break compatibility, luckily there's only one signal in Godot that uses a generic type (GraphEdit::delete_nodes_request) and GraphEdit is marked experimental.

Also took the opportunity to remove an unused String in the C# bindings generator: delegate_type_params.

Signals with typed arrays were generating C# delegates with untyped arrays.
@raulsntos raulsntos added this to the 4.4 milestone Jul 30, 2024
@raulsntos raulsntos requested a review from a team as a code owner July 30, 2024 17:48
@paulloz
Copy link
Member

paulloz commented Sep 22, 2024

Everything seem to work as intended. Looks good to me 👍

Here is the full diff on the generated glue.

--- GraphEdit.cs        2024-09-22 11:30:00.947689600 +0200
+++ GraphEdit.cs        2024-09-22 11:24:14.966598300 +0200
@@ -1308,12 +1308,12 @@
     /// <summary>
     /// Represents the method that handles the <see cref="Godot.GraphEdit.DeleteNodesRequest"/> event of a <see cref="Godot.GraphEdit"/> 
class.
     /// </summary>
-    public delegate void DeleteNodesRequestEventHandler(Godot.Collections.Array nodes);
+    public delegate void DeleteNodesRequestEventHandler(Godot.Collections.Array<StringName> nodes);
 
     private static void DeleteNodesRequestTrampoline(object delegateObj, NativeVariantPtrArgs args, out godot_variant ret)
     {
         Callable.ThrowIfArgCountMismatch(args, 1);
-        ((DeleteNodesRequestEventHandler)delegateObj)(VariantUtils.ConvertToArray(args[0]));
+        ((DeleteNodesRequestEventHandler)delegateObj)(new Godot.Collections.Array<StringName>(VariantUtils.ConvertToArray(args[0])));    
         ret = default;
     }

@akien-mga akien-mga merged commit c65ab71 into godotengine:master Sep 23, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@raulsntos raulsntos deleted the dotnet/signals-with-typed-arrays branch September 23, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants