You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to load an external class that was loaded into the project via nuget package and access the static methods provided.
Accessing the static methods does not work, the methods are not found.
I am using the same approach I used in Godot3, but it seems to be broken in Godot4.
Steps to reproduce
I build a simple test project with a given c# class containig two methods.
public partial class TestClass : Node
{
public static string Foo() {
return "foo";
}
public string Bar() {
return "bar";
}
}
And load them via const TestClass = preload("res://TestClass.cs")
i can access the method Bar() but the static method Foo is not accessible.
The only way around this problem is to write a wrapper method to call the static method it contains, but this is extremely inconvenient.
// GdUnit4 c# API wrapper
public partial class GdUnit4MonoApi : GdUnit4.GdUnit4MonoAPI
{
public bool _IsTestSuite(string classPath) {
return GdUnit4.GdUnit4MonoAPI.IsTestSuite(classPath);
}
}
@RedworkDE why this is maked as enhancement?
static methods was supported on Godot3 and is a regression.
I saw also issues by loading external c# classes public methods are not found.
I will prepare an small example project in the next days to show the regression between Godot3 and Godot4
The line between bug and enhancement is often pretty vague, in this case I picked enhancement because as far as I can tell this isn't an issue with any existing code, instead the code that is required for this to work doesn't exist yet at all.
Godot version
v4.1.stable.mono.official [9704596]
System information
Windows 10
Issue description
I want to load an external class that was loaded into the project via nuget package and access the static methods provided.
Accessing the static methods does not work, the methods are not found.
I am using the same approach I used in Godot3, but it seems to be broken in Godot4.
Steps to reproduce
I build a simple test project with a given c# class containig two methods.
And load them via
const TestClass = preload("res://TestClass.cs")
i can access the method
Bar()
but the static methodFoo
is not accessible.The only way around this problem is to write a wrapper method to call the static method it contains, but this is extremely inconvenient.
Load the attached example to reproduce.
Minimal reproduction project
csharp-statics.zip
The text was updated successfully, but these errors were encountered: