vs-threading
vs-threading copied to clipboard
VSTHRD110 mis-fires on null coalescing operator
Bug description
When an async method's result is returned with ?? operator, VSTHRD110 claims the result isn't returned or awaited.
Repro steps
internal Task<T> GetClientAsync<T>(CancellationToken cancellationToken) where T : VssHttpClientBase
{
return _vssConnection?.GetClientAsync<T>(cancellationToken) ?? Task.FromResult<T>(null);
}
Expected behavior
No warning.
Actual behavior
A warning.
Duplicate of #880?
The two issues are regarding distinct analyzers. I wouldn't know till fixing it whether there is common code behind each analyzer such that fixing one will implicitly fix the other.
private Task ShakeTreeAsync() => Tree?.ShakeAsync() ?? Task.CompletedTask;
A simple example causing a VSTHRD110 warning where it shouldn't.