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

VSTHRD102 should not fire when VSTHRD002 would #91

Closed
AArnott opened this issue Mar 9, 2017 · 0 comments
Closed

VSTHRD102 should not fire when VSTHRD002 would #91

AArnott opened this issue Mar 9, 2017 · 0 comments

Comments

@AArnott
Copy link
Member

AArnott commented Mar 9, 2017

The following code requires two warning suppressions for the same by-design "violation". If VSTHRD002 signals a violation, being more severe, VSTHRD102 shouldn't double up.

private static bool CopyTaskResultIfCompleted<T>(Task<T> task, IVsTaskCompletionSource taskCompletionSource)
{
    if (task.IsCanceled)
    {
        taskCompletionSource.SetCanceled();
    }
    else if (task.IsFaulted)
    {
        taskCompletionSource.SetFaulted(Marshal.GetHRForException(task.Exception));
    }
    else if (task.IsCompleted)
    {
#pragma warning disable VSTHRD102 // Implement internal logic asynchronously (We already confirmed task.IsCompleted)
#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits (We already confirmed task.IsCompleted)
        taskCompletionSource.SetResult(task.Result);
#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
#pragma warning restore VSTHRD102 // Implement internal logic asynchronously
    }
    else
    {
        return false;
    }

    return true;
}
AArnott added a commit that referenced this issue Jun 29, 2017
AArnott added a commit that referenced this issue Jun 29, 2017
AArnott pushed a commit that referenced this issue Apr 11, 2022
Notice .NET SDK install failure earlier and workaround broken script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant