IDISP020
November 25, 2021 ยท View on GitHub
Call SuppressFinalize(this)
| Topic | Value |
|---|---|
| Id | IDISP020 |
| Severity | Warning |
| Enabled | True |
| Category | IDisposableAnalyzers.Correctness |
| Code | DisposeMethodAnalyzer |
Description
Call SuppressFinalize with this as argument.
Motivation
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(null);
}
How to fix violations
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
Configure severity
Via ruleset file.
Configure the severity per project, for more info see MSDN.
Via #pragma directive.
#pragma warning disable IDISP020 // Call SuppressFinalize(this)
Code violating the rule here
#pragma warning restore IDISP020 // Call SuppressFinalize(this)
Or put this at the top of the file to disable all instances.
#pragma warning disable IDISP020 // Call SuppressFinalize(this)
Via attribute [SuppressMessage].
[System.Diagnostics.CodeAnalysis.SuppressMessage("IDisposableAnalyzers.Correctness",
"IDISP020:Call SuppressFinalize(this)",
Justification = "Reason...")]