Hi,
I came across some problems decompiling methods with try/catch blocks, I have narrowed it down to the following.
JustDecompile Version: 2011.1.719.9
Original Code:
Decompiles to the following
Here we see two problems
1. The bool argument test is not being tested against false, but against 0
2. The try/catch which wrap the assignment to test (again the type of test was not considered here) is outside of the conditional block.
If this helps, here is the IL as it is from ILDASM, but I confirmed and JD's IL is correct
I came across some problems decompiling methods with try/catch blocks, I have narrowed it down to the following.
JustDecompile Version: 2011.1.719.9
Original Code:
public
bool
Test(
bool
test)
{
if
(test ==
true
)
{
try
{
test =
false
;
}
catch
{
}
}
return
test;
}
Decompiles to the following
public
bool
Test(
bool
test)
{
if
(test != 0)
{
test = 0;
}
try
{
}
catch
{
}
return
test;
}
Here we see two problems
1. The bool argument test is not being tested against false, but against 0
2. The try/catch which wrap the assignment to test (again the type of test was not considered here) is outside of the conditional block.
If this helps, here is the IL as it is from ILDASM, but I confirmed and JD's IL is correct
.method
public
hidebysig instance
bool
Test(
bool
test) cil managed
{
// Code size 30 (0x1e)
.maxstack 2
.locals init ([0]
bool
CS$1$0000,
[1]
bool
CS$4$0001)
IL_0000: nop
IL_0001: ldarg.1
IL_0002: ldc.i4.0
IL_0003: ceq
IL_0005: stloc.1
IL_0006: ldloc.1
IL_0007: brtrue.s IL_0018
IL_0009: nop
.
try
{
IL_000a: nop
IL_000b: ldc.i4.0
IL_000c: starg.s test
IL_000e: nop
IL_000f: leave.s IL_0016
}
// end .try
catch
[mscorlib]System.Object
{
IL_0011: pop
IL_0012: nop
IL_0013: nop
IL_0014: leave.s IL_0016
}
// end handler
IL_0016: nop
IL_0017: nop
IL_0018: ldarg.1
IL_0019: stloc.0
IL_001a: br.s IL_001c
IL_001c: ldloc.0
IL_001d: ret
}