Bug in If (obj is bool) decompiled as if (obj as bool)

7 posts, 1 answers
  1. Blamara
    Blamara avatar
    10 posts
    Member since:
    Dec 2014

    Posted 05 Apr 2015 Link to this post

    if we use is keyword to detect if object is of type in this case bool.
    Code is decompiled incorrectly with as keyword.

    Original Code:

      public object Convert(object[] values)
      {
        string str = "";
        bool IsBool = values[2] is bool; // if IsBool not in use (see commented line) decompiled : object obj = values[2];
        if (values != null
            && (int)values.Length == 3
            && (values[2] is bool)
            && (bool)values[2]
            && values[0] is Color
            && values[1] is Color)
        {
          Color color = (Color)values[0];
          Color color1 = (Color)values[1];       
        }
        // object oo = (object)IsBool; // any use
        return str;
      }
    }
    Decompiler Code:

    public object Convert(object[] values)
    {
        string str = "";
        object obj = values[2];     
        if (values != null && (int)values.Length == 3 && values[2] as bool && (bool)values[2] && values[0] is Color && values[1] is Color)
        {
            Color color = (Color)values[0];
            Color color1 = (Color)values[1];
        }
        return str;
    }

    make notice of 
    object obj = values[2];

    if we in original code used anywhere IsBool variable it would decompile properly is keyword in above line:
    bool flag = values[2] is bool;

    but still strange that no use of object decompiles as object instead of bool (I would still say this is bug, but we can live with it).

     

  2. Blamara
    Blamara avatar
    10 posts
    Member since:
    Dec 2014

    Posted 05 Apr 2015 in reply to Blamara Link to this post

    sorry was little out of topic, in last comments, and can't edit !?
    bug is in if line bold text "values[2] as bool
  3. DevCraft banner
  4. Answer
    Alexander
    Admin
    Alexander avatar
    80 posts

    Posted 07 Apr 2015 Link to this post

    Hello Blamara,

    Thank you for letting us know about this problem. I really appreciate it.

    Unfortunately, I can't reproduce exactly the problem you have. Would you like to zip the whole project, containing the code that causes the bug, and sent it over to me at Alexander.Dimitrov at telerik.com? In this case this is the only way to reproduce the problem 100% accurately.

    You help is very appreciated.

    Regards,
    Alexander
    Telerik
  5. Blamara
    Blamara avatar
    10 posts
    Member since:
    Dec 2014

    Posted 07 Apr 2015 in reply to Alexander Link to this post

    Hi Aleksander,

    I have project where I was evaluating Telerik JustDecompile, DotPeek, and ILSpy decompile techniques against code I wrote.

    I was mostly focused to debug what Telerik Decompiler can't do, but the other two can fix.
    I've tried to replicate the code that produced some of major unwanted behaviors I have detected in original project I was decompiling.
    Some of them I haven't yet succeeded to replicate, but most of behaviors are well documented inside comments in separate classes.

    only question now is do you want me to attach project here or send via email ?

    //SA

  6. Alexander
    Admin
    Alexander avatar
    80 posts

    Posted 07 Apr 2015 Link to this post

    Hello Blamara,

    Thank you for your help so far.

    As you wish. You can attach it here or send it to my email. Whatever suits you best.

    Thank you in advance.

    Regards,
    Alexander
    Telerik
  7. Blamara
    Blamara avatar
    10 posts
    Member since:
    Dec 2014

    Posted 07 Apr 2015 in reply to Alexander Link to this post

    Problem with Forum it only allows extensions that are images
    "The selected file(s) cannot be attached because it may exceed the maximum attachment size (2 MB) or is from not allowed type (allowed: .jpg, .jpeg, .gif, .png)."

    file is only 18k zipped project files. no binaries, or obj files.
    will email when I find your email, or on support email addressing you.

    hope it finds you

     

  8. Alexander
    Admin
    Alexander avatar
    80 posts

    Posted 07 Apr 2015 Link to this post

    Hi Blamara,

    My email is Alexander.Dimitrov at telerik.com.

    Regards,
    Alexander
    Telerik
Back to Top
DevCraft banner