Example #1
0
        static void TestAll()
        {
            logger.Log_Warning("TestAll.");
            //reset
            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();
                }
            }
            int finish = 0;

            foreach (var m in tests)
            {
                try
                {
                    TestOne(m, false, false);
                    finish++;
                }
                catch (Exception err)
                {
                }
            }
            logger.Log_Warning("TestAllEnd. Count:" + finish + "/" + tests.Count);
        }
Example #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            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();
                }
            }
            System.Threading.ThreadPool.QueueUserWorkItem((s) =>
            {
                Mono.Cecil.MethodDefinition d = this.treeView2.Tag as Mono.Cecil.MethodDefinition;
                try
                {
                    object obj = RunTest(d);
                    Log("----RunOK----" + obj);
                }
                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);
                }
            });
        }
Example #3
0
    void TestAll()
    {
        logmode = 0;
        Log_Warning("TestAll.");
        //reset
        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();
                Debug.Log("Reset:" + t);
            }
        }
        int finish = 0;

        //string text = "";
        foreach (var m in tests)
        {
            if (m.bSucc && bHideRight)
            {
                continue;
            }
            try
            {
                if (m.method.Contains("UnitTest_TestThread"))
                {
                    continue;
                }
                //text += "Begin==" + m.method + "==\n";
                //System.IO.File.WriteAllText("e:\\log.txt", text);
                TestOne(m.m, false, false);
                finish++;
                m.bSucc = true;
                //text += "<succ>==" + m.method + "==\n";
                //System.IO.File.WriteAllText("e:\\log.txt", text);
                m.bError = false;
            }
            catch (Exception err)
            {
                //text += "<fail>==" + m.method + "==\n";
                //System.IO.File.WriteAllText("e:\\log.txt", text);

                m.bError = true;
                m.bSucc  = false;
                Log_Error(m.ToString() + "|||" + err.ToString());
            }
        }
        Log_Warning("TestAllEnd. Count:" + finish + "/" + tests.Count);
        logmode = 1;
    }
Example #4
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 + ")----");
        }
Example #5
0
    void TestAll()
    {
        logmode = 0;
        Log_Warning("TestAll.");
        //reset
        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();
                Debug.Log("Reset:" + t);
            }
        }
        int finish = 0;

        foreach (var m in tests)
        {
            if (m.bSucc && bHideRight)
            {
                continue;
            }
            try
            {
                TestOne(m.m, false, false);
                finish++;
                m.bSucc  = true;
                m.bError = false;
            }
            catch (Exception err)
            {
                m.bError = true;
                m.bSucc  = false;
                Log_Error(m.ToString() + "|||" + err.ToString());
            }
        }
        Log_Warning("TestAllEnd. Count:" + finish + "/" + tests.Count);
        logmode = 1;
    }
Example #6
0
        public static object FromJson(object ScriptType, MyJson.JsonNode_Object data)
        {
            CLRSharp.ICLRType_Sharp    type = ScriptType as CLRSharp.ICLRType_Sharp;
            CLRSharp.CLRSharp_Instance s    = new CLRSharp.CLRSharp_Instance(type);
            type.GetMethod(".ctor", CLRSharp.MethodParamList.constEmpty()).Invoke(null, s, new object[] { });


            foreach (var m in type.GetFieldNames())
            {
                var field = type.GetField(m);
                if (field.isStatic)
                {
                    continue;
                }
                //s.Fields[m] = field.DefValue;

                //        s.member[m.Key] = new CSLE.CLS_Content.Value();
                //        s.member[m.Key].type = m.Value.type.type;
                //        s.member[m.Key].value = m.Value.type.DefValue;//先填默认值

                if (data.ContainsKey(m) == false)//json中没有的部分填默认值
                {
                    continue;
                }
                if (data[m].IsNull())//json中没有的部分填默认值
                {
                    continue;
                }

                {
                    if ((Type)field.FieldType.TypeForSystem == typeof(int))
                    {
                        s.Fields[m] = data[m].AsInt();
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(float))
                    {
                        s.Fields[m] = (float)data[m].AsDouble();
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(double))
                    {
                        s.Fields[m] = data[m].AsDouble();
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(string))
                    {
                        s.Fields[m] = data[m].AsString();
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(List <CLRSharp.CLRSharp_Instance>))
                    {
                        //处理List
                        List <CLRSharp.CLRSharp_Instance> list = new List <CLRSharp.CLRSharp_Instance>();
                        s.Fields[m] = list;
                        var subtype = field.FieldType.SubTypes[0];
                        foreach (MyJson.JsonNode_Object item in data[m].AsList())
                        {
                            list.Add(FromJson(subtype, item) as CLRSharp.CLRSharp_Instance);
                        }
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(List <string>))
                    {
                        List <string> list = new List <string>();
                        s.Fields[m] = list;
                        foreach (MyJson.JsonNode_ValueString item in data[m].AsList())
                        {
                            list.Add(item);
                        }
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(List <int>))
                    {
                        List <int> list = new List <int>();
                        s.Fields[m] = list;
                        foreach (MyJson.JsonNode_ValueNumber item in data[m].AsList())
                        {
                            list.Add(item);
                        }
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(List <float>))
                    {
                        List <float> list = new List <float>();
                        s.Fields[m] = list;
                        foreach (MyJson.JsonNode_ValueNumber item in data[m].AsList())
                        {
                            list.Add(item);
                        }
                    }
                    else if ((Type)field.FieldType.TypeForSystem == typeof(List <double>))
                    {
                        List <double> list = new List <double>();
                        s.Fields[m] = list;
                        foreach (MyJson.JsonNode_ValueNumber item in data[m].AsList())
                        {
                            list.Add(item);
                        }
                    }
                    else if (field.FieldType.TypeForSystem == typeof(CLRSharp.CLRSharp_Instance))//其他嵌套脚本类型
                    {
                        s.Fields[m] = FromJson(field.FieldType, data[m] as MyJson.JsonNode_Object);
                    }
                    else
                    {
                        Logger.Log("发现不能处理的类型:" + type + ":" + m + ":" + type.GetField(m).FieldType);
                    }
                }
            }


            return(s);
        }