public void Emit_Ldloc_1_ReturnsValue() { var generator = new ILGenerator(); generator.DeclareLocal(typeof(int)); generator.DeclareLocal(typeof(int)); generator.Emit(OpCodes.Ldarg, 0); generator.Emit(OpCodes.Stloc_1); generator.Emit(OpCodes.Ldloc_1); var result = (int)generator.ExecuteUsingOneArgument(42); Assert.AreEqual(42, result); }
public void Emit_Ldloc_1_ReturnsValue() { var generator = new ILGenerator(); generator.DeclareLocal(typeof(int)); generator.DeclareLocal(typeof(int)); generator.Emit(OpCodes.Ldarg, 0); generator.Emit(OpCodes.Stloc_1); generator.Emit(OpCodes.Ldloc_1); var result = (int)generator.ExecuteUsingOneArgument(42); Assert.AreEqual(42, result); }
public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException() { var generator = new ILGenerator(); var local = generator.DeclareLocal(typeof(int)); generator.Emit(OpCodes.Ldarg, local); generator.ExecuteUsingOneArgument(new object[] { }); }
public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException() { var generator = new ILGenerator(); var local = generator.DeclareLocal(typeof(int)); generator.Emit(OpCodes.Ldarg, local); generator.ExecuteUsingOneArgument(new object[] { }); }