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

Custom signals in C# generate compiler errors when using SignalName.xyz #81674

Closed
mickeyordog opened this issue Sep 14, 2023 · 1 comment
Closed

Comments

@mickeyordog
Copy link
Contributor

Godot version

v4.1.1.stable.mono.official [bd6af8e]

System information

MacOS - Ventura 13.4.1

Issue description

In C#, if you create a signal, e.g. from Making your first 2D game:

[Signal]
public delegate void HitEventHandler();

and you emit the signal (same way the tutorial tells you):

EmitSignal(SignalName.Hit);

the SignalName.Hit will give you a compiler error in external IDE's like VS Code, since SignalName.Hit is not defined. However, note that the game will actually run and the signal will work fine in Godot.

I'd like to know if this could be fixed, or otherwise if there is a standard way to solve this problem. I believe a workaround for this issue is to use EmitSignal("nameString") instead of using EmitSignal(SignalName.xyz), however I chose to report this is overall as a bug because the EmitSignal documentation says "Prefer using the names exposed in the SignalName class to avoid allocating a new StringName on each call", which makes me think this feature should be working fine.

Steps to reproduce

  1. Open Mono Project, and create a C# script
  2. Declare a signal like
[Signal]
public delegate void HitEventHandler();

then emit it somewhere like

EmitSignal(SignalName.Hit);
  1. Observe that although Godot will not have a problem with this, IDE's will give a compiler error saying SignalName.Hit is not defined.

Minimal reproduction project

N/A

@raulsntos
Copy link
Member

This is a bug in the Microsoft C# extension for VSCode, their new Roslyn-based LSP doesn't support source generators. Switch back to Omnisharp or wait until they fix it.

This has been previously reported in godotengine/godot-csharp-vscode#57 which may contain more information. I'll be closing this issue since there's nothing we can do on our side.

@raulsntos raulsntos closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
@raulsntos raulsntos added archived and removed bug labels Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants