Gendarme.Rules.Performance.AvoidUnusedPrivateFieldsRule Class
This rule checks all private fields inside each type to see if some of them are not being used. This could be a leftover from debugging or testing code or a more serious typo where a wrong field is being used. In any case this makes the type bigger than it needs to be which can affect performance when a large number of instances exist.

See Also: AvoidUnusedPrivateFieldsRule Members

Syntax

[Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine, Gendarme.Framework, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null))]
[Gendarme.Framework.FxCopCompatibility("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
[Gendarme.Framework.Problem("This type contains private fields which seem to be unused.")]
[Gendarme.Framework.Solution("Remove unused fields to reduce the memory required by the type or correct the use of the field.")]
public class AvoidUnusedPrivateFieldsRule : Gendarme.Framework.Rule, Gendarme.Framework.ITypeRule

Remarks

Documentation for this section has not yet been entered.

Example

Bad example:

Example

            public class Bad {
            	int level;
            	bool b;
            	public void Indent ()
            	{
            		level++;
            #if DEBUG
            		if (b) Console.WriteLine (level);
            #endif
            	}
            }
            

Example

Good example:

Example

            public class Good {
            	int level;
            #if DEBUG
            	bool b;
            #endif
            	public void Indent ()
            	{
            		level++;
            #if DEBUG
            		if (b) Console.WriteLine (level);
            #endif
            	}
            }
            

Requirements

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