Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CLRSharp.VBox.newcount = 0;
            var types = env.GetAllTypes();

            foreach (var t in types)
            {
                CLRSharp.ICLRType_Sharp type = env.GetType(t) as CLRSharp.ICLRType_Sharp;
                if (type != null)
                {
                    type.ResetStaticInstace();
                }
            }

            Mono.Cecil.MethodDefinition d = this.treeView2.Tag as Mono.Cecil.MethodDefinition;
            try
            {
                object obj = RunTest(d);
                Log("----RunOK----" + obj);
                Log("Vbox new:" + CLRSharp.VBox.newcount);
            }
            catch (Exception err)
            {
                Log("----RunErr----");
                Log_Error(err.ToString());
                MessageBox.Show(
                    "=DumpInfo FirstLine Is Error Pos.=\n" +
                    CLRSharp.ThreadContext.activeContext.Dump()
                    + "================err===============\n" + err.Message);
            }
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var bytes    = System.IO.File.ReadAllBytes("UnitTestDll.dll");
            var bytespdb = System.IO.File.ReadAllBytes("UnitTestDll.pdb");

            System.IO.MemoryStream ms    = new System.IO.MemoryStream(bytes);
            System.IO.MemoryStream mspdb = new System.IO.MemoryStream(bytespdb);

            env        = new CLRSharp.CLRSharp_Environment(this);
            this.Text += " L# Ver:" + env.version;
            env.LoadModule(ms, mspdb);
            var types = env.GetAllTypes();

            foreach (var t in types)
            {
                var tclr = env.GetType(t, null) as CLRSharp.Type_Common_CLRSharp;
                if (tclr != null && tclr.type_CLRSharp.HasMethods)
                {
                    TreeNode node = new TreeNode(t);
                    treeView1.Nodes.Add(node);
                    foreach (var m in tclr.type_CLRSharp.Methods)
                    {
                        TreeNode method = new TreeNode(m.Name);
                        method.Tag = m;
                        node.Nodes.Add(method);
                        if (m.HasParameters == false && m.Name.Contains("UnitTest") && m.IsStatic)
                        {
                            method.BackColor = Color.Yellow;
                        }
                    }
                    if (tclr.type_CLRSharp.HasNestedTypes)
                    {
                        TreeNode nt = new TreeNode("NestedTypes");
                        node.Nodes.Add(nt);
                        foreach (var ttt in tclr.type_CLRSharp.NestedTypes)
                        {
                            TreeNode snt = new TreeNode(ttt.Name);
                            nt.Nodes.Add(snt);
                            if (ttt.HasMethods)
                            {
                                foreach (var m in ttt.Methods)
                                {
                                    TreeNode method = new TreeNode(m.Name);
                                    method.Tag = m;
                                    snt.Nodes.Add(method);
                                }
                            }
                        }
                    }
                }
            }
            SortTreeView();
            treeView1.ExpandAll();
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            var types = env.GetAllTypes();

            foreach (var t in types)
            {
                CLRSharp.ICLRType_Sharp type = env.GetType(t, null) as CLRSharp.ICLRType_Sharp;
                if (type != null)
                {
                    type.ResetStaticInstace();
                }
            }
            int testcount = 0;
            int succcount = 0;

            foreach (TreeNode t in treeView1.Nodes)
            {
                foreach (TreeNode method in t.Nodes)
                {
                    Mono.Cecil.MethodDefinition m = method.Tag as Mono.Cecil.MethodDefinition;
                    if (m == null)
                    {
                        continue;
                    }
                    if (m.HasParameters == false && m.Name.Contains("UnitTest") && m.IsStatic)
                    {
                        testcount++;
                        try
                        {
                            object obj = RunTest(m);
                            method.BackColor = Color.YellowGreen;
                            succcount++;
                            Log("----TestOK----" + m.ToString());
                        }
                        catch (Exception err)
                        {
                            method.BackColor = Color.Red;
                            Log("----Test Fail----" + m.ToString());
                        }
                    }
                }
            }
            Log("----Test Succ(" + succcount + "/" + testcount + ")----");
        }
