예제 #1
0
 public void Emit_Ldloc_0_ReturnsValue()
 {
     var generator = new ILGenerator();
     generator.DeclareLocal(typeof(int));
     generator.Emit(OpCodes.Ldarg, 0);
     generator.Emit(OpCodes.Stloc_0);
     generator.Emit(OpCodes.Ldloc_0);
     var result = (int)generator.ExecuteUsingOneArgument(42);
     Assert.AreEqual(42, result);
 }
예제 #2
0
        public void Emit_Ldloc_0_ReturnsValue()
        {
            var generator = new ILGenerator();

            generator.DeclareLocal(typeof(int));
            generator.Emit(OpCodes.Ldarg, 0);
            generator.Emit(OpCodes.Stloc_0);
            generator.Emit(OpCodes.Ldloc_0);
            var result = (int)generator.ExecuteUsingOneArgument(42);

            Assert.AreEqual(42, result);
        }
예제 #3
0
 public void Emit_Ldarg_ReturnsArgument()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg, 0);
     var result = (int)generator.ExecuteUsingOneArgument(42);
     Assert.AreEqual(42, result);
 }
예제 #4
0
        public void Emit_Nop_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Nop);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
예제 #5
0
        public void Emit_IntWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg_0, 42);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
예제 #6
0
        public void Emit_MethodInfoWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg, (MethodInfo)null);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
예제 #7
0
        public void Emit_Byte_ReturnsByte()
        {
            var generator = new ILGenerator();
            generator.Emit(OpCodes.Ldc_I4_S, (byte)42);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });
            Assert.AreEqual(42, result);

        }
예제 #8
0
        public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException()
        {
            var generator = new ILGenerator();
            var local     = generator.DeclareLocal(typeof(int));

            generator.Emit(OpCodes.Ldarg, local);
            generator.ExecuteUsingOneArgument(new object[] { });
        }
예제 #9
0
        public void Emit_Ldarg_ReturnsArgument()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldarg, 0);
            var result = (int)generator.ExecuteUsingOneArgument(42);

            Assert.AreEqual(42, result);
        }
예제 #10
0
        public void Emit_Byte_ReturnsByte()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldc_I4_S, (byte)42);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });

            Assert.AreEqual(42, result);
        }
예제 #11
0
        public void Emit_Ldc_I4_8_ReturnsValue()
        {
            var generator = new ILGenerator();

            generator.Emit(OpCodes.Ldc_I4_8);
            var result = (int)generator.ExecuteUsingOneArgument(new object[] { });

            Assert.AreEqual(8, result);
        }
예제 #12
0
 public void Emit_Nop_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Nop);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
예제 #13
0
 public void Emit_Ldc_I4_8_ReturnsValue()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldc_I4_8);
     var result = (int)generator.ExecuteUsingOneArgument(new object[] { });
     Assert.AreEqual(8, result);
 }
예제 #14
0
 public void Emit_IntWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg_0, 42);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
예제 #15
0
 public void Emit_LocalBuilderWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     var local = generator.DeclareLocal(typeof(int));
     generator.Emit(OpCodes.Ldarg, local);
     generator.ExecuteUsingOneArgument(new object[] { });
 }
예제 #16
0
 public void Emit_MethodInfoWithInvalidOpCode_ThrowsException()
 {
     var generator = new ILGenerator();
     generator.Emit(OpCodes.Ldarg, (MethodInfo)null);
     generator.ExecuteUsingOneArgument(new object[] { });
 }