public void TestOverloadedMethods() { var obj = new MultipleOverloadedMethodsClass(); var cecilType = CurrentAssembly.FindRuntimeType(typeof(MultipleOverloadedMethodsClass)); var met = Recompiler.RecompileMethod(cecilType.GetMethodByName("test")); var result = met.Invoke(this, new object[] { obj }); Assert.AreEqual(true, (bool)result); }
public void TestInnerAccess() { var obj = new TestClassA(); var cecilType = CurrentAssembly.FindRuntimeType(typeof(TestClassA)); var met2 = Recompiler.RecompileMethod(cecilType.GetMethodByName("dotest")); var result = met2.Invoke(this, new object[] { obj }); Assert.NotNull(obj.obj); Assert.AreEqual(1337, (int)result); }
void TryMethod(System.Type type, string methodName) { var asm = CecilExtensions.CurrentAssembly; var recompiler = new Recompiler(); var cecilType = asm.FindRuntimeType(type); var cecilMethod = cecilType.GetMethodByName(methodName); var realType = recompiler.FindType(cecilType); Assert.AreEqual(type, realType); var realMethod = recompiler.FindMethod(realType, cecilMethod); Assert.NotNull(realMethod); }
static string Eval(string program) { Recompiler rec = null; var parser = new DemoNavi.MyParser(); parser.Parse(program); var programa = parser.Program; if (toMips == true) { rec = new Mips32Recompiler(); } else if (toX86 == true) { rec = new x86Recompiler(); } // Recompiler rec = new Mips32Recompiler(); return(rec.Recompile(programa)); }
/// <summary> /// Draw the custom editor settings as reorderable lists, grouped by target type. /// </summary> private void DrawManager() { // Display a help box if there's no registered custom editors if (m_CustomEditors.Count == 0) { EditorGUILayout.HelpBox("No custom editor", MessageType.Info); return; } // Draw the settings lists in a scroll view to avoid overflow clipping m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition, ScrollViewStyle, GUILayout.ExpandHeight(false)); { foreach (CustomEditorListGroup group in m_CustomEditors) { if (string.IsNullOrEmpty(m_Filter) || group.TargetTypeName.ToLower().Contains(m_Filter.ToLower())) { group.List.DrawList(LeftOffset); } } } EditorGUILayout.EndScrollView(); EditorGUILayout.Space(); // Draw the control buttons EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Reset To Default Settings", GUILayout.Height(BUTTON_HEIGHT))) { if (EditorUtility.DisplayDialog("Reset Custom Editors", "Are you sure you want top reset all custom editor settings to their default values?", "Reset", "Cancel")) { MultipleEditorsManager.ResetDefaultOptions(); Recompiler.Recompile(); } } if (GUILayout.Button("Apply Changes (Reimport)", GUILayout.Height(BUTTON_HEIGHT))) { Recompiler.Recompile(); } } EditorGUILayout.EndHorizontal(); }
public void TestGenericClasses() { var obj1 = new GenericDerivedClass1(); var obj2 = new GenericDerivedClass2(); var cecilType1 = CurrentAssembly.FindRuntimeType(typeof(GenericDerivedClass1)); var cecilType2 = CurrentAssembly.FindRuntimeType(typeof(GenericDerivedClass2)); obj1.add(); obj2.add(); obj2.add(); var met = Recompiler.RecompileMethod(cecilType1.GetMethodByName("test")); var result = met.Invoke(obj1, new object[] { obj1 }); Assert.IsTrue((bool)result); met = Recompiler.RecompileMethod(cecilType2.GetMethodByName("test")); result = met.Invoke(obj2, new object[] { obj2 }); //obj2 was added twice. Test if target method bound to proper field Assert.IsTrue((bool)result); }