Пример #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var bytes    = System.IO.File.ReadAllBytes("UnitTestDll.dll");
            var bytespdb = System.IO.File.ReadAllBytes("UnitTestDll.pdb");

            //var bytesmdb = System.IO.File.ReadAllBytes("UnitTestDll.dll.mdb");//现在支持mdb了
            System.IO.MemoryStream ms    = new System.IO.MemoryStream(bytes);
            System.IO.MemoryStream mspdb = new System.IO.MemoryStream(bytespdb);
            //System.IO.MemoryStream msmdb = new System.IO.MemoryStream(bytesmdb);

            env        = new CLRSharp.CLRSharp_Environment(this);
            this.Text += " L# Ver:" + env.version;
            try
            {
                env.LoadModule(ms, mspdb, new Mono.Cecil.Pdb.PdbReaderProvider());
                //env.LoadModule(ms, msmdb, new Mono.Cecil.Mdb.MdbReaderProvider());
            }
            catch (Exception err)
            {
                try
                {
                    env.LoadModule(ms, null, null);
                    Log_Error("符号文件无法识别");
                }
                catch
                {
                    this.Log_Error(err.ToString());
                    this.Log_Error("模块未加载完成,请检查错误");
                }
            }
            var types = env.GetAllTypes();

            foreach (var t in types)
            {
                var tclr = env.GetType(t) as CLRSharp.Type_Common_CLRSharp;
                if (tclr != null && tclr.type_CLRSharp.HasMethods)
                {
                    TreeNode node = new TreeNode(t);
                    treeView1.Nodes.Add(node);
                    foreach (var m in tclr.type_CLRSharp.Methods)
                    {
                        TreeNode method = new TreeNode(m.Name);
                        method.Tag = m;
                        node.Nodes.Add(method);
                        if (m.HasParameters == false && m.Name.Contains("UnitTest") && m.IsStatic)
                        {
                            method.BackColor = Color.Yellow;
                        }
                    }
                    if (tclr.type_CLRSharp.HasNestedTypes)
                    {
                        TreeNode nt = new TreeNode("NestedTypes");
                        node.Nodes.Add(nt);
                        foreach (var ttt in tclr.type_CLRSharp.NestedTypes)
                        {
                            TreeNode snt = new TreeNode(ttt.Name);
                            nt.Nodes.Add(snt);
                            if (ttt.HasMethods)
                            {
                                foreach (var m in ttt.Methods)
                                {
                                    TreeNode method = new TreeNode(m.Name);
                                    method.Tag = m;
                                    snt.Nodes.Add(method);
                                }
                            }
                        }
                    }
                }
            }
            SortTreeView();
            treeView1.ExpandAll();
        }
Пример #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var bytes = System.IO.File.ReadAllBytes("UnitTestDll.dll");
            var bytespdb = System.IO.File.ReadAllBytes("UnitTestDll.pdb");
            //var bytesmdb = System.IO.File.ReadAllBytes("UnitTestDll.dll.mdb");//现在支持mdb了
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
            System.IO.MemoryStream mspdb = new System.IO.MemoryStream(bytespdb);
            //System.IO.MemoryStream msmdb = new System.IO.MemoryStream(bytesmdb);

            env = new CLRSharp.CLRSharp_Environment(this);
            this.Text += " L# Ver:" + env.version;
            try
            {
                env.LoadModule(ms, mspdb, new Mono.Cecil.Pdb.PdbReaderProvider());
                //env.LoadModule(ms, msmdb, new Mono.Cecil.Mdb.MdbReaderProvider());
            }
            catch (Exception err)
            {
                this.Log_Error(err.ToString());
                this.Log_Error("模块未加载完成,请检查错误");
            }
            var types = env.GetAllTypes();
            foreach (var t in types)
            {
                var tclr = env.GetType(t) as CLRSharp.Type_Common_CLRSharp;
                if (tclr != null && tclr.type_CLRSharp.HasMethods)
                {
                    TreeNode node = new TreeNode(t);
                    treeView1.Nodes.Add(node);
                    foreach (var m in tclr.type_CLRSharp.Methods)
                    {
                        TreeNode method = new TreeNode(m.Name);
                        method.Tag = m;
                        node.Nodes.Add(method);
                        if (m.HasParameters == false && m.Name.Contains("UnitTest") && m.IsStatic)
                        {
                            method.BackColor = Color.Yellow;
                        }
                    }
                    if (tclr.type_CLRSharp.HasNestedTypes)
                    {
                        TreeNode nt = new TreeNode("NestedTypes");
                        node.Nodes.Add(nt);
                        foreach (var ttt in tclr.type_CLRSharp.NestedTypes)
                        {
                            TreeNode snt = new TreeNode(ttt.Name);
                            nt.Nodes.Add(snt);
                            if (ttt.HasMethods)
                            {
                                foreach (var m in ttt.Methods)
                                {
                                    TreeNode method = new TreeNode(m.Name);
                                    method.Tag = m;
                                    snt.Nodes.Add(method);
                                }
                            }
                        }
                    }

                }

            }
            SortTreeView();
            treeView1.ExpandAll();
        }