Search code examples
obfuscationdotfuscator

How to only obfuscate method name with Dotfuscator?


Due to some reflection actions, I have the need to exclude some methods from Dotfuscator ce obfuscation:

[Obfuscation(Exclude = true)]
internal MyMethod (String input1)
{
   string member1 = "hello"
   string member2 = "world"
   [...]
}

The Obfuscation attribute does this job, but now also the complete content of the method is not obfuscated any more. How I can achieve that the name MyMethod will not be obfuscated, but the members member1, member2 etc are still obfuscated?


Solution

  • (Note: I work on the Dotfuscator team and am answering in that capacity.)

    The names of local variables (what you refer to as "members") are stored with other debugging information in the Program Database (.pdb) file, not the assembly (.dll or .exe file). Dotfuscator renames code items in the assembly, but doesn't rename local variables in the .pdb.

    We assume that customers concerned about reverse engineering aren't going to ship the .pdb, as it contains line number and source file information, which would make the reverse engineering process easy, even with an obfuscated assembly.

    However, Dotfuscator can still produce .pdb files for internal testing and debugging. If you'd like Dotfuscator Community (formerly known as Dotfuscator CE) to stop doing so, open your config file in Dotfuscator's user interface, go to Settings -> General and uncheck Emit debugging symbols.