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

Cannot inherit signals from interfaces #80033

Open
Lord-of-Madness opened this issue Jul 29, 2023 · 1 comment · May be fixed by #94440
Open

Cannot inherit signals from interfaces #80033

Lord-of-Madness opened this issue Jul 29, 2023 · 1 comment · May be fixed by #94440

Comments

@Lord-of-Madness
Copy link

Lord-of-Madness commented Jul 29, 2023

Godot version

4.1.stable.mono

System information

Godot v4.1.stable.mono - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Laptop GPU (NVIDIA; 31.0.15.3667) - 11th Gen Intel(R) Core(TM) i9-11900H @ 2.50GHz (16 Threads)

Issue description

Using C# I wanted to have an interface that would ensure that anything implementing such interface would have a certain signal.

In my case IDamagable would have [Signal] public delegate void DamagedEventHandler and anything implementing such interface would have the Damaged signal. However that is not the case. I can access the Handler in the class as IDamagable.DamagedEventHandler but the Damaged method is not generated.
I feel like its sensible thing to want to demand (through interfaces) for things to have signals.

I would have done it thorough inheritance however my class already inherits from something thats not necessarily Damagable and C# doesn't allow multiple inheritance which the Interfaces are supposed to deal with.

Steps to reproduce

public interface IDamagable
    {
        [Signal] public delegate void DamagedEventHandler();
}
public partial class Unit : /*...*/, IDamagable{
     public override void _Ready(){
             Damaged += ()=>{};  //CS0103: The name 'Damaged' does not exist in the current context 
            IDamagable.Damaged  += ()=>{};  //CS0117: IDamagable does not contain definition for Damaged
}
}

Minimal reproduction project

Trivial

@Thomas-X
Copy link

I think this would be a nice improvement, it would require some changes to the source generator. As far as I know the team is currently in feature freeze for 4.2 but I'll have a crack at it the next few days.

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