All rules
CA2215Usage Enabled by default: No

Dispose methods should call base class dispose

Dispose methods should call base class dispose

Microsoft docs

Description

If a type inherits from a disposable type, it must call the System.IDisposable.Dispose method of the base type from within its own System.IDisposable.Dispose method. Calling the base type Dispose method ensures that any resources created by the base type are released.

Cause

A type that implements System.IDisposable inherits from a type that also implements System.IDisposable. The System.IDisposable.Dispose method of the inheriting type does not call the System.IDisposable.Dispose method of the parent type.

How to fix violations

To fix a violation of this rule, call base.System.IDisposable.Dispose in your System.IDisposable.Dispose method.

Example

#pragma warning disable CA2215
// The code that's violating the rule is on this line.
#pragma warning restore CA2215

When to suppress

It is safe to suppress a warning from this rule if the call to base.System.IDisposable.Dispose occurs at a deeper calling level than the rule checks.

Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0