Closed
Description
openedon Mar 15, 2021
Analyzer
Diagnostic ID: CA2013: Do not use ReferenceEquals with value types
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Describe the bug
CA2213 seemingly does not consider DisposeAsyncCore method.
/// <summary>State object for <see cref="RestClient"/>.</summary>
private readonly RestClientContext restContext; // <<<< CA2213: WARNING EMMITED HERE.
// ...
/// <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()
{
this.log.Debug("*");
lock (this.disposedValueLock)
{
if (this.disposedValue)
{
this.log.Debug("$<ALREADY_DISPOSED>");
return;
}
this.disposedValue = true;
}
this.log.Debug("Dispose REST context.");
this.restContext.Dispose(); // // This does not make the warning go away!
this.log.Debug("$");
}
/// <inheritdoc/>
public async ValueTask DisposeAsync()
{
// this.restContext.Dispose(); // THIS MAKES THE WARNING GO AWAY.
await this.DisposeAsyncCore().ConfigureAwait(false);
GC.SuppressFinalize(this);
}
Steps To Reproduce
Please see the source code above.
Expected behavior
No warning is emitted when this.restContext.Dispose();
is called in DisposeAsyncCore
.
Actual behavior
A warning is emitted when this.restContext.Dispose();
is called in DisposeAsyncCore
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment