Exemplo n.º 1
0
 public void MainTest()
 {
     string[] assemblyPaths = new string[] {
         @"C:\Dev\OmniQuery\OmniQuery.Test\bin\Debug\OmniQuery.Test.dll",
     };
     CodeAnalysis analysis = new CodeAnalysis(assemblyPaths);
 }
Exemplo n.º 2
0
        public void TestMethods()
        {
            string assemblyFolder = "temp";
            string[] systemAssemblies = Utility.GetSystemAssemblies();
            //string[] systemAssemblies = new string[] { @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.EnterpriseServices.dll" };
            Utility.CreateAssemblyFolder(assemblyFolder, systemAssemblies);

            foreach (string assemblyPath in systemAssemblies)
            {
                string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath);
                string query = string.Format("SELECT METHODS FROM ASSEMBLIES \"{0}\" ORDER BY NbMethods", assemblyName);
                NDependProject project = new NDependProject("MethodProject", assemblyFolder, null);
                NDependResults result = project.AnalyzeQuery(null, query);

                CodeAnalysis analysis = new CodeAnalysis(new string[] { assemblyPath });
                Console.WriteLine("{0} ( {1} , {2} )", assemblyName, result.Count, analysis.Methods.Count);
                //Assert.True(result.Count <= analysis.Methods.Count);
            }
        }
Exemplo n.º 3
0
        public void QueryTest()
        {
            CodeAnalysis analysis;

            using (new PerfWatch("Retrieving assemblies"))
            {
                //analysis = new CodeAnalysis(@"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Web.dll");
                analysis = new CodeAnalysis(Utility.GetSystemAssemblies());
            }

            using (new PerfWatch("Query total"))
            {
                using (new PerfWatch("Running query 1"))
                {
                    var result =
                        from a in analysis.Assemblies
                        from mod in a.Modules
                        from t in mod.Types
                        from m in t.Methods
                        where m.Name.StartsWith("get_")
                        select m.FullName;

                    string[] arr = result.ToArray();
                }

                for (int i = 2; i < 5; i++)
                {
                    using (new PerfWatch("Running query " + i))
                    {
                        var result =
                            from a in analysis.Assemblies
                            from mod in a.Modules
                            from t in mod.Types
                            from m in t.Methods
                            where t.Methods.Count > 10
                            select m.FullName;

                        string[] arr = result.ToArray();
                    }
                }
            }
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public Main()
        {
            InitializeComponent();

            string analysisPath = @"C:\Dev\OmniQuery\OmniQuery.Test\bin\Debug\OmniQuery.Test.dll";
            _analysis = new CodeAnalysis(analysisPath);

            TreeNode parentNode = new TreeNode("System.Web.dll");
            TreeNode assemblyNode = new TreeNode("Assemblies" );
            TreeNode moduleNode = new TreeNode("Modules");
            TreeNode typeNode = new TreeNode("Types");
            TreeNode methodNode = new TreeNode("Methods");
            TreeNode resourceNode = new TreeNode("Resources");

            parentNode.Nodes.AddRange(new TreeNode[] { assemblyNode, moduleNode, typeNode, methodNode, resourceNode });
            parentNode.Expand();
            AnalysisTree.Nodes.Add(parentNode);

            AnalysisTree.DoubleClick += new EventHandler(AnalysisTree_DoubleClick);
            QueryText.KeyDown += new KeyEventHandler(QueryText_KeyDown);
            QueryText.KeyUp += new KeyEventHandler(QueryText_KeyUp);
        }