godot-rust / gdext

Rust bindings for Godot 4
https://mastodon.gamedev.place/@GodotRust
Mozilla Public License 2.0
2.73k stars 167 forks source link

Improvement expected behaviour for #[export] #772

Open snatvb opened 2 weeks ago

snatvb commented 2 weeks ago

If user tries convert @export_file("*.txt") to Array:

extends Node

class_name NewScript

@export_file("*.txt") var files: Array[String]

LSP shows error: image And in console: image

But if user does it in rust:

#[derive(GodotClass)]
#[class(init, base=Node)]
struct Foo {
    base: Base<Node>,
    #[export(file)]
    resources: Array<GString>,
}

#[godot_api]
impl INode for Foo {}

It leads to this: image image

For user it's unexpected and it would be rather to notify about incorrect annotation.

Reprocase: godot-rust-repro.zip

Discord source conversation

snatvb commented 2 weeks ago

https://github.com/godotengine/godot/issues/93366 Created on Godot, if there is no point in improving the macro, you can close it down

lilizoey commented 2 weeks ago

godotengine/godot#93366 Created on Godot, if there is no point in improving the macro, you can close it down

i dont see why this issue should be brought up to godot

snatvb commented 2 weeks ago

i dont see why this issue should be brought up to godot

Bromeon said that it's issue of Godot that it doesn't notify about incorrect export property

Bromeon commented 2 weeks ago

Sorry about the confusion here, tried to clarify it on the Godot issue.

I'm not sure whether Godot performs the same validations for @export_* annotations in GDScript as it does for GDExtension property hints. If it doesn't (and there is no change planned), then we would need to replicate them on Rust side, which could be quite laborious and maintenance-intensive.