public void TokenInstructions() { var builder = new BlobBuilder(); var il = new InstructionEncoder(builder); Assert.Equal(0, il.Offset); il.Token(MetadataTokens.TypeDefinitionHandle(0x123456)); Assert.Equal(4, il.Offset); il.Token(0x7F7E7D7C); Assert.Equal(8, il.Offset); il.LoadString(MetadataTokens.UserStringHandle(0x010203)); Assert.Equal(13, il.Offset); il.Call(MetadataTokens.MethodDefinitionHandle(0xA0A1A2)); Assert.Equal(18, il.Offset); il.Call(MetadataTokens.MethodSpecificationHandle(0xB0B1B2)); Assert.Equal(23, il.Offset); il.Call(MetadataTokens.MemberReferenceHandle(0xC0C1C2)); Assert.Equal(28, il.Offset); il.Call((EntityHandle)MetadataTokens.MethodDefinitionHandle(0xD0D1D2)); Assert.Equal(33, il.Offset); il.Call((EntityHandle)MetadataTokens.MethodSpecificationHandle(0xE0E1E2)); Assert.Equal(38, il.Offset); il.Call((EntityHandle)MetadataTokens.MemberReferenceHandle(0xF0F1F2)); Assert.Equal(43, il.Offset); il.CallIndirect(MetadataTokens.StandaloneSignatureHandle(0x001122)); Assert.Equal(48, il.Offset); AssertEx.Equal(new byte[] { 0x56, 0x34, 0x12, 0x02, 0x7C, 0x7D, 0x7E, 0x7F, (byte)ILOpCode.Ldstr, 0x03, 0x02, 0x01, 0x70, (byte)ILOpCode.Call, 0xA2, 0xA1, 0xA0, 0x06, (byte)ILOpCode.Call, 0xB2, 0xB1, 0xB0, 0x2B, (byte)ILOpCode.Call, 0xC2, 0xC1, 0xC0, 0x0A, (byte)ILOpCode.Call, 0xD2, 0xD1, 0xD0, 0x06, (byte)ILOpCode.Call, 0xE2, 0xE1, 0xE0, 0x2B, (byte)ILOpCode.Call, 0xF2, 0xF1, 0xF0, 0x0A, (byte)ILOpCode.Calli, 0x22, 0x11, 0x00, 0x11 }, builder.ToArray()); }