Skip to content

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

@AArnott

Description

@AArnott

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.
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions