Skip to content

VSTHRD003 should fire when awaiting on TCS.Task #1224

@AArnott

Description

@AArnott

VSTHRD003 catches awaiting on foreign tasks. Methods that return tasks are assumed to be novel (not foreign). But evidently Task objects returned from property getters are also assumed to be novel. They should probably be assumed to be foreign, since most properties that return Task are probably returning a previously stored Task from a field somewhere, which is exactly what VSTHRD003 was designed to help users avoid.

This should trigger a diagnostic, but does not:

async Task WaitForTaskAsync(TaskCompletionSource<int> tcs) {
   await tcs.Task;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions