Пример #1
0
 public static IList<TypeReference> GetDirectDependencies(TypeDefinition type)
 {
     var dep = new List<TypeReference>();
     
     dep.AddNotExist(type.BaseType);
     foreach (var field in type.Fields)
     {
         dep.AddNotExist(field.FieldType);
     }
     return dep;
 }
Пример #2
0
        public static IList <TypeReference> GetDirectDependencies(TypeDefinition type)
        {
            var dep = new List <TypeReference>();

            dep.AddNotExist(type.BaseType);
            foreach (var field in type.Fields)
            {
                dep.AddNotExist(field.FieldType);
            }
            return(dep);
        }
Пример #3
0
 public static ScanResult ScanMethod(MethodDefinition method)
 {
     try
     {
         var dep = new List <MemberAccess>();
         if (!method.HasBody)
         {
             return(new ScanResult(dep, method, 0));
         }
         int complexity = 0;
         for (int index = 0; index < method.Body.Instructions.Count; index++)
         {
             var instruction = method.Body.Instructions[index];
             var memberRef   = instruction.Operand as MemberReference;
             if (branches[(int)instruction.OpCode.Code])
             {
                 complexity++;
             }
             if (memberRef != null)
             {
                 var methodReference = memberRef as MethodReference;
                 var info            = new MethodCallInfo(false, null, false);
                 if (methodReference != null && methodReference.HasThis)
                 {
                     info = GetEnhancedCallInformation(instruction, method.HasThis);
                 }
                 var methodDef = memberRef as MethodDefinition;
                 if (instruction.OpCode == OpCodes.Ldfld || instruction.OpCode == OpCodes.Ldsfld ||
                     (methodDef != null && methodDef.IsConstructor))
                 {
                     dep.AddNotExist(new MemberAccess(memberRef, true, info.IsSelfCall, info.FieldReference,
                                                      methodReference, info.IsLocal));
                 }
                 else
                 {
                     dep.AddNotExist(new MemberAccess(memberRef, false, info.IsSelfCall, info.FieldReference,
                                                      methodReference, info.IsLocal));
                 }
             }
         }
         return(new ScanResult(dep, method, complexity));
     }
     catch (Exception ex)
     {
         throw new MethodDependencyDetectionFailedException(method.GetCacheName(), ex);
     }
 }
Пример #4
0
 public static ScanResult ScanMethod(MethodDefinition method)
 {
     try
     {
         var dep = new List<MemberAccess>();
         if (!method.HasBody) return new ScanResult(dep, method, 0);
         int complexity = 0;
         for (int index = 0; index < method.Body.Instructions.Count; index++)
         {
             var instruction = method.Body.Instructions[index];
             var memberRef = instruction.Operand as MemberReference;
             if (branches[(int) instruction.OpCode.Code])
             {
                 complexity++;
             }
             if (memberRef != null)
             {
                 var methodReference = memberRef as MethodReference;
                 var info = new MethodCallInfo(false, null, false);
                 if (methodReference != null && methodReference.HasThis)
                 {
                     info = GetEnhancedCallInformation(instruction, method.HasThis);
                 }
                 var methodDef = memberRef as MethodDefinition;
                 if (instruction.OpCode == OpCodes.Ldfld || instruction.OpCode == OpCodes.Ldsfld ||
                     (methodDef != null && methodDef.IsConstructor))
                     dep.AddNotExist(new MemberAccess(memberRef, true, info.IsSelfCall, info.FieldReference,
                                                      methodReference, info.IsLocal));
                 else
                     dep.AddNotExist(new MemberAccess(memberRef, false, info.IsSelfCall, info.FieldReference,
                                                      methodReference, info.IsLocal));
             }
         }
         return new ScanResult(dep, method, complexity);
     }
     catch (Exception ex)
     {
         throw new MethodDependencyDetectionFailedException(method.GetCacheName(), ex);
     }
 }