public void LoadArgumentAddress() { var builder = new BlobBuilder(); var il = new InstructionEncoder(builder); il.LoadArgumentAddress(0); il.LoadArgumentAddress(1); il.LoadArgumentAddress(2); il.LoadArgumentAddress(3); il.LoadArgumentAddress(4); il.LoadArgumentAddress(byte.MaxValue); il.LoadArgumentAddress(byte.MaxValue + 1); il.LoadArgumentAddress(int.MaxValue); AssertEx.Equal(new byte[] { (byte)ILOpCode.Ldarga_s, 0x00, (byte)ILOpCode.Ldarga_s, 0x01, (byte)ILOpCode.Ldarga_s, 0x02, (byte)ILOpCode.Ldarga_s, 0x03, (byte)ILOpCode.Ldarga_s, 0x04, (byte)ILOpCode.Ldarga_s, 0xFF, 0xFE, 0x0A, 0x00, 0x01, 0x00, 0x00, 0xFE, 0x0A, 0xFF, 0xFF, 0xFF, 0x7F }, builder.ToArray()); Assert.Throws <ArgumentOutOfRangeException>(() => il.LoadArgumentAddress(-1)); Assert.Throws <ArgumentOutOfRangeException>(() => il.LoadArgumentAddress(int.MinValue)); }
public void LoadArgumentAddress() { var builder = new BlobBuilder(); var il = new InstructionEncoder(builder); il.LoadArgumentAddress(0); il.LoadArgumentAddress(1); il.LoadArgumentAddress(2); il.LoadArgumentAddress(3); il.LoadArgumentAddress(4); il.LoadArgumentAddress(byte.MaxValue); il.LoadArgumentAddress(byte.MaxValue + 1); il.LoadArgumentAddress(int.MaxValue); AssertEx.Equal(new byte[] { (byte)ILOpCode.Ldarga_s, 0x00, (byte)ILOpCode.Ldarga_s, 0x01, (byte)ILOpCode.Ldarga_s, 0x02, (byte)ILOpCode.Ldarga_s, 0x03, (byte)ILOpCode.Ldarga_s, 0x04, (byte)ILOpCode.Ldarga_s, 0xFF, 0xFE, 0x0A, 0x00, 0x01, 0x00, 0x00, 0xFE, 0x0A, 0xFF, 0xFF, 0xFF, 0x7F }, builder.ToArray()); Assert.Throws<ArgumentOutOfRangeException>(() => il.LoadArgumentAddress(-1)); Assert.Throws<ArgumentOutOfRangeException>(() => il.LoadArgumentAddress(int.MinValue)); }