vs-threading
vs-threading copied to clipboard
VSTHRD200 reports DisposeAsyncCore
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.
It appears there is still an open discussion on this. Once that concludes I can update the analyzer with the result.
@sharwell I just ran into this warning, too. Is the naming of DisposeAsyncCore()
still up for discussion? 🙂
.NET SDK analyzers have the same issue: https://github.com/dotnet/roslyn-analyzers/issues/3909 (AFAIK).
@MartyIX Thanks, I was curious if that was the case for the .NET SDK analyzers as well 🙂