Hello,
Yesterday I've stumbled upon weird errors while instrumenting existing assembly: "Common Language Runtime detected an invalid program. while compiling method" After some digging I found out te problem was in an overflow of conditional IL operator: IL_00...: brtrue.s IL_ffffffc9 (actually there were a number of overflows not only with brtrue.s operator..) This happened when I inserted some instructions in the middle of method and therefore brtrue.s ' int8 size of offset was not enough any more, so now I have to create myself some checks and replace small conditional instructions in such cases, but that's not the story... During this investigation I've found a place in CodeWriter.cs that could be changed a bit: Line 215: from m_codeWriter.Write ((byte) (((Instruction) instr.Operand).Offset - to m_codeWriter.Write (checked((sbyte) (((Instruction) instr.Operand).Offset - Firstly - sbyte is actually INT8 which is ecpected as an operant of ".s" operators, and secondly - checked will actually throw exception in case of overflow. I know that "Cecil does absolutely no verification on what it emits.", but just in case... Best Regards. Sergiy -- View this message in context: http://www.nabble.com/byte-vs-sbyte-tp24768259p24768259.html Sent from the Mono - Cecil mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
