Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do method names get compiled into the EXE?

Do class, method and variable names get included in the MSIL after compiling a Windows App project into an EXE?

  • For obfuscation - less names, harder to reverse engineer.
  • And for performance - shorter names, faster access.

e.g. So if methods ARE called via name:

  • Keep names short, better performance for named-lookup.
  • Keep names cryptic, harder to decompile.
like image 905
Robin Rodricks Avatar asked Jan 05 '09 14:01

Robin Rodricks


3 Answers

Yes, they're in the IL - fire up Reflector and you'll see them. If they didn't end up in the IL, you couldn't build against them as libraries. (And yes, you can reference .exe files as if they were class libraries.)

However, this is all resolved once in JIT.

Keep names readable so that you'll be able to maintain the code in the future. The performance issue is unlikely to make any measurable difference, and if you want to obfuscate your code, don't do it at the source code level (where you're the one to read the code) - do it with a purpose-built obfuscator.

EDIT: As for what's included - why not just launch Reflector or ildasm and find out? From memory, you lose local variable names (which are in the pdb file if you build it) but that's about it. Private method names and private variable names are still there.

like image 117
Jon Skeet Avatar answered Oct 27 '22 20:10

Jon Skeet


Yes, they do. I do not think that there will be notable performance gain by using shorter names. There is no way that gain overcomes the loss of readability.

like image 3
Serhat Ozgel Avatar answered Oct 27 '22 19:10

Serhat Ozgel


Local variables are not included in MSIL. Fields, methods, classes etc are. Variables are index based.

like image 1
Michiel Avatar answered Oct 27 '22 18:10

Michiel