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

VSTHRD110 mis-fires on null coalescing operator #881

Closed
AArnott opened this issue Jul 26, 2021 · 3 comments · Fixed by #1251
Closed

VSTHRD110 mis-fires on null coalescing operator #881

AArnott opened this issue Jul 26, 2021 · 3 comments · Fixed by #1251
Assignees
Milestone

Comments

@AArnott
Copy link
Member

AArnott commented Jul 26, 2021

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.

@drewnoakes
Copy link
Member

Duplicate of #880?

@AArnott
Copy link
Member Author

AArnott commented Aug 17, 2021

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.

@peterdrier
Copy link

private Task ShakeTreeAsync() => Tree?.ShakeAsync() ?? Task.CompletedTask;

A simple example causing a VSTHRD110 warning where it shouldn't.

@AArnott AArnott self-assigned this Oct 24, 2023
AArnott added a commit to AArnott/vs-threading that referenced this issue Oct 24, 2023
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.

3 participants