Skip to content

VSTHRD003 fails to identify when 'foreign task' is assigned to field and awaited on within the same method #679

Open

Description

Bug description

Similar to #108, the VSTHRD003 analyzer failed to recognize a deadlock-prone pattern of a JTF.Run delegate that simply returns the value of a Task field.

Repro steps

See this PR (line 314) for the specific case the analyzer failed to catch the issue.

Roughly this:

Task task;

void Foo()
{
   task = jtf.RunAsync(async () => { await Task.Yield(); }).Task;
   jtf.Run(() => task); // violation should be found here.
}

Expected behavior

We should see a VSTHRD003 diagnostic as indicated above.

Actual behavior

No VSTHRD003 diagnostic.

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions