Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSTHRD003 should fire when awaiting on TCS.Task #1224

Closed
AArnott opened this issue Aug 24, 2023 · 0 comments · Fixed by #1244
Closed

VSTHRD003 should fire when awaiting on TCS.Task #1224

AArnott opened this issue Aug 24, 2023 · 0 comments · Fixed by #1244

Comments

@AArnott
Copy link
Member

AArnott commented Aug 24, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant