Skip to content

Conversation

@niekschoemaker
Copy link
Contributor

This allows awaiting exports without a null check.

Goal of this PR

In the current implementation of exports exports might return null instead of a coroutine, which is the case for exports which execute within a tick (so no wait calls) and don't return a value.
Simply returning a Completed Coroutine with a null value fixes this issue.

How is this PR achieving the goal

By returning a completed coroutine with a null value.

This PR applies to the following area(s)

ScRt: C# v2

Successfully tested on

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

This allows awaiting exports without a null check.
@niekschoemaker
Copy link
Contributor Author

Another one which is somewhat opiniated.

In my opinion being able to call await on the export without a null check and then handling null values after the await seems like a cleaner solution than:

var result = Exports["test", "test"]();
if (result != null) {
    await result;
}

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant