简体   繁体   中英

Is this line of code from ILSpy decompiler valid?

I decompiled a release assembly using ILSPy and I got code like below. When I open the decompiled project in VS 2013, I get an error for each of these statements.

using #j;//this line shows up as an error in VS2013
using System;

The error is:

Preprocessor directives must appear as the first non-whitespace character on a line

I get a similar error at following line also.

string path = #db.#ab(HttpUtility.UrlDecode(text));

Question : What is the meaning of using # and how can I correct these errors?

I have also noticed that some decompiled classes have names starting with # and so do some namespaces and method names. I have never used such a naming convention, so it's very confusing how 'ILSpy` came up with such code.

No, it's not valid C#. Chances are it's decompiled code that was obfuscated to start with, so using identifiers that are valid in IL but not in C#.

Typically, if you're decompiling obfuscated code, you're doing something against the wishes of the original authors of the code - so I'd suggest just not doing that. If you think you have a legitimate reason for getting the source code for something, ask the author.

Could you convert this into valid C#? Sure - just take every # -prefixed identifier, and map it (consistently) onto something else, eg

using hashj;
...

string path = hashdb.hashab(HttpUtility.UrlDecode(text));

... and eventually you'll run across a class called #db which you'd then rename to hashdb etc. But the point of the obfuscation is to make this a painful process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM