Exemple #1
0
        static void ModifyCode(ClassDef classDef, MethodDef methodDef, Method startLogMethod, Method endLogMethod)
        {
            if (methodDef is null)
            {
                return;
            }
            bool bIsHavReturn = methodDef.GetRetType().TypeName().ToLower() != "void";

            Console.WriteLine("Processing  Method:" + classDef.Name() + "." + methodDef.Name() + "  Return Type: " + methodDef.GetRetType().TypeName());
            if (!bIsHavReturn)
            {
                ILSY.ILSpyMtNoRt(classDef, methodDef, startLogMethod, endLogMethod);
            }
            else
            {
                ILSY.ILSpyMtHvRt(classDef, methodDef, startLogMethod, endLogMethod);
            }
        }
Exemple #2
0
        static void ProcessClass(ClassDef classDef, Method startLogMethod, Method endLogMethod)
        {
            // Don't modify the class methods that we are going to emit calls to, otherwise we'll get unbounded recursion.
            //if (classDef.Name() == methodLoggerClassName)
            //    return;

            //if (classFilter.PassesFilter(classDef) == false)
            //    return;

            foreach (NestedClassDef c in classDef.GetNestedClasses())
            {
                ProcessClass(c, startLogMethod, endLogMethod);
            }
            Console.WriteLine("Processing  Class:" + classDef.Name());
            foreach (MethodDef methodDef in classDef.GetMethods())
            {
                if (methodDef.Name().ToLower() == ".ctor" || methodDef.Name().ToLower() == "dispose" || methodDef.Name().ToLower() == "initializecomponent")
                {
                    continue;
                }
                ModifyCode(classDef, methodDef, startLogMethod, endLogMethod);
            }
        }
Exemple #3
0
 public static string GetQualifiedClassName(ClassDef classDef)
 {
     return(classDef.NameSpace().Length == 0 ? classDef.Name() : classDef.NameSpace() + "." + classDef.Name());
 }