I have the following code:
/// <summary>
/// Dispose.
/// </summary>
public override sealed void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose.
/// </summary>
/// <param name="disposing">
/// Disposing parameter.
/// </param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
}
Clear();
base.Dispose(disposing);
}
And have the following warnings:
Warning 435 CA2215 : Microsoft.Usage : Ensure that method ‘DSDump.Dispose()’ calls base.’DSDump.Dispose()’ in all possible control flow paths.
Warning 436 CA1063 : Microsoft.Design : Remove ‘DSDump.Dispose()’, override Dispose(bool disposing), and put the dispose logic in the code path where ‘disposing’ is true.
I don’t have any ideas why… All looks OK from my side.
The problem is that your base class is defined incorrectly.
public void Dispose()should not be a virtual method in your base class. It should handle the GC suppression and call the virtualprotected virtual void Dispose(bool)method, which is the one you should override.