public static void OpenWindow() { if (instance == null) { instance = GetWindow <ReflectionTestMethodRunnerWindow>(); } else { FocusWindowIfItsOpen <ReflectionTestMethodRunnerWindow>(); } }
void ShowInfoGUI(Type type, MethodInfo[] infos) { ShowInfoGUI(infos, ref selectM, (f) => { return(ReflectionToCodeDefineInfo.GetMethodInfoToDeclaring(type, f)); }, (f) => { ShowFieldANDPropertyInfo(f, () => { ParameterInfo[] pis = f.GetParameters(); string ss = ""; for (int i = 0; i < pis.Length; i++) { Type tt = pis[i].ParameterType; ss += (string.IsNullOrEmpty(tt.FullName)) ? tt.ToString() : tt.FullName; if (i < (pis.Length - 1)) { ss += ","; } } GUILayout.Space(5); ShowLabel("参数信息", ss); for (int i = 0; i < pis.Length; i++) { ParameterInfo tt = pis[i]; ShowLabel("参数" + i, tt.Name); ShowFieldANDPropertyInfo(tt); GUILayout.Space(6); } MethodInfo m = f.GetBaseDefinition(); if (!f.Equals(m)) { GUILayout.Space(10); ShowLabel("父方法", ReflectionToCodeDefineInfo.GetMethodInfoToDeclaring(type, m)); ShowFieldANDPropertyInfo(m); } }); }, (f) => { if (type.IsAbstract || type.IsInterface) { return; } if (GUILayout.Button("调用测试")) { ReflectionTestMethodRunnerWindow.AddTest(selectCont.data, f); } }); }
void OnGUI() { if (mData == null) { return; } GUILayout.Label("AssemblyName : " + mData.assemblyName); GUILayout.Label("TypeFullName : " + mData.typeFullName); GUILayout.Label("MethodeName : " + mData.methodeName); //GUILayout.Label("IsStatic : " + mData.isStatic); EditorGUILayout.Separator(); selectConsName = EditorDrawGUIUtil.DrawPopup(name, selectConsName, consDefineList); int index = consDefineList.IndexOf(selectConsName); mData.constructorParas = GetConstructorInfoTestValue(consInfos[index]); for (int i = 0; i < mData.constructorParas.parameterDatas.Count; i++) { ParameterData p = mData.constructorParas.parameterDatas[i]; GUILayout.BeginHorizontal("box"); GUILayout.Label(p.parameterType.FullName + " " + p.parameterName); p.setValue = EditorDrawGUIUtil.DrawBaseValue("=", p.setValue); GUILayout.EndHorizontal(); } EditorGUILayout.Separator(); for (int i = 0; i < mData.paramsData.Count; i++) { GUILayout.Label("输入参数:"); TestValue tv = mData.paramsData[i]; for (int j = 0; j < tv.parameterDatas.Count; j++) { ParameterData p = tv.parameterDatas[j]; GUILayout.BeginHorizontal("box"); GUILayout.Label(p.parameterType.FullName + " " + p.parameterName); p.setValue = EditorDrawGUIUtil.DrawBaseValue("=", p.setValue); GUILayout.EndHorizontal(); } GUILayout.Label("预计结果:"); GUILayout.BeginHorizontal("box"); GUILayout.Label(tv.resultWant.parameterType.FullName + " " + tv.resultWant.parameterName); tv.resultWant.setValue = EditorDrawGUIUtil.DrawBaseValue("=", tv.resultWant.setValue); GUILayout.EndHorizontal(); EditorGUILayout.Separator(); if (GUILayout.Button("Run")) { object instance = null; if (!tv.isStatic) { instance = GetTypeInstance(classType, mData.constructorParas); } TestRun(classType, instance, tv); } if (tv.testState == TestState.NoTest) { GUILayout.Label("○"); } else if (tv.testState == TestState.NoPass) { GUILayout.Label("X"); } else { GUILayout.Label("√"); } EditorGUILayout.Separator(); } }