-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Suggest snake_case script names by default #41991
Suggest snake_case script names by default #41991
Conversation
typo defualt → default |
285ff45
to
78a5ccb
Compare
Corrected. Thanks! |
Adds After using this patch for a while, I am now personally against renaming the object script names. It causes the names to get mixed up, e.g. If you don't want or can't follow exactly the PascalCase convention. |
I don't like how this implementation relies on a "magic string" to determine whether case should be snake or pascal. What if another language is added in the future and we want it to use this option? What if other custom languages in modules also want to make use of this option? They can't because it is defined within the core codebase. This does not follow the Open-Closed principle. Also remember that C# is not part of core - it is a module too. So if you compile Godot without the mono module, this code kind of makes no sense since C# doesn't exist. I suggest moving this to a method in You would also need to apply the logic when the language is changed in Here is what I did on a local branch: |
@capnm underscores are added by the string method which converts camel to snake case - this would be an implementation detail of that method. Not sure if core devs would be willing to change a core method for this. I think most of the time though you would want underscores around numbers. It just so happens that in the example you gave it is not ideal with that particular naming format. An underscore is added unnecessarily at the end because of the dot for the file extension. If the extension and the dot are removed, and then the conversion is done, it works just fine as in my gif above. |
I understand what is going on. I'm just saying that now, after practical testing in my projects, I am against this idea of automatic name change (i.e.enforcing a snake_case file naming convention). Personally, I think it's better if the filenames match the object names. |
Fair enough - good feedback to have. |
Looks like I'm not alone. The code of the guys around the new Godot-docs hire confirms for me, that the snake_case filename convention wasn't a smart idea. I secretly hope @NathanLovato will fix the convention documents;) https://github.com/GDQuest/godot-2d-tactical-space-combat/tree/master/godot |
@capnm We'd prefer keeping the |
Looks like a Godot bug to me. The editor should then not allow file names that differ only in upper and lower case and internally ignore the case in file names. |
+1 for keeping CamelCase for consistency. The alternative would be to rename all internal classes so they also follow a snake_case convention. |
@robbertzzz Godot's C++ source files use |
When you save a scene, the dialog also uses the PascalCase name from the root node ... |
The convention has been PascalCase node, scene, and gdscript file names since the first release of Godot in the editor. I'm not against snake_case for all files, but if that's the way you're expected to name all files, then the editor should take care of that for all files. Otherwise, you're asking the user to work against the program. |
Ah, and I second that this repo is the engine's back-end, a separate domain, so its conventions don't have to be applied to and affect the user's experience when working with the editor. I mean that consistency with the C++ back-end doesn't have to be part of the equation; it's a separate project. |
Should be fixed in #41991. |
@Calinou I think this one is fixed. |
I've tested the current behavior on This is also not fixed yet when adding a script to a node that isn't the scene root. Therefore, this PR is still relevant 🙂 |
Ok so
|
Superseded by #78119. Thanks for the contribution! |
Script Create Dialog will now suggest snake case file names for GDScript, VisualScript and NativeScript.
This doesn't apply to C# which requires PascalCase file names (to match the class name).
Closes: godotengine/godot-proposals#1211.