Hi,
I have noticed a bug when decompiling code which used the 'is' operator in a conditional statement.
Here is a simple reproduction of the issue using an 'if' statement.
Given the following piece of code
Here are two tests for checking the type of the boxed value in 'obj'
bool test = obj is int;
decompiles correctly, however when using the same expression as part of a conditional statement as as follows,
if (obj is int)
{
...
}
This decompiles to the following
I have noticed a bug when decompiling code which used the 'is' operator in a conditional statement.
Here is a simple reproduction of the issue using an 'if' statement.
Given the following piece of code
object
obj = 100;
bool
test = obj
is
int
;
if
(obj
is
int
)
{
...
}
Here are two tests for checking the type of the boxed value in 'obj'
bool test = obj is int;
decompiles correctly, however when using the same expression as part of a conditional statement as as follows,
if (obj is int)
{
...
}
This decompiles to the following
Debug Build
bool flag = obj as int <= null;
if (!flag)
{
...
}
Release Build
if (obj as int != 0)
{
...
}
As you can see that when the 'is' operator is used in an expression of a conditional statement JustDecompile is decompiling to use the 'as' operator which is not valid when the type we are testing against is a value type.
JustDecompile Version : 2012.1.214.2
Best Regards,
Chris