Esempio n. 1
0
        public void Blah()
        {
            MemberHasAttributeMatcher matcher  = new MemberHasAttributeMatcher("CodeWeaving.Matcher.SampleCode.SuperDuperAttribute");
            AssemblyDefinition        assembly = AssemblyFactory.GetAssembly(GetType().Assembly.Location);
            MemberFinder     memberFinder      = new MemberFinder();
            FindMemberUsages findMemberUsages  = new FindMemberUsages();

            foreach (MemberReference member in memberFinder.FindMembers(assembly, matcher))
            {
                PropertyDefinition property = member as PropertyDefinition;
                if (property != null)
                {
                    Console.WriteLine("Found: {0}", property);
                    foreach (MemberUsage usage in findMemberUsages.FindUsages(assembly, property.GetMethod))
                    {
                        Console.WriteLine("Usage: {0}", usage.MethodDefinition);
                        CodeInspector codeInspector = new CodeInspector();
                        codeInspector.Inspect(usage.MethodDefinition, _mocks.DynamicMock <IInspectionVisitor>());

                        ControlFlowGraph controlFlowGraph = FlowGraphFactory.CreateControlFlowGraph(usage.MethodDefinition);
                        // ActionFlowGraph actionFlowGraph = FlowGraphFactory.CreateActionFlowGraph(controlFlowGraph);
                        StringWriter writer = new StringWriter();
                        FormatControlFlowGraph(writer, controlFlowGraph);
                        Console.WriteLine(writer.ToString());
                    }
                }
            }
        }
        public void Blah()
        {
            MemberHasAttributeMatcher matcher = new MemberHasAttributeMatcher("CodeWeaving.Matcher.SampleCode.SuperDuperAttribute");
              AssemblyDefinition assembly = AssemblyFactory.GetAssembly(GetType().Assembly.Location);
              MemberFinder memberFinder = new MemberFinder();
              FindMemberUsages findMemberUsages = new FindMemberUsages();
              foreach (MemberReference member in memberFinder.FindMembers(assembly, matcher))
              {
            PropertyDefinition property = member as PropertyDefinition;
            if (property != null)
            {
              Console.WriteLine("Found: {0}", property);
              foreach (MemberUsage usage in findMemberUsages.FindUsages(assembly, property.GetMethod))
              {
            Console.WriteLine("Usage: {0}", usage.MethodDefinition);
            CodeInspector codeInspector = new CodeInspector();
            codeInspector.Inspect(usage.MethodDefinition, _mocks.DynamicMock<IInspectionVisitor>());

            ControlFlowGraph controlFlowGraph = FlowGraphFactory.CreateControlFlowGraph(usage.MethodDefinition);
            // ActionFlowGraph actionFlowGraph = FlowGraphFactory.CreateActionFlowGraph(controlFlowGraph);
            StringWriter writer = new StringWriter();
            FormatControlFlowGraph(writer, controlFlowGraph);
            Console.WriteLine(writer.ToString());
              }
            }
              }
        }
 public void Inspect_AllTypesInOurAssemblies_DoesntFail()
 {
     AssemblyDefinition assembly = AssemblyFactory.GetAssembly(typeof(CodeInspector).Assembly.Location);
       foreach (TypeDefinition type in assembly.MainModule.Types)
       {
     foreach (MethodDefinition method in type.Methods)
     {
       if (method.Body != null)
       {
     CodeInspector codeInspector = new CodeInspector();
     codeInspector.Inspect(method, new NullInspectionVisitor());
       }
     }
       }
 }
Esempio n. 4
0
 public CodeSnippets(CodeInspector code)
 {
     _code = code;
 }