-
-
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
Generate C# singletons as non-static classes #59208
Conversation
1bd42bc
to
921496e
Compare
@@ -1889,7 +1887,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf | |||
p_output.append(MEMBER_BEGIN); | |||
p_output.append(p_imethod.is_internal ? "internal " : "public "); | |||
|
|||
if (p_itype.is_singleton) { | |||
if (p_itype.name == "Engine" && p_imethod.name == "get_singleton") { |
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.
Engine.GetSingleton
is still generated as static to avoid an infinite loop.
Singleton classes are no longer generated as static classes so they can be inherited.
921496e
to
99546cf
Compare
This is precisely why I made them static classes. It's a pretty big downside. I'll see what can be done about |
Another possible solution, if we can't find a different one, is to have a |
For now, let's just ignore classes that inherit from singletons. EDIT: We don't want to ignore all of those, as to not silence possible future regressions. Instead, let's hard-code a list of classes that should be ignored, with |
Superseeded by #59286 |
Singleton classes are no longer generated as static classes so they can be inherited.
This fixes mono after #59140 (introduces a class
PhysicsServer3DExtension
that inherits fromPhysicsServer3D
which is a singleton class) and re-enables mono CI.The disadvantage of this is we now have to access the singleton class using the
Singleton
property everytime, which is cumbersome, but it's consistent with how it works in the engine and godot-cpp (using theget_singleton
method).