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
Assert.ThatAsync doesn't seem to work with ValueTask #4588
Comments
Adding workaround as well: await Assert.ThatAsync(() => Method(), Is.EqualTo("")); // Doesn't work, would work if method returned Task<string>
await Assert.ThatAsync(async () => await Method(), Is.EqualTo("")); // Works |
Another workaround is await Assert.ThatAsync(()=>Method().AsTask(),Is.EqualTo("")); |
I'm not sure where, but I'd thought we had an existing thread on ValueTask. ValueTask is just one of dozens of awaitable types other than Task. For all of these, With that said, of course ValueTask is much more common as an awaitable method return type than anything else besides Task itself, so maybe we could consider adding extra API overloads just for convenience. |
After re-reading Stephen Toubs article I also think |
@jnm2 We do have other issues on ValueTask. You authored one back in 2018. I'll link these together. But this one was very specific, so I thought it was a valid one to keep. |
@jnm2 Here are all the async issues, open and closed. I have had them collected in a project. https://github.com/nunit/nunit/issues?q=is%3Aissue+project%3Anunit%2Fnunit%2F1+ |
Twitter user eduardo @ed_dev_ commented about this, and showed the following repro code:
See twitter post https://twitter.com/ed_dev_/status/1730951076730323419
Comments @manfred-brands @stevenaw @jnm2 ?
Repro here: https://github.com/nunit/nunit.issues/tree/main/Issue4588
The text was updated successfully, but these errors were encountered: