dnSpyEx / dnSpy

Unofficial revival of the well known .NET debugger and assembly editor, dnSpy
GNU General Public License v3.0
6.83k stars 452 forks source link

Decompiled code format problem #95

Closed DATA-GaMi closed 2 years ago

DATA-GaMi commented 2 years ago

Before clicking Submit new issue, try the latest build

The style of the code generated after decompilation is very strange, how to format the code?

CodeFormat

GazziFX commented 2 years ago

I've seen this before, this is because inspecting assembly was compiled in the Debug profile

ElektroKill commented 2 years ago

The flag local variables usually occur when decompiling debug builds as pointed out by @GazziFX. However, this file might be obfuscated with some sort of protection that injects additional local variables. Debug builds would usually only have one "level" of flag variable like shown in the example below:

bool flag1 = Console.ReadLine() == "test";
if (flag1) {
}

Your file however features something like this which I have not seen in debug builds and is probably an indication that this file was in some way obfuscated:

bool flag1 = Console.ReadLine() == "test";
bool flag2 = flag1;
if (flag2) {
}

The ILSpy 2.4 decompiler engine used by dnSpyEx does not currently do a good job at inlining unnecessary variables and hence this rather messy output is produced.

As for the big amount of if-else conditions, this is very likely just user code being that messy.

DATA-GaMi commented 2 years ago

okay.I'll try to change the decomplier engine version.