-
-
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
C#: Generate instance types for singletons #79470
C#: Generate instance types for singletons #79470
Conversation
3052fc1
to
e4fabdc
Compare
Does this help with resolving compatibility issues from #75694 ? |
As I understand it, #75694 changes However, with this PR we generate an additional |
That sounds like a great idea, if it's possible. I think if we are going to merge this PR, we should merge it first, then you can suggest me how to update mine to make address the issue. |
I've added a commit with the some of the changes suggested by @neikeq in #75694 (comment). This means that now |
40dbc35
to
64d8d34
Compare
64d8d34
to
619a029
Compare
619a029
to
64dc4f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more minor suggestions, but I (still) cannot think of a fundamentally better design for this.
64dc4f1
to
d5a18c6
Compare
Co-authored-by: Ignacio Etcheverry <ignalfonsore@gmail.com>
d5a18c6
to
23f7f24
Compare
Thanks! |
Singleton classes in C# are currently exposed as static classes. In some cases these classes are inherited (e.g.:
PhysicsServer2DExtension
derives from the singleton classPhysicsServer2D
).We currently ignore these classes and don't generate them, because C# doesn't allow inheriting static classes. In order to fix this, with this PR C# now generates additional Instance classes for every singleton. E.g.:
Input.MouseModeEnum
).Footnotes
This would break compatibility and won't happen in 4.x, but in 5.0 we could remove the static classes, rename the instance classes to remove the Instance suffix and create a
Singletons
static class that can be used withglobal using
. Similar to how singletons are exposed in GDScript using@GlobalScope
. See https://github.com/godotengine/godot/pull/59208#issuecomment-1069583895. ↩