We ran into a major issue with Obfuscator, found a fix and want to
contribute the changes to the project:
When a virtual method of a class is skipped from being renamed, the
overriding or overridden methods in the related classes must also be
excluded from name changes.
When this is not done you typically get a "method has no
implementation" error when running your program.
Here is an example to reproduce the problem. When the method in
Interace1 is filtered from renaming, the obfuscated version of the
program throws an error:
using System;
using System.Collections.Generic;
using System.Text;
namespace test
{
public interface Interface1
{
void Method1();
}
public class Class1 : Interface1
{
public void Method1() { Console.WriteLine("Method1"); }
public void Method2() { Console.WriteLine("Method2"); }
}
class Program
{
static void Main(string[] args)
{
Class1 bla = new Class1();
bla.Method1();
}
}
}
Besides this fix we did some minor changes to help us in our project.
Maybe these are also of interest:
All Skip???? elements in the configuration file now accept simple
wildcards (*,?) or full regular expressions for filtering types and
member names. Regular expressions are identified by a starting ^
character which counts to the regular expression. I don't think, that
there are type or member names including the characters ^,* or ? so
this should give no compatibility issues. The rx attribute gets
somewhat obsolete by this feature of course.
In the mapping file the scope (Assembly) of a type is also put in
brackets instead of the comma separation. This should increase human
readability.
I uploaded the patch for these changes to this group. It was created
from Obfuscar version 1.1.0 (SVN Revision 29). It includes the fix for
the inheritance problem (only Obfuscator.cs) and the other two changes.
I particularly like the changes with the brackets...much better, imo.
The wildcard stuff is good too, I like it (I cut out the extra
substring allocation, though). I ran into some trouble while testing
your fix for the virtual method skipping...it worked when skipping
Interface1.Method1, but not Class1.Method1 (I fixed it by making the
virtual naming / renaming into a real two-pass operation...all virtual
method names now get assigned before renaming occurs, so if a group is
given a name but later needs to get skipped, it can be unnamed).
Committed them in r30.
As the patch is committed to SVN now, I tried to remove it from the
files section. But I did not find a button to do this. Maybe this is
only allowed to the group owner. Otherwise it will have to stay there
forever ;)
Also, I dropped the file from the group for you ;)