Gendarme.Rules.Performance.UseTypeEmptyTypesRule Class
This rule fires if a zero length array of System.Type is created. This value is so often required by the framework API that the System.Type includes an EmptyTypes field. Using this field avoids the memory allocation (and GC tracking) of your own array.

See Also: UseTypeEmptyTypesRule Members

Syntax

[Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine, Gendarme.Framework, Version=2.8.0.0, Culture=neutral, PublicKeyToken=null))]
[Gendarme.Framework.Problem("The method creates an empty System.Type array instead of using Type.EmptyTypes.")]
[Gendarme.Framework.Solution("Use Type.EmptyTypes instead of creating your own array.")]
public class UseTypeEmptyTypesRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule

Remarks

This rule is available since Gendarme 2.0

Example

Bad example:

Example

            ConstructorInfo ci = type.GetConstructor (new Type[0]);
            

Example

Good example:

Example

            ConstructorInfo ci = type.GetConstructor (Type.EmptyTypes);
            

Requirements

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