Beispiel #1
0
        public void ScanMethodBody(string app, MethodDefinition methd, ICollection filters)
        {
            if (methd.Body == null)
            {
                return;
            }

            Collectors.OnMethodBody(methd.Body);

            foreach (Mono.Cecil.Cil.Instruction i in methd.Body.Instructions)
            {
                if (CodeProperties.IsMethodCall(i))
                {
                    //if (i.Operand is Mono.Cecil.CallSite || i.Operand is Mono.Cecil.FieldReference)
                    //    continue;

                    MethodReference rf       = (MethodReference)i.Operand;
                    string          typeName = CodeProperties.GetClassName(rf.DeclaringType);
                    string          methName = CodeProperties.GetMethodNameWithParameters(((MethodReference)i.Operand));

                    if (filters.Count > 0)
                    {
                        if (IsIncluded(filters, typeName))
                        {
                            ProcessMethod(methd, rf, typeName, methName);
                        }
                    }
                    else
                    {
                        ProcessMethod(methd, rf, typeName, methName);
                    }
                }
            }
        }
Beispiel #2
0
        private void CountRankedUsage(MethodDefinition callingContext, MethodResult mr)
        {
            if (m_dtCodeRank != null)
            {
                string contextTypeName = CodeProperties.GetClassName(callingContext.DeclaringType);
                string contextMethName = CodeProperties.GetMethodNameWithParameters(callingContext);

                mr.MethodRankedFrequency += Rank(m_app, contextTypeName, contextMethName);
            }
        }
Beispiel #3
0
        // Add edges to virtual methods or after the fact?
        public override void OnMethodCall(MethodDefinition callingContext, MethodReference methodCall,
                                          string callTypeName, string callMethodName, bool isSystem, bool isExternal)
        {
            // Don't include system calls.
            if (isSystem)
            {
                return;
            }

            string contextTypeName = CodeProperties.GetClassName(callingContext.DeclaringType);
            string contextMethName = CodeProperties.GetMethodNameWithParameters(callingContext);

            m_graph.Add(contextTypeName, contextMethName, callTypeName, callMethodName);
        }