public void Call() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); IMethodBuilder Method2 = TestType.CreateMethod("TestMethod2"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.DoesNotThrow(() => Method.This.Call(Method2, null)); }
public void Create() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); Assert.NotNull(Method); }
public void Call() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); Assert.DoesNotThrow <Exception>(() => Local1.Call("ToString")); }
public void Assign() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int)); Assert.DoesNotThrow(() => Field.Assign(12)); }
public void Save() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); Local1.Save(Method.Generator); }
public void Save() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int)); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); Field.Save(Method.Generator); }
public void Load() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); Assert.DoesNotThrow(() => Local1.Load(Method.Generator)); }
public void Load() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int)); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); Assert.DoesNotThrow <Exception>(() => Field.Load(Method.Generator)); }
public void Call() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); Utilities.Reflection.Emit.FieldBuilder Field = TestType.CreateField("Field1", typeof(int)); Field.Call("ToString"); }
public void Cast() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Method.Cast(Method.This, typeof(object)); }
public void Box() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.NotNull(Method.Box(Local1)); }
public void Throw() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.DoesNotThrow <Exception>(() => Method.Throw(Method.NewObj(typeof(Exception)))); }
public void Return() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod", ReturnType: typeof(int)); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.DoesNotThrow(() => Method.Return(Local1)); }
public void NewObj() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Assert.NotNull(Method.NewObj(typeof(DateTime), new object[] { Local1 })); }
public void Create() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); Assert.NotNull(Local1); Assert.Equal(typeof(int), Local1.DataType); Assert.Equal("Local1", Local1.Name); }
public void While() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Utilities.Reflection.Emit.Commands.While While = Method.While(Local1, Utilities.Reflection.Emit.Enums.Comparison.Equal, Local2); Method.EndWhile(While); Assert.NotNull(While); }
public void CreateMethod() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); Utilities.Reflection.Emit.Interfaces.IMethodBuilder TestMethod = TestType.CreateMethod("TestMethod"); Assert.NotNull(TestMethod); Assert.Equal("TestMethod", TestMethod.Name); Assert.Equal(typeof(void), TestMethod.ReturnType); Assert.NotNull(TestMethod.Generator); Assert.NotNull(TestMethod.This); Assert.Equal(1, TestMethod.Parameters.Count); Assert.Equal(MethodAttributes.Public | MethodAttributes.Virtual, TestMethod.Attributes); }
public void TryCatch() { Utilities.Reflection.Emit.Assembly Assembly = new Utilities.Reflection.Emit.Assembly("TestAssembly"); Utilities.Reflection.Emit.TypeBuilder TestType = Assembly.CreateType("TestType"); IMethodBuilder Method = TestType.CreateMethod("TestMethod"); VariableBase Local1 = Method.CreateLocal("Local1", typeof(int)); VariableBase Local2 = Method.CreateLocal("Local2", typeof(int)); Utilities.Reflection.Emit.Commands.Try Try = Method.Try(); Utilities.Reflection.Emit.Commands.Catch Catch = Method.Catch(typeof(Exception)); Method.EndTry(); Assert.NotNull(Try); Assert.NotNull(Catch); }