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

Elaborate on C# Connect/Disconnect #8812

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

31
Copy link
Contributor

@31 31 commented Jan 22, 2024

The C# signal page mentions the Connect and Disconnect APIs (defined on GodotObject), but not when you might want to use them, or how. When looking at the class doc, there's technically an example in there, but it seems limited by only translating the code examples rather than having a C#-specific description. It's never mentioned why you might still want/need to use these. I added some examples and some details about this.

This also clarifies the note about godotengine/godot#70414. Right now it doesn't link to the active issue, so I added a link, and it also doesn't mention that using .Connect is another way around it. Depending on how much a particular dev hates manual cleanup, this might be significantly more appealing.

I imagine the note might have been kept brief rather than mentioning more about it because this was imagined at the time to perhaps be a short-lived problem. But there doesn't seem to me to be a clear, consensus path forward at godotengine/godot#73730, so I think it's worth the detail.

/cc @paulloz (#8538)

@@ -30,8 +36,13 @@ In addition, you can always access signal names associated with a node type thro
.. warning::

While all engine signals connected as events are automatically disconnected when nodes are freed, custom
signals aren't. Meaning that: you will need to manually disconnect (using ``-=``) all the custom signals you
connected as C# events (using ``+=``).
signals connected using ``+=`` aren't. Meaning that: you will need to manually disconnect (using ``-=``)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "as events" on the line above already implies the "connected using +=" for me, that's why it was worded like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ambiguous:

While all engine signals connected as events are automatically disconnected when nodes are freed, custom signals aren't.

While all (engine signals connected as events) are automatically disconnected [...], (custom signals) aren't.
vs.
While all (engine signals) (connected as events) are automatically disconnected [...], (custom signals) (connected as events [implied]) aren't.

I don't know if that's enough to convey what I mean, but I didn't even consider the second interpretation--I thought this line was entirely mistaken when I first read it. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the whole sentence is too complicated for me either way, so I don't really have a strong opinion. I hate we don't have a simple way to convey +=.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take another look later with fresh eyes... yeah, pulling apart the complexity a bit is probably the right move.

And yeah, this is all already a nightmare in casual convos, getting it right in a doc seems like it may be tough. 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After playing with the behavior a bit, I found a whole new chapter to this about capturing variables, so ended up writing a decent amount at #8815.

tutorials/scripting/c_sharp/c_sharp_signals.rst Outdated Show resolved Hide resolved
tutorials/scripting/cross_language_scripting.rst Outdated Show resolved Hide resolved
31 and others added 2 commits January 22, 2024 04:11
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Co-authored-by: Paul Joannon <437025+paulloz@users.noreply.github.com>
@raulsntos raulsntos added enhancement topic:dotnet area:manual Issues and PRs related to the Manual/Tutorials section of the documentation labels Jan 22, 2024
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you say I did imagine it wouldn't take too long to fix and didn't want to discourage users from the event syntax. Unfortunately, there's problems with the proposed fix (godotengine/godot#73730) so it may still take a while. Therefore, I'm more than willing to correct the documentation now (as it should've been done long ago).

Thank you for contributing this PR, it looks good to me so I'll approve but let's wait for @paulloz approval too.

@paulloz
Copy link
Member

paulloz commented Jan 22, 2024 via email

@skyace65 skyace65 merged commit 829619e into godotengine:master Jan 22, 2024
1 check passed
@skyace65
Copy link
Contributor

Thanks!

@mhilbrunner
Copy link
Member

Cherry-picked to 4.2 in #9648.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation enhancement topic:dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants