Gendarme.Rules.Performance.RemoveUnneededFinalizerRule Class
This rule looks for types that have an empty finalizer (a.k.a. destructor in C# or Finalize method). Finalizers that simply set fields to null are considered to be empty because this does not help the garbage collection. You should remove the empty finalizer to alleviate pressure on the garbage collector and finalizer thread.

See Also: RemoveUnneededFinalizerRule Members

Syntax

[Gendarme.Framework.FxCopCompatibility("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")]
[Gendarme.Framework.Problem("The type has an useless (empty or only nullifying fields) finalizer.")]
[Gendarme.Framework.Solution("Remove the finalizer from this type to reduce the GC workload.")]
public class RemoveUnneededFinalizerRule : Gendarme.Framework.Rule, Gendarme.Framework.ITypeRule

Remarks

Prior to Gendarme 2.2 this rule was named EmptyDestructorRule

Example

Bad example (empty):

Example

            class Bad {
            	~Bad ()
            	{
            	}
            }
            

Example

Bad example (only nulls fields):

Example

            class Bad {
            	object o;
            	~Bad ()
            	{
            		o = null;
            	}
            }
            

Example

Good example:

Example

            class Good {
            	object o;
            }
            

Requirements

Namespace: Gendarme.Rules.Performance
Assembly: Gendarme.Rules.Performance (in Gendarme.Rules.Performance.dll)
Assembly Versions: 2.8.0.0