A finalizer has an empty body

tx0/csharp:empty-finalizerrecommendedwarningperformance/allocationdepth fastperformance

What it finds

An object with a finalizer is kept alive for an extra garbage collection and finalized on a separate thread, even when the finalizer does nothing. An empty finalizer only costs. Finalizers that hold a conditional directive, which may compile to a non-empty body, are left alone.

From the rule's source, empty_finalizer.rs.

Example from the rule's tests
class Holder{    ~Holder()tx0 reports: the finalizer of Holder is empty    {    }} class Native{    ~Native()    {        Release();    }     void Release() { }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/csharp:empty-finalizer" = "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:empty-finalizer] reason="..."

tx0 explain tx0/csharp:empty-finalizer shows the same in the terminal. Found a false positive? Report it.