Open Rekkonnect opened 2 hours ago
Thanks - I'll look into this. Current workaround (apart from the pragma disable) is using a scope for the using:
await using (Assert.Multiple())
{
...
}
Imo it's best to completely remove this error, for the reason I explained above. I prefer typing the extra var _ =
to allow the inline syntax, and avoid nesting all my assertions within the scope, since most of my testing logic is very small and linear.
I'll just make the analyzer accept both versions. I won't remove it because the dispose call is what performs the assertions, so if there's no analyzer to remind people to dispose then their assertions wouldn't run
Oh I completely missed the point of this diagnostic, thanks for the explanation
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:
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 simpleusing
on anIAsyncDisposable
, hinting usingawait using
.Example screenshot:
Workaround
To use this you need to suppress the error by doing:
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.