Beispiel #1
0
        private void DoCrossAssemblyWalk(MethodGraph methodGraph, string companyAssembliesPattern, ModuleDefinition module, string moduleMessagee)
        {
            var publicMethods = DecompilerService.GetPublicMethods(companyAssembliesPattern, module)
                                .Where(x => !IsBlackListed(x))
                                .OrderBy(x => x.DeclaringType.Name)
                                .ThenBy(x => x.Name)
                                .ToList();

            int methodCount           = publicMethods.Count;
            var publicMethodsAnalyzed = new HashSet <string>();

            _methodNodeLookup.Clear();

            int methodCounter = 0;

            foreach (var publicMethod in publicMethods)
            {
                methodCounter++;
                _logOutput.LogAnalysis("Method " + methodCounter + " of " + methodCount + " : " + moduleMessagee + " -> " + publicMethod.Name);
                if ((publicMethod.IsGetter || publicMethod.IsSetter) && !IsNoteworthyProperty(publicMethod))
                {
                    continue;
                }

                var signature = SignatureKeyService.GetFullMethodSignature(publicMethod);
                if (_methodIndexer.HasMethod(signature))
                {
                    var unfilteredRootNodes = _methodIndexer.GetMethods(signature);
                    var rootNodes           = unfilteredRootNodes.Where(x => x.HasImplementation() &&
                                                                        (
                                                                            // if it is a public implementation of a different assembly, then'll we'll filter it out here (and analyze it that assembly)
                                                                            (x.ConcreteMethod.IsPublic && x.ConcreteMethod.Module.Name.Equals(module.Name))
                                                                            // if it is a private implementation then analyze it now as we'll miss it when we analyze the public methods of the other assembly
                                                                            || !x.ConcreteMethod.DeclaringType.IsPublic
                                                                        )
                                                                        )
                                              .ToList();

                    foreach (var rootMethod in rootNodes)
                    {
                        if (!AlreadyProcessed(rootMethod.GetMethodDefinition()))
                        {
                            var publicMethodNode = GetMethodNode(methodGraph.GraphType, methodGraph.ApplicationName, rootMethod);
                            var callTreeNode     = new ExploreTreeNode()
                            {
                                FullSignature = signature
                            };
                            CrossAssemblyWalk(methodGraph, publicMethodNode, rootMethod, 1, callTreeNode);
                            CacheNode(rootMethod.GetMethodDefinition(), publicMethodNode);
                            methodGraph.AddMethodNode(publicMethodNode);
                        }
                    }
                }
            }
        }
        public void IndexTriples(ModuleDefinition module)
        {
            int counter = 0;
            int total   = module.Types.Count;

            foreach (var type in module.Types)
            {
                counter++;
                _logOutput.LogAnalysis(counter + " types of " + total);
                IndexTriples(type);
            }
        }
        private void ParseMainScope(MainScope mainScope, MethodDefinition methodDefinition, List <Triple> triples)
        {
            foreach (var instruction in mainScope.Instructions)
            {
                ValidateInstruction(instruction);

                if (IsToTrigger(instruction))
                {
                    try
                    {
                        ParseInstruction(instruction, methodDefinition, triples);
                    }
                    catch (ILParseException ex)
                    {
                        _logOutput.LogAnalysis("ERROR " + ex.Message);
                    }
                }
            }
        }