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); } } } }
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); } }
// 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); }