Mono Class Library: Gendarme.Rules.Performance Namespace

Gendarme.Rules.Performance.UseTypeEmptyTypesRule Class

This rule looks for methods that creates an empty (zero sized) array of System.Type. This value is so often required by the framework API that the System.Type includes a EmptyTypes field. Using this field avoids the memory allocation (and GC tracking) of your own array.

See Also: UseTypeEmptyTypesRule Members

Gendarme.Framework.Rule
     Gendarme.Rules.Performance.UseTypeEmptyTypesRule

[Gendarme.Framework.EngineDependency(typeof(Gendarme.Framework.Engines.OpCodeEngine, Gendarme.Framework, Version=2.4.2.0, Culture=neutral, PublicKeyToken=null))]
[Gendarme.Framework.Problem("The method creates an empty System.Type array instead of using Type.EmptyTypes.")]
[Gendarme.Framework.Solution("Change the array creation for Type.EmptyTypes.")]
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.4.2.0