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

Added a hint for the C# constants use #70852

Closed
wants to merge 1 commit into from
Closed

Conversation

aseiis
Copy link

@aseiis aseiis commented Jan 2, 2023

Instead of Color.RED (GDScript), constants are found under the Colors class

Instead of Color.RED (GDScript), constants are found under the Colors class
@akien-mga
Copy link
Member

akien-mga commented Jan 3, 2023

The same is true for any constant AFAIK, and we don't typically document all differences between the native Godot API and the C# glue case conversions in the class reference. Doing this consistently would lead to a lot of extra work, and doing it only here would be inconsistent.

The difference in the constant casing for C# is documented here: https://docs.godotengine.org/en/latest/tutorials/scripting/c_sharp/c_sharp_differences.html#constants

As a side note, the cheat sheet picture should be redone to use the UPPER_CASE names (the current one uses the names from 3.x which were indeed lowercase). For that picture, it could be worth making a C# version for easy referencing.

@aseiis
Copy link
Author

aseiis commented Jan 3, 2023

@akien-mga I understand. I struggled more than I should to find the C# enum-class equivalent so I wanted to make the life easier for people who might have the same issue in the future, and while I was looking at the Color doc I didn't see any mention of the Colors C# class -- althought there is one but below the description, for something that has nothing to do at first sight.
Before this PR I also looked at https://docs.godotengine.org/en/latest/tutorials/scripting/c_sharp/c_sharp_differences.html#constants as you mentionned and I don't see any mention of the C# Colors class. I guess it is true for many other differences but I have no idea how to consistently spot them -- but it might be a good idea to extend the array of differences to all of them, or share the technique we should use to get the C# equivalent, if there is such thing without looking extensively into the source code. I'm new to this so I'm sorry if I'm not very consistent!

@YuriSizov
Copy link
Contributor

YuriSizov commented Jan 3, 2023

I don't see any mention of the C# Colors class.

I guess there are two issues here.

First, constants use different writing style between the engine/GDScript and C#. That is documented at the link, and there is nothing special in that regard for color constants.

Second, apparently in C# you should use Colors, with an "s" at the end, instead of Color. That might need a dedicated mention in the linked doc (and would also be a fair game for the class description, IMO). Note that I don't know if this is true or not in the first place, I trust that you've tested it.

@akien-mga
Copy link
Member

Indeed, if C# constants are in a separate Colors enum/class and not in the Color Variant class, then it's likely still worth mentioning explicitly in the class reference for the Color class, additionally to the page covering C# specific differences. CC @godotengine/dotnet

@raulsntos
Copy link
Member

I think the C# API differences to GDScript page is a bit outdated and is missing some differences. I wanted to add a section for the Color struct like there is for other types to mention differences such as the Colors static class to retrieve the "constants".

However, I feel like that page is often missed by users, specially if you are new you probably won't think to look for it so I'd be in favor of adding links to it from the class reference.

@YuriSizov
Copy link
Contributor

YuriSizov commented Jan 5, 2023

However, I feel like that page is often missed by users, specially if you are new you probably won't think to look for it

Do you have any idea on how to better address this? Should we add a reference to it at the top of the editor help if you're using a "mono" version?

@akien-mga
Copy link
Member

However, I feel like that page is often missed by users, specially if you are new you probably won't think to look for it

Do you have any idea on how to better address this? Should we add a reference to it at the top of the editor help if you're using a "mono" version?

That's a good idea. Maybe there should be a dedicated first section about using the class reference for C# users, explaining the general concepts first before going into details. The current page kind of does that but without the perspective of a class reference reader specifically, I think it would be a useful angle to develop.

@YuriSizov
Copy link
Contributor

Thanks for your contribution! #79206 supersedes this PR, but I hope you'll be able to contribute something else in the future!

@YuriSizov YuriSizov closed this Jul 14, 2023
@YuriSizov YuriSizov removed this from the 4.x milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants