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

Godot4.4-dev5: Breaks my mock implementation, get_method_list provides invalid method info for get_primary_rotation_axis #99531

Closed
MikeSchulze opened this issue Nov 22, 2024 · 4 comments · Fixed by #99424

Comments

@MikeSchulze
Copy link

MikeSchulze commented Nov 22, 2024

Tested versions

v4.4.dev5.mono.official [9e60984]

System information

All

Issue description

I'm providing a mocking util for testing in my plugin GdUnit4 and the test are broken now.
My tests try to mock all Godot classes, and it fails now on LookAtModifier3D#get_primary_rotation_axis
The method is documented as
Image

But the Vector3 has no enum Axis defined.

Steps to reproduce

Run the script to check the provided method info.

extends Node


func _ready() -> void:
	get_method_info()
	get_tree().quit()


func get_method_info() -> void:
	var modifier := LookAtModifier3D.new()


	var axis := modifier.get_primary_rotation_axis()
	prints("get_primary_rotation_axis value:", axis, "return type:", typeof(axis))

	var methods := modifier.get_method_list()
	var mi_get_primary_rotation_axis := methods.filter(func(m :Dictionary) -> bool:
		return m["name"] == "get_primary_rotation_axis"
	)
	prints(mi_get_primary_rotation_axis[0]["return"])

The output is:

get_primary_rotation_axis value: 1 return type: 2
{ "name": "", "class_name": &"Vector3.Axis", "type": 2, "hint": 0, "hint_string": "", "usage": 65542 }

I use the provided method info to build the mocking class, and it will not be compiling about missing enum Vector3.Axis

e.g. use a valid script code will show the compile error
var axis_typed :Vector3.Axis = modifier.get_primary_rotation_axis()

Parse Error: Built-in types don't contain nested types.
Same issues for all classes inherits from SpriteBase3D

Minimal reproduction project (MRP)

n/a

@akien-mga
Copy link
Member

Related to #98446 which added the method, though it's not the first use of Vector3.Axis in the API, so I'm surprised it's only a problem now for your use case.

#99424 sounds related and might solve this? CC @dalexeev

@dalexeev
Copy link
Member

e.g. use a valid script code will show the compile error var axis_typed :Vector3.Axis = modifier.get_primary_rotation_axis()

Parse Error: Built-in types don't contain nested types.

#99424 sounds related and might solve this?

Yes, it should fix this, see the test analyzer/features/global_builtin_and_native_enums.gd in the PR.

@MikeSchulze
Copy link
Author

@akien-mga it is an older issue right, I checked my mock tests and see I had explicit excluded "Sprite3D", "AnimatedSprite3D" in the past, but I can't remember which version of Godot

@Sithoid
Copy link

Sithoid commented Nov 22, 2024

@akien-mga it is an older issue right, I checked my mock tests and see I had explicit excluded "Sprite3D", "AnimatedSprite3D" in the past, but I can't remember which version of Godot

I'm fairly confident it exists at least in 4.3 stable (and perhaps earlier), since this PR originated as an attempt to fix #99309 (which turned out to be a minor symptom of the same core problem)

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

Successfully merging a pull request may close this issue.

4 participants