Thanks to visit codestin.com
Credit goes to github.com

Skip to content

VSTHRD200 reports DisposeAsyncCore #805

@MartyIX

Description

@MartyIX

Bug description

VSTHRD200 should (probably) not report a warning for DisposeAsyncCore method name as it is recommended here: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-disposeasync#disposeasync-and-disposeasynccore

Repro steps

Code to reproduce the behavior.

/// <summary>
/// Frees managed resources used by the object.
/// </summary>
/// <returns>A <see cref="ValueTask">task</see> that represents the asynchronous dispose operation.</returns>
protected virtual async ValueTask DisposeAsyncCore() // <<<<<<< WARNING HERE
{
    this.log.Debug("*");

    lock (this.disposedValueLock)
    {
        if (this.disposedValue)
        {
            this.log.Debug("$<ALREADY_DISPOSED>");
            return;
        }

        this.disposedValue = true;
    }

    // ...

    this.log.Debug("$");
}

/// <inheritdoc/>
public async ValueTask DisposeAsync()
{
    await this.DisposeAsyncCore().ConfigureAwait(false);
    GC.SuppressFinalize(this);
}

Expected behavior

No warning.

Actual behavior

A warning is emitted.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions