New C# scripts use incorrect syntax highlighting in Godot's script editor
Godot version
v4.0.rc2.mono.official [d2699dc7a] v4.2.1.stable.mono.official [b09f793f5]
System information
Manjaro Linux, kernel 6.0.19-4
Issue description
The syntax highlighting for C# does not function properly on newly-created C# source code files. There is some syntax highlighting, but it is not correct. Possibly it is trying to use the syntax highlighting for GDScript?
After closing and reopening the newly-created C# source file, the syntax highlighting begins to function after a short delay (1-3 seconds on my system).
Steps to reproduce
- Create a new C# file. Its syntax highlighting is incorrect.
- Close the new C# file.
- Reopen the C# file. Its syntax highlighting is corrected after a short delay
Minimal reproduction project
N/A
This bug is still occurring with Godot 4.1
This bug occured at Godot 4.1.1, Windows x64. Actions with reopen helped
Still an issue with Godot 4.2.1
Updated the original post with a more accurate description
Tested on: v4.2.2.stable.mono.official [15073afe3]
In addition, on existing C# files (such as copied directly from an addon folder like YarnSpinner for Godot), there is some syntax highlighting but it's not great (comments are not gray, some keywords in blue, using and var is not colored, etc.
To force syntax highlight I had to save the file (despite no change), close the file, reopen it and wait 3 seconds. In other words, saving the file seems to make it as if it was our own new file, then we can use the same workaround as with our own files.
I have no idea what this intermediate syntax highlighting means, but I'd expect both new and existing files to just open with the complete highlighting, possibly after a short delay if that's really about finding if a class exists in the project (but things like comments should be immediately identified).
This bug is still present in Godot 4.2.2
I used to code a lot in Python IDLE without syntax highlighting, but with C# it's much harder.
Saving and re-opening the file doesn't help.
I had to restart the entire engine to fix it.
First time trying to edit C# within the editor personally, saving and reopening seems to work for me on 4.3rc3.
Not sure if it's supported but I'm not getting any intellisense either.
I'm also experiencing this on Godot 4.3 mono on windows 11 x64. Steps to reproduce as listed by the OP worked for me.
screenshots show the same file before saving, closing, and re-opening
Can also confirm that this is reproducible in 4.3 on Windows 10 (22H2). Workaround works.
Can confirm still present in v4.4.1 on Windows 11 both on x86 and arm64.
Still present in 4.5 stable.
It also happens if you open an existing script for the first time since restarting Godot.
Still in 4.5.1-stable. Happens if you create a script too
Is Godot dropping support for C#?
If not, why is such a critical bug still not fixed yet?
because it probably is sitting on the back burner becuse it is fixed by closing and reopening script. The first thing they would work on for C# would be way more likely to be some form of Intelisense instead of some tiny bug fix that isn't a game changer, just a minor inconvenience.
Godot's internal script editor is not intended to be used in production for C#. Most C# users are used to dedicated C# IDEs and it would be a waste of effort to try to make Godot's script editor be as feature complete as C# IDEs like VS, VS Code or Rider.
It can open C# files like it can open .txt or .json files, but it's not a supported use case. As such this is indeed a very low priority issue.
See the docs on how to configure an external C# IDE: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html#configuring-an-external-editor