Bugs of field order in Reflector
CreateAndInject
Posts: 5 New member
class Demo
{
public static int bbb = 5;
public static int aaa = bbb + 2;
}
aaa=7,bbb=5
decompiled by Reflector:
internal class Demo
{
// Fields
public static int aaa = (bbb + 2);
public static int bbb = 5;
}
aaa=2,bbb=5
{
public static int bbb = 5;
public static int aaa = bbb + 2;
}
aaa=7,bbb=5
decompiled by Reflector:
internal class Demo
{
// Fields
public static int aaa = (bbb + 2);
public static int bbb = 5;
}
aaa=2,bbb=5
Tagged:
Comments
When I write this in Visual Studio:
class Demo
{
public static int bbb = 5;
public static int aaa = bbb + 2;
}
Then put the output to Reflector. it will like this:
internal class Demo
{
// Fields
public static int aaa = (bbb + 2);
public static int bbb = 5;
}
So, when I Export Assembly Source Code, there are mistakes!
Reflector should keep the order, or else there are different values!!!
in my program: aaa=7,bbb=5
but in Reflector code: aaa=2,bbb=5
"The IL is in the static constructor (.cctor method). That is where the static variables are initialised."
So?
In my original application, IL will like:
ldc.i4.5
stsfld bbb
ldsfld bbb ===>this time bbb=5
ldc.i4.2
add
stsfld aaa
But Reflector change the filed order, so if I compile the decompiled source , IL will like:
ldsfld bbb ==> this time bbb=0
ldc.i4.2
add
stsfld aaa
ldc.i4.5
stsfld bbb
Can't you find the difference?
So, there is a bug!!!
For instance, I had these columns:
Id | Name | Birth date
1234 | John Doe | 31/12/1990
that were displayed like so:
Id | Name | Birth date
31/12/1990 | 1234 | John Doe
This is because Reflector transformed this code: into this one: ... causing the DataTables parser to get the and display the data in the wrong order.
The problem occurs here (for those who would came across this post):