Skip to content

[C#] Simple Async support #1346

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

[C#] Simple Async support #1346

wants to merge 10 commits into from

Conversation

yowl
Copy link
Collaborator

@yowl yowl commented Aug 2, 2025

This PR add the very minimal changes to enable the first async functions tests to pass. These tests return immediately which means a lot of the callback, waitable, changes are not done yet. There are no TaskCompletionSources created, we just set the return value on the task. User code will look like

https://github.com/bytecodealliance/wit-bindgen/pull/1346/files#diff-f34015927bd91d8f86e20e1a9258891caad407de6a499fcf977cb1165c89b3a5

and

https://github.com/bytecodealliance/wit-bindgen/pull/1346/files#diff-756d40996fd1204ae5975dd4da40e815b827d804c27b13dd36f69b6612ced825

Which should be idiomatic.

Thanks @dicej for the help in Zulip.

@yowl yowl marked this pull request as ready for review August 2, 2025 16:27
Copy link
Collaborator

@dicej dicej left a comment

Choose a reason for hiding this comment

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

Looks like a solid start, thanks!

return (uint)CallbackCode.Yield;
"#);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to add a "TODO" comment here to remember to defer dropping borrowed resources until a result is returned (i.e. just before calling {name}TaskReturn).

"#
);

let task_return_param = match &sig.results[..] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The task return function could accept up to 16 core parameters (e.g. 2 for a string, 5 for a tuple<string, list<u8>, u32>, etc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants