Comments
3 comments
-
Thanks for reporting this - I've logged it in our bug tracking database.
-
Hi,
Here is another more simple sample to re-produce the case:
0 L_0000: ldstr "C:\Program Files (x86)"
1 L_0005: stloc.0
2 L_0006: ldloc.0
3 L_0007: dup
4 L_0008: brtrue 7 -> stloc.1
5 L_000d: pop
6 L_000e: ldstr "C:\Program Files (x86)"
7 L_0013: stloc.1
8 L_0014: ldloc.1
9 L_0015: ret
Current output:
{
// This item is obfuscated and can not be translated.
string str = @C:\Program Files (x86);
if (str != null)
{
goto Label_0013;
}
return @C:\Program Files (x86);
}
It should be:
{
string str = @C:\Program Files (x86);
if (str != null)
{
return str;
}
return @C:\Program Files (x86);
}
Hope it helps.
Regards
Wicky -
Hi,
For second sample, more correct:
{
string str = @C:\Program Files (x86);
return str ?? @C:\Program Files (x86);
}
IL of above C#:
0 L_0000: ldstr "C:\Program Files (x86)"
1 L_0005: stloc.0
2 L_0006: ldloc.0
3 L_0007: dup
4 L_0008: brtrue.s 7 -> ret
5 L_000a: pop
6 L_000b: ldstr "C:\Program Files (x86)"
7 L_0010: ret
you can see additional stloc.1 and ldloc.1 make Reflector wrong.
Regards
Wicky
Add comment
Please sign in to leave a comment.
Please take a look on these IL:
0 L_0000: ldarg.1
1 L_0001: dup
2 L_0002: brtrue 5 -> starg.s p0
3 L_0007: pop
4 L_0008: call System.String System.Environment::get_CurrentDirectory()
5 L_000d: starg.s p0
6 L_000f: ldarg.1
7 L_0010: ldarg.0
8 L_0011: call System.String NS001.c00012d::get_p0000c5()
9 L_0016: call System.String System.IO.Path::Combine(System.String,System.String)
10 L_001b: stloc.0
11 L_001c: ldloc.0
12 L_001d: ldarg.2
13 L_001e: brtrue 16 -> ldc.i4.2
14 L_0023: ldc.i4.1
15 L_0024: br 17 -> newobj System.Void System.IO.FileStream::.ctor(System.String,System.IO.FileMode)
16 L_0029: ldc.i4.2
17 L_002a: newobj System.Void System.IO.FileStream::.ctor(System.String,System.IO.FileMode)
18 L_002f: stloc.1
19 L_0030: ldarg.0
20 L_0031: call NS003.c000113 NS001.c00012d::get_p0000a6()
21 L_0036: ldloc.1
22 L_0037: callvirt System.Void NS003.c000113::m000323(System.IO.Stream)
23 L_003c: ldloc.1
24 L_003d: callvirt System.Void System.IO.Stream::Flush()
25 L_0042: leave 32 -> ret
26 L_0047: ldloc.1
27 L_0048: brfalse 30 -> endfinally
28 L_004d: ldloc.1
29 L_004e: callvirt System.Void System.IDisposable::Dispose()
30 L_0053: endfinally
31 L_0054: nop
32 L_0055: ret
.try0 19 to 26 Finally handler 26 to 31
The decompiled C# is (both 6.5 and 7 beta 1):
public void m00034c(string p0, bool p1)
{
// This item is obfuscated and can not be translated.
if (p0 != null)
{
goto Label_000D;
}
p0 = Environment.CurrentDirectory;
using (FileStream stream = new FileStream(Path.Combine(p0, this.p0000c5), p1 ? FileMode.Create : FileMode.CreateNew))
{
this.p0000a6.m000323(stream);
stream.Flush();
}
}
I think the correct one should be:
public void m00034c(string p0, bool p1)
{
if (p0 == null)
{
p0 = Environment.CurrentDirectory;
}
using (FileStream stream = new FileStream(Path.Combine(p0, this.p0000c5), p1 ? FileMode.Create : FileMode.CreateNew))
{
this.p0000a6.m000323(stream);
stream.Flush();
}
}
Regards
Wicky