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

VSTHRD103 mis-fires in synchronous local methods declared within an async member method #1003

Closed
AArnott opened this issue Mar 24, 2022 · 0 comments · Fixed by #1251
Closed
Assignees

Comments

@AArnott
Copy link
Member

AArnott commented Mar 24, 2022

Compile the following for .NET 6, where CTR.DisposeAsync is defined, to see the false warning.

Task Foo()
{
    return Task.CompletedTask;

    void CompletionHandler(CancellationTokenRegistration registration)
    {
#pragma warning disable VSTHRD103 // Use DisposeAsync instead.
        registration.Dispose();
#pragma warning restore VSTHRD103 // Use DisposeAsync instead.
    }
}
@AArnott AArnott self-assigned this Oct 24, 2023
AArnott added a commit to AArnott/vs-threading that referenced this issue Oct 24, 2023
This prevents false positives in synchronous local functions that appear within async methods.

Fixes microsoft#1003
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