-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
C# script does not list non-exported properties unlike GDScript #92183
Comments
I think this is a C# issue, GDScript does not check if the property is exported ( |
Yes, C# only adds exported properties to My only concern with changing this is that it will expose everything, even properties that the user didn't intend to expose, since Godot doesn't have a concept of |
GDScript already collects all non-static variables, and this works well. For C#, I guess we should collect all public properties except the |
I think if we have to change something, we should at least should be consistent with how this works for methods. And for methods, we don't care about accessibility. It would be weirdly inconsistent to expose But I'm not a huge fan of the idea (neither am I that we expose private methods to begin with). |
This is not something we can change back easily now, because it'd break compatibility for anyone currently using members exposed that way. |
Hey, this is something I ran into and brought up in the contributor chat, glad to see there's an issue open for discussion here. I do agree that private methods shouldn't have been exposed in the first place but we're sadly past the point where we could change that. In my opinion we can remedy this by adding cproj defines that the source generator will check for how to expose properties and methods. Example:
We then add these to the current SDK as defaults that will keep the behaviour the same as it is currently to not break compatibility, but people will be able to opt into the more sane method of exporting public. This would require CSharp scripts to have a third member variable with the exposed properties on the engine code side, as neither |
I don't think adding all public C# properties to GDScript autocomplete would break compatibility (correct me if I'm wrong), as they are already readable and writeable because they are exposed by the source generators. In my opinion, making them appear in the GDScript autocomplete by default would be a good solution, but we could also add @preslavnpetrov's soultion with "GodotExposeProperties" for those who don't want it (or the other way around if it breaks compatibility). It also would be nice to have a way to "export" properties specifically for autocomplete without affecting their editor or storage behavior, essentially using PROPERTY_USAGE_NONE. I know GDScript recently got @export_custom (#72912) which allows for this, but it doesn't look like C# has an equivalent. Would like to hear thoughts on this. |
I'm personally not a fan of the idea of introducing that kind of Basically I tend to agree with the following. And having a specific thing to allow opting-out would alleviate my gripes with the fact we over-expose.
About |
Yeah I mean either works. I'm a fan of opt-in more than opt-out and setting it as a general rule rather than specific but that's just code preference. I'd be happy in either case, as long as we can start having more direct, manual control over what is exposed and what isn't. An [Ignore] or [GodotIgnore] attribute would be good, and the name is generic enough that we can apply it to both properties and methods. On the topic of properties, I would prefer that we only expose these, even at the cost of some inconsistency with methods:
Private properties feel like they're gonna be too much clutter to me, and slapping an [Ignore] on all of them would be a bit ugly. |
Tested versions
v4.1.3.stable.mono, All 4.2.2 release candidates, 4.2.2.stable.mono
System information
Godot v4.2.2.stable.mono - Desktop
Issue description
Non exported C# properties do not show up in GDScript autocomplete.
They can be set and get, just fine though.
This is a problem for a few reasons:
Which is why non C# exported properties should be included in GDScript autocomplete.
Steps to reproduce
Have a C# script like this
Only exported properties (and fields) show up in autocomplete
Minimal reproduction project (MRP)
MRP.zip
The text was updated successfully, but these errors were encountered: