-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
Implement [ExportToolButton]
#97894
Implement [ExportToolButton]
#97894
Conversation
6732463
to
89a4abd
Compare
I'm putting this in "ready for review". The last thing to do is write proper diagnostic messages, for which I'd still require some help. |
|
The reasons it is not the case have been discussed in the original proposal, if you're interested. |
I tweaked the messages and also refactored a bit to error when using a non-marshallable type (currently if you put the attribute on for example The comments you called out are wrong and I think the handling was sort of copied from The branch is rebased so I could use this with some other recent merges but if you'd prefer I can open a pr against your branch rather than cherry picking the latest commit off mine to yours. Also imo the error messages are fine. I tweaked them because you called out maybe changing them, but I think they are clear enough as is. |
That's a good catch. I'd want to take a second look to maybe find a less invasive way to handle this, tho.
I don't think this should be modified in this PR. It isn't really related to the new button thing, and faxing unrelated changes make things hard to track IMHO. It's also probably going to clash against #98396.
TBH, that was more of a call for @raulsntos, to make sure all of our diagnostic messages are more or less worded in the same way. |
That's fair; I felt like the structure of
I'll make a separate issue/pr then for it. It looks like it will conflict with that pr but not in a substantial way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing the C# follow-up so quickly, everything looks great already.
The
DeterminePropertyInfo()
method is becoming a bit convoluted. I'm pretty sure we could simplify it, but didn't want to refactor more than I needed.
Not sure it's worth it since we'll replace these generators in the future, but feel free to do this in a follow-up PR if you want.
Also, am I blind, or are the comments lines 452 and 463 wrong?
You are right, I think originally these members were supposed to be filtered by WhereIsGodotCompatibleType
. This method used to filter read-only and write-only members, but these checks where removed in #67304, probably also why we have duplicate diagnostic reports now (but it seems @a-johnston has already fixed this in #99206).
modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportToolButtonAttribute.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/AnalyzerReleases.Unshipped.md
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertiesGenerator.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Common.cs
Outdated
Show resolved
Hide resolved
b66ddf8
to
9c9ce76
Compare
Thanks for the review. Everything you noted should be addressed 👍 |
9c9ce76
to
7990d9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
7990d9e
to
4f52c2b
Compare
Squashed and ready to go 🚀 |
Are there plans/goals for overhauling the generators or is this a hypothetical long-term thing? |
Generators are very different in the GDExtension bindings. |
In reference to https://godotengine.org/article/whats-new-in-csharp-for-godot-4-0/#gdextension-support (unsure if there are more recent links)? I think that would be welcome but if c# still stuck around as a scripting language in addition to a gdextension language, wouldn't these generators also continue being relevant, or do you anticipate them sharing code? |
Thanks! |
If you are interested in the development progress of the GDExtension-based integration, you may check this repo; please note that this project is not yet ready for formal projects. |
hi, I read the discussion about why we can't export methods directly. When the method marked by |
Follow up to #96290, implementing the C# attribute.
✋ I leave this in draft for the following reasons:
I need to add tests inGodot.SourceGenerators.Tests
.Texts in the new diagnostics are placeholders. I'd appreciate if someone could take a stab at writing proper error messages, I'm quite bad at it myself.I more or less reflected the GDScript annotation, with a new attribute
[ExportToolButton]
. It can be used on both fields, and properties of typeCallable
. I lifted the restriction on read-only exported properties for this specific usage. I don't think we need to do anything inScriptPropertyDefValGenerator
, unless I miss something major.The
DeterminePropertyInfo()
method is becoming a bit convoluted. I'm pretty sure we could simplify it, but didn't want to refactor more than I needed. I could comment it more if it helps to navigate it, please tell me. Also, am I blind, or are the comments lines 452 and 463 wrong?I introduced the following diagnostics:
[ExportToolButton]
marks a member defined in a class not marked with[Tool]
.[ExportToolButton]
and[Export]
mark the same member.[ExportToolButton]
marks a member that is not of typeCallable
.The easiest way to use this is something like the following.
It is also possible to use a backing field, but it becomes more verbose, since in C# we can't assign
Callable.From(...)
during fields initialization.Cheers ✨