Skip to content

VSTHRD103 regression: recommends ThrowsAsync for synchronous xUnit assertions #1661

Closed

Description

VSTHRD103 again recommends xUnit's Assert.ThrowsAsync when the delegate under test is synchronous. This was previously tracked and fixed in #61.

With Microsoft.VisualStudio.Threading.Analyzers 18.7.115, code shaped like this is flagged when it appears in an async test method:

Assert.Throws<FormatException>(() => ParseInvalidValue());

The suggested ThrowsAsync API is not semantically appropriate because the operation under test completes synchronously and does not return a Task. Applying the suggestion requires wrapping the synchronous operation in an artificial completed task.

Expected: VSTHRD103 should not report synchronous xUnit assertion calls whose delegate does not return a task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions