CompareMethodAgainstTypeMethods() private method

private CompareMethodAgainstTypeMethods ( Mono.Cecil.MethodDefinition current, Mono.Cecil.TypeDefinition targetType ) : void
current Mono.Cecil.MethodDefinition
targetType Mono.Cecil.TypeDefinition
return void
Exemplo n.º 1
0
 private void FindCodeDuplicated(TypeDefinition type)
 {
     foreach (MethodDefinition method in type.Methods)
     {
         foreach (TypeDefinition sibling in siblingClasses)
         {
             codeDuplicatedLocator.CompareMethodAgainstTypeMethods(method, sibling);
         }
     }
 }
 private void FindCodeDuplicated(TypeDefinition type, ICollection siblingClasses)
 {
     foreach (MethodDefinition method in type.Methods)
     {
         foreach (TypeDefinition sibling in siblingClasses)
         {
             foreach (Message message in codeDuplicatedLocator.CompareMethodAgainstTypeMethods(method, sibling))
             {
                 messageCollection.Add(message);
             }
         }
     }
 }
		public MessageCollection CheckType (TypeDefinition typeDefinition, Runner runner) 
		{
			messageCollection = new MessageCollection ();
			CodeDuplicatedLocator codeDuplicatedLocator = new CodeDuplicatedLocator ();
			foreach (MethodDefinition currentMethod in typeDefinition.Methods) {
				foreach (Message message in codeDuplicatedLocator.CompareMethodAgainstTypeMethods (currentMethod, typeDefinition)) {
					messageCollection.Add (message);
				}
				codeDuplicatedLocator.CheckedMethods.Add (currentMethod.Name);
			}
			
			if (messageCollection.Count == 0)
				return null;
			return messageCollection;
		}
Exemplo n.º 4
0
        public MessageCollection CheckType(TypeDefinition typeDefinition, Runner runner)
        {
            messageCollection = new MessageCollection();
            CodeDuplicatedLocator codeDuplicatedLocator = new CodeDuplicatedLocator();

            foreach (MethodDefinition currentMethod in typeDefinition.Methods)
            {
                foreach (Message message in codeDuplicatedLocator.CompareMethodAgainstTypeMethods(currentMethod, typeDefinition))
                {
                    messageCollection.Add(message);
                }
                codeDuplicatedLocator.CheckedMethods.Add(currentMethod.Name);
            }

            if (messageCollection.Count == 0)
            {
                return(null);
            }
            return(messageCollection);
        }
Exemplo n.º 5
0
        public RuleResult CheckType(TypeDefinition type)
        {
            // don't analyze cases where no methods (or body) are available
            if (type.IsEnum || type.IsInterface || !type.HasMethods)
            {
                return(RuleResult.DoesNotApply);
            }

            // ignore code generated by compiler/tools, since they can generate some amount of duplicated code
            if (type.IsGeneratedCode())
            {
                return(RuleResult.DoesNotApply);
            }

            locator.Clear();
            foreach (MethodDefinition current in type.Methods)
            {
                locator.CompareMethodAgainstTypeMethods(current, type);
                locator.CheckedMethods.AddIfNew(current.Name);
            }

            return(Runner.CurrentRuleResult);
        }