A pair of box !T/unbox.any Int32 is decompiled into (int)variable
That obviously will not compile again, it would produce the compiler error "Cannot convert type 'T' to 'int'
". It should be (int)(object)variable
Similarly box Int32/unbox.any !T is decompiled into (T)something
, and that won't compile either and should be (T)(object)something
Worse than both of those, code like this: (you guys should add the MSIL language to the format code block, btw)
Is decompiled into (T)(int)a + (int)b
which as you can see doesn't even get operator precedence right. At the very least it should be
(T)((int)a + (int)b)
(that's what ILspy makes of it - and it's also wrong) but it should actually be (T)(object)((int)(object)a + (int)(object)b)
otherwise it will not compile.