Wrong decompile for 'is' operator in conditional statements.

2 posts, 0 answers
  1. Chris
    Chris avatar
    12 posts
    Member since:
    May 2011

    Posted 01 Apr 2012 Link to this post

    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
    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

    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.2Best Regards,Chris
  2. Nikolay G Rusev
    Admin
    Nikolay G Rusev avatar
    44 posts

    Posted 05 Apr 2012 Link to this post

    Hi Chris,

     Thank you for the feedback. We know about this issue and we have it logged, so it will definitely be fixed in some of the forthcoming releases.
    Meanwhile, don't hesitate to write us about any other problems you encounter with JustDecompile.

    Kind regards,
    Nikolay G Rusev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top