TUnit icon indicating copy to clipboard operation
TUnit copied to clipboard

Unnecessary and prohibiting error about `await using` on `Assert.Multiple()`

Open Rekkonnect opened this issue 5 months ago • 4 comments

I'm using the version 0.1.790, which only contains the single Assert.Multiple() overload that can be used as a scope without writing all the assertion logic inside a lambda expression passed into the multiple assertion scope.

There is an analyzer that reports the following error:

  • TUnitAssertions0004 - Assert.Multiple needs an await using before it.

Which I find unnecessary. If you don't include the await keyword, the C# compiler itself will report an error about applying a simple using on an IAsyncDisposable, hinting using await using.

Example screenshot:

image

Workaround

To use this you need to suppress the error by doing:

#pragma warning disable TUnitAssertions0004 // Assert.Multiple needs an `await using` before it

VS provides a quick fix for that by suppressing and then restoring the error, although I would recommend completely disabling it throughout the entire file, or in the .editorconfig entirely.

Rekkonnect avatar Sep 21 '24 18:09 Rekkonnect