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

Naming a C# field @new cause Godot to generate invalid C# code #74839

Closed
atom-dispencer opened this issue Mar 12, 2023 · 2 comments · Fixed by #93198
Closed

Naming a C# field @new cause Godot to generate invalid C# code #74839

atom-dispencer opened this issue Mar 12, 2023 · 2 comments · Fixed by #93198

Comments

@atom-dispencer
Copy link

atom-dispencer commented Mar 12, 2023

Godot version

4.0-stable-mono

System information

Windows 10, Intel, Visual Studio Community 2022

Issue description

Naming a C# field @new causes Godot to generate invalid C# code. The field can be a class or method member.

This can be seen in these screenshots:

  1. (above) - The invalid code. Left: The @new. Right: The invalid C++ code.
  2. (below) - The same snippet as above, but renamed @new to a name which Godot can handle.

image
image

Steps to reproduce

  1. Create a C# script for Godot
  2. Open in Visual Studio (untested in VSCode or other editors)
  3. Name a field @new. Note that this is valid C# code.
  4. Build the .NET project.
  5. The build will fail with compilation errors because Godot has generated invalid C# code, trying to name a field new (no @ symbol.

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Mar 21, 2023

I suppose this occurs with any reserved C# keyword, not just new.

PS: The code on the right is C#, not C++.

@Calinou Calinou changed the title Naming a C# field @new cause Godot to generate invalid C++ code Naming a C# field @new cause Godot to generate invalid C# code Mar 21, 2023
@atom-dispencer
Copy link
Author

atom-dispencer commented Mar 21, 2023

I assume so, but have not checked this.

I've also now changed C++ in the report to C# because yeah you're right it's C#.
For some reason I assumed it was C++ but looking at it now it's fairly obvious that it's C# (I mean the file extension ends with s which is a bit of a giveaway)

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