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# Generics Deriving Godot.Object Cannot Be Marshalled Over Signals #47510

Closed
kayomn opened this issue Mar 30, 2021 · 0 comments · Fixed by #53581
Closed

C# Generics Deriving Godot.Object Cannot Be Marshalled Over Signals #47510

kayomn opened this issue Mar 30, 2021 · 0 comments · Fixed by #53581

Comments

@kayomn
Copy link
Contributor

kayomn commented Mar 30, 2021

Godot version:
Godot 3.3 RC 7

OS/device including version:
OS: Manjaro Linux x86_64
Kernel: 5.9.16-1-MANJARO
CPU: AMD Ryzen 7 1700X (16) @ 3.400GHz
GPU: AMD ATI Radeon RX 5600 XT

Issue description:
Godot's marshalling logic does not account for signals with generic argument types extend Godot.Object.

This means that patterns to avoid the issue of not being able to pass structs over Godot signals, such as using a generic Box<T> type, do not work.

case MONO_TYPE_GENERICINST: {

The issue appears to be in how Godot handles generic instances when doing coersion from Mono type info to Godot variant type info, as it will discard any generic that is not a hardcoded exception, such as the generic collection interfaces.

It should be noted that passing generic types that extend Godot.Object to regular Godot functions works fine.

Steps to reproduce:

public class Box<T> : Godot.Object where T : struct
{
    public T Value
    {
        get;
        private set;
    }

    public Box(in T value)
    {
        Value = value;
    }
}

Attempt to declare a Godot signal that uses the above generic type

Minimal reproduction project:
MinimalReproduction.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants