godot icon indicating copy to clipboard operation
godot copied to clipboard

C# signal callbacks don't work when callbacks are extension methods

Open Byteron opened this issue 2 years ago • 1 comments

Godot version

4.0 Beta 3

System information

Windows 11

Issue description

In C#, signals can be used similar to how Events are used. However, when using functions that are extension methods: image image then I get an error: image It seems to assume the first argument as actual argument, rather than the method owner. With normal C# events this is possible.

Steps to reproduce

  1. create an extension method for some object
  2. connect that method to a signal without parameters
  3. trigger signal

Minimal reproduction project

I think this is easy enough to reproduce in an empty project.

Byteron avatar Oct 15 '22 13:10 Byteron

Has this issue been solved? It seems that I can't reproduce the problem.

image.png

Where

public class Button2{
}

static class Helper {
    public static void Press(this Button2 self) {
        GD.Print("Button2 Pressed.");
    }
}

godot version: commit e29b982dbf06fb7bb32257642687df5093d7327c dotnet version: 6.0.400

NeilKleistGao avatar Nov 28 '22 12:11 NeilKleistGao

I can reproduce it in beta 3 but not in beta 4, so it seems like it was fixed by https://github.com/godotengine/godot/pull/67987.

raulsntos avatar Dec 01 '22 20:12 raulsntos