resharper-unity icon indicating copy to clipboard operation
resharper-unity copied to clipboard

Please add support for UniTask

Open ManuelRauber opened this issue 4 years ago • 2 comments

Hi,

UniTask (https://github.com/Cysharp/UniTask) is a super nice library for having async/await support for Unity, e.g. it allows to await Tasks in Coroutines or await Addressables.LoadAssetAsync etc.

You also can mark Unity's Start method to be a UniTask, like this:

private async UniTaskVoid Start() {
  // ...
}

Rider now reports two things:

  1. "Incorrect return type" which is not true (see https://github.com/Cysharp/UniTask#async-void-vs-async-unitaskvoid at the bottom of this section)
  2. Start is never used (that's a following error from 1.)

It would be super nice, if the plugin could handle the usage of UniTask.

Thanks!

ManuelRauber avatar Sep 15 '21 19:09 ManuelRauber

It is acceptable to return any instance of the struct/class of any Unity function.

It is not strongly related to the UniTask (JB doesn't like 3-party dependencies).

//all are valid
private string OnEnable() => "";
private int OnEnable() => 1234;
private Guid Update() => default;
private MyClass FixedUpdate() => default;

Furthermore, Unity will release analog of the UniTask some day and this issue will need to be solved in future anyway.

YegorStepanov avatar Jul 17 '22 00:07 YegorStepanov

Notification slipped through. :)

Furthermore, Unity will release analog of the UniTask some day and this issue will need to be solved in future anyway.

Indeed, good hint! An according to the linked blog post, they are talking with UniTask so it seems like a win-win situation :)

ManuelRauber avatar Sep 21 '22 16:09 ManuelRauber