TypeName | DisposablesShouldCallSuppressFinalizeAnalyzer |
Check Id | CC0029 |
Category | Naming |
Severity | Warning |
Classes implementing IDisposable should call the GC.SuppressFinalize
method in their finalize method to avoid any finalizer from being called.
This rule should be followed even if the class doesn’t have a finalizer as a derived class could have one.
public class MyType : System.IDisposable
{
public void Dispose()
{
var x = 123;
}
}
A code fix will be presented to you that will transform the code:
public class MyType : System.IDisposable
{
public void Dispose()
{
var x = 123;
GC.SuppressFinalize(this);
}
}
None
TBD