An override of Dispose(bool) does not call the base class's Dispose(bool), so the base resources are not released
What it finds
In the dispose pattern, each class releases its own resources in Dispose(bool) and then calls base.Dispose(disposing). An override that forgets the call leaves whatever the base class holds, handles, streams or subscriptions, unreleased. Empty overrides, which say on purpose that nothing is to be done, are left alone.
From the rule's source, dispose_without_base_call.rs.
using System.IO; class Wrapper : Stream{ private readonly Stream inner = new MemoryStream(); protected override void Dispose(bool disposing)tx0 reports: this Dispose override does not call the base class's Dispose { inner.Dispose(); } public override bool CanRead => true; public override bool CanSeek => false; public override bool CanWrite => false; public override long Length => 0; public override long Position { get; set; } public override void Flush() { } public override int Read(byte[] buffer, int offset, int count) => 0; public override long Seek(long offset, SeekOrigin origin) => 0; public override void SetLength(long value) { } public override void Write(byte[] buffer, int offset, int count) { }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:dispose-without-base-call" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:dispose-without-base-call] reason="..."tx0 explain tx0/csharp:dispose-without-base-call shows the same in the terminal. Found a false positive? Report it.