`inst_to_dict` deprecated in Godot stable
https://docs.godotengine.org/en/stable/classes/class_%40gdscript.html#class-gdscript-method-inst-to-dict
inst_to_dict is used in a few places in Gut for in situations involving native nodes, such as during test collection and reporting assertions, and probably a lot of other places I'm not familiar with. According to the Godot documentation, this method is now deprecated, suggesting other methods to be used in its place.
This is relevant to the C# support I've been working on, because as pointed out in #576 inst_to_dict doesn't work in that context, though it might not be necessary.
More context on the issue
Hi! We're also getting this error, specifically on a bunch of assertions. I can confirm this breaks when using assert_signal_emitted and assert_signal_emitted with Godot 4.4.1 (both Windows and Linux). It seems to fail only when using built-in scripts
Editor dependency
I thought the solution would be to replace inst_to_dict to use get_property_list() instead, but it's not as simple as that. I spent some hours trying to do this just to find that it cannot be fixed from our side. It's missing some code from the engine that would let us get the subclass' path
I see @ganondev already opened a ticket there. So please, anyone interested in a fix, give this issue a 👍 reaction if you want it to get fixed sooner: https://github.com/godotengine/godot-proposals/issues/12300
The good thing is that once that change exists, it seems like this inst_to_dict is only used once in the whole project (res://addons/gut/strutils.gd#86), so the change would be small
Workaround
If Gut is upgraded to Godot 4.4, there's a new is_built_in() method in the Resource class. We could try to return just the Script name (without the subclass' path) by checking first if it's built-in:
if thing.has_method("is_built_in") and thing.call("is_built_in"):
filename = _get_filename(thing.script.resource_path)
This would prevent the crash, even though we would still be missing the subclass' path. I'm not sure if that would make
In the meantime, we can't use most assertions on built-in scripts
For cases where inner test classes are to be displayed, we can work around this by adding and populating a property in GutTest when inner test classes are loaded. This would likely go somewhere is test_collector.gd and use get_script_contsant_map. Only one level of nesting is supported for inner test classes so that should make it pretty easy.
In other cases we can probably skip this if inst_to_dict does not exist, and call it dynamically if it does. I don't think this will affect much of the user output, but I might be wrong.
Since we know if we have an inner class (doubler.gd does it to tell you when to use register_inner_classes), we could also use GUT's inner_class_registry.gd to get info out for user objects if they have registered the inner class. If the class isn't registered we can tell them to register it.
I made. POC branch in case anyone needs this in the short term: https://github.com/bitwes/Gut/tree/i706_inst_to_dict_POC
This appears to work, but it's a sloppy POC. I'm going to wait to actually implement this until it is absolutely needed or the issue mentioned above provides an alternate solution.