Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

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

$
0
0

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

 


Viewing all articles
Browse latest Browse all 94857

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>