This is a migrated thread and some comments may be shown as answers.

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

6 Answers 41 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Blamara
Top achievements
Rank 1
Blamara asked on 05 Apr 2015, 11:51 PM

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

 

6 Answers, 1 is accepted

Sort by
0
Blamara
Top achievements
Rank 1
answered on 05 Apr 2015, 11:54 PM
sorry was little out of topic, in last comments, and can't edit !?
bug is in if line bold text "values[2] as bool
0
Accepted
Alexander
Telerik team
answered on 07 Apr 2015, 02:44 PM
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
0
Blamara
Top achievements
Rank 1
answered on 07 Apr 2015, 03:20 PM

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

0
Alexander
Telerik team
answered on 07 Apr 2015, 03:46 PM
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
0
Blamara
Top achievements
Rank 1
answered on 07 Apr 2015, 04:54 PM

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

 

0
Alexander
Telerik team
answered on 07 Apr 2015, 05:09 PM
Hi Blamara,

My email is Alexander.Dimitrov at telerik.com.

Regards,
Alexander
Telerik
Tags
General Discussions
Asked by
Blamara
Top achievements
Rank 1
Answers by
Blamara
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or