﻿<?xml version="1.0" encoding="utf-8"?><Type Name="AvoidLongMethodsRule" FullName="Gendarme.Rules.Smells.AvoidLongMethodsRule"><TypeSignature Language="C#" Value="public class AvoidLongMethodsRule : Gendarme.Framework.Rule, Gendarme.Framework.IMethodRule" /><TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit AvoidLongMethodsRule extends Gendarme.Framework.Rule implements class Gendarme.Framework.IMethodRule, class Gendarme.Framework.IRule" /><AssemblyInfo><AssemblyName>Gendarme.Rules.Smells</AssemblyName><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Base><BaseTypeName>Gendarme.Framework.Rule</BaseTypeName></Base><Interfaces><Interface><InterfaceName>Gendarme.Framework.IMethodRule</InterfaceName></Interface></Interfaces><Attributes><Attribute><AttributeName>Gendarme.Framework.Problem("Long methods are usually hard to understand and maintain.  This method can cause problems because it contains more code than the maximum allowed.")</AttributeName></Attribute><Attribute><AttributeName>Gendarme.Framework.Solution("You should apply an Extract Method refactoring, but there are other solutions.")</AttributeName></Attribute></Attributes><Docs><summary>
             This rule allows developers to measure the method size. The short sized 
             methods allows you to maintain your code better, if you have long sized 
             methods perhaps you have the Long Method smell.
            
             The rule will skip some well known methods, because they are autogenerated:
             <list type="bullet"><item><description><c>Gtk.Bin::Build ()</c></description></item><item><description><c>Gtk.Window::Build ()</c></description></item><item><description><c>Gtk.Dialog::Build ()</c></description></item><item><description><c>System.Windows.Forms::InitializeComponents ()</c></description></item><item><description><c>System.Workflow.Activities.StateMachineWorkflowActivity::InitializeComponents ()</c></description></item><item><description><c>System.Workflow.Activities.SequentialWorkflowActivity::InitializeComponents ()</c></description></item><item><description><c>System.Windows.Controls.UserControl::InitializeComponents ()</c></description></item></list>
             This will work for classes that extend those types.
            
             If debugging symbols (e.g. Mono .mdb or MS .pdb) are available then the rule 
             will compute the number of logical source line of code (SLOC). This number
             represent the lines where 'SequencePoint' are present in the code. By 
             default the maximum SLOC is defined to 40 lines.
            
             Otherwise the rule falls back onto an IL-SLOC approximation. It's quite 
             hard to determine how many SLOC exists based on the IL (e.g. LINQ). The metric
             being used is based on a screen (1024 x 768) full of source code where the 
             number of IL instructions were counted. By default the maximum number of IL 
             instructions is defined to be 165.
             </summary><remarks>To be added.</remarks><example>
             Bad example:
             <code>
             public void LongMethod ()
             {
            	Console.WriteLine ("I'm writting a test, and I will fill a screen with some useless code");
            	IList list = new ArrayList ();
             	list.Add ("Foo");
             	list.Add (4);
             	list.Add (6);
            	
            	IEnumerator listEnumerator = list.GetEnumerator ();
            	while (listEnumerator.MoveNext ()) {
            		Console.WriteLine (listEnumerator.Current);
            	}
             
             	try {
            		list.Add ("Bar");
            		list.Add ('a');
            	}
            	catch (NotSupportedException exception) {
            		Console.WriteLine (exception.Message);
            		Console.WriteLine (exception);
            	}
            	 
            	foreach (object value in list) {
            		Console.Write (value);
            		Console.Write (Environment.NewLine);
            	}
             
            	int x = 0;
            	for (int i = 0; i &lt; 100; i++) {
            		x++;
            	}
            	Console.WriteLine (x);
               
            	string useless = "Useless String";
            	if (useless.Equals ("Other useless")) {
             		useless = String.Empty;
            		Console.WriteLine ("Other useless string");
            	}
             
            	useless = String.Concat (useless," 1");
            	for (int j = 0; j &lt; useless.Length; j++) {
            		if (useless[j] == 'u') {
            			Console.WriteLine ("I have detected an u char");
            		} else {
            			Console.WriteLine ("I have detected an useless char");
            		}
            	}
                        
            	try {
            		foreach (string environmentVariable in Environment.GetEnvironmentVariables ().Keys) {
            			Console.WriteLine (environmentVariable);
            		}
            	}
            	catch (System.Security.SecurityException exception) {
            		Console.WriteLine (exception.Message);
            		Console.WriteLine (exception);
            	}
             
            	Console.WriteLine ("I will add more useless code !!");
            	try {
            		if (!(File.Exists ("foo.txt"))) {
            			File.Create ("foo.txt");    
            			File.Delete ("foo.txt");
            		}
            	}
            	catch (IOException exception) {
            		Console.WriteLine (exception.Message);
            		Console.WriteLine (exception);
            	}
             }
             </code></example><example>
             Good example:
             <code>
             public void ShortMethod ()
             {
            	try {
            		foreach (string environmentVariable in Environment.GetEnvironmentVariables ().Keys) {
            			Console.WriteLine (environmentVariable);
            		}
            	}
            	catch (System.Security.SecurityException exception) {
            		Console.WriteLine (exception.Message);
            		Console.WriteLine (exception);
            	}
             }
             </code></example></Docs><Members><Member MemberName=".ctor"><MemberSignature Language="C#" Value="public AvoidLongMethodsRule ();" /><MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /><MemberType>Constructor</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><Parameters /><Docs><summary>To be added.</summary><remarks>To be added.</remarks></Docs></Member><Member MemberName="CheckMethod"><MemberSignature Language="C#" Value="public Gendarme.Framework.RuleResult CheckMethod (Mono.Cecil.MethodDefinition method);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance valuetype Gendarme.Framework.RuleResult CheckMethod(class Mono.Cecil.MethodDefinition method) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>Gendarme.Framework.RuleResult</ReturnType></ReturnValue><Parameters><Parameter Name="method" Type="Mono.Cecil.MethodDefinition" /></Parameters><Docs><param name="method">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks></Docs></Member><Member MemberName="MaxInstructions"><MemberSignature Language="C#" Value="public int MaxInstructions { get; set; }" /><MemberSignature Language="ILAsm" Value=".property instance int32 MaxInstructions" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Int32</ReturnType></ReturnValue><Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs></Member><Member MemberName="MaxSourceLineOfCode"><MemberSignature Language="C#" Value="public int MaxSourceLineOfCode { get; set; }" /><MemberSignature Language="ILAsm" Value=".property instance int32 MaxSourceLineOfCode" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Int32</ReturnType></ReturnValue><Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs></Member><Member MemberName="UseIlApproximation"><MemberSignature Language="C#" Value="public bool UseIlApproximation { get; set; }" /><MemberSignature Language="ILAsm" Value=".property instance bool UseIlApproximation" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>4.2.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Boolean</ReturnType></ReturnValue><Docs><summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks></Docs></Member></Members></Type>