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

Can't call C# static function #86256

Closed
CsloudX opened this issue Dec 17, 2023 · 6 comments · Fixed by #86972
Closed

Can't call C# static function #86256

CsloudX opened this issue Dec 17, 2023 · 6 comments · Fixed by #86972

Comments

@CsloudX
Copy link

CsloudX commented Dec 17, 2023

Tested versions

v4.2.1.stable.mono.official [b09f793]

System information

Godot v4.2.1.stable.mono - Windows 10.0.17763 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.2849) - AMD Ryzen 9 5950X 16-Core Processor (32 Threads)

Issue description

image

Steps to reproduce

.

Minimal reproduction project (MRP)

CSStaticTest.zip

@zaevi
Copy link
Contributor

zaevi commented Dec 18, 2023

This is a weird error when parsing GDScript, but the static function do works:

var klass = CsMain
var a = klass.F1()
print(a) # prints 123

@YuriSizov
Copy link
Contributor

@CsloudX You didn't finish uploading the MRP. Please do not click away from the template field until it is done uploading next time you submit an issue.

For this one, could you please re-upload it?

@CsloudX
Copy link
Author

CsloudX commented Dec 19, 2023

Sorry about that, and I'm upload a new MRP.

@zaevi
Copy link
Contributor

zaevi commented Dec 19, 2023

This is caused when lookup MethodInfo from CSharpScript:

if (!(info == MethodInfo())) {
return function_signature_from_info(info, r_return_type, r_par_types, r_default_arg_count, r_method_flags);
}

inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; }

The id field is never used (at lease in C#) and is always 0. So the info always equals to empty MethodInfo()

@vnen
Copy link
Member

vnen commented Jan 2, 2024

It this fixed by #86259?

@zaevi
Copy link
Contributor

zaevi commented Jan 2, 2024

It this fixed by #86259?

image

It recognizes the static function now but gives an incorrect return type.

[GlobalClass]
public partial class Main : Node
{
	public static int Add(int a, int b) => a + b; 

	// ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants