Dotfuscator 5 CE - renaming exclusion by signature

772 Views Asked by At

I'm running dotfuscator 5 from the command line using a config file. This works ok, more or less, except for one new requirement that's just come about.

I have a class with a small number (less than half a dozen) void methods that need to be excluded from renaming (for a roundabout system of calling reflected methods by name; don't ask...)

Their signature is (names changed to protect the innocent) void Method(System.Xml.XmlNode xnode, ref System.String str).

My question is two-fold:

  • How do I express a ref parameter in dotfuscator configuration syntax?
  • Why doesn't using the signature of the method quoted in the Map file work?

The map file contains the element <signature>void(System.Xml.XmlNode, string&amp;)</signature> when these methods are renamed. I would expect therefore to be able to specify in the config file:

<type name="ParentClass" excludetype="false">
<method signature="void(System.Xml.XmlNode, string&amp;)"/>
</type>

This doesn't work. The output from the command line utility claims that the config file is invalid.

If I include the syntax name=".*" regex="true", all the methods in the type are excluded. I don't want that. I understand why this is - the rules are ORed together - but the utility forces me to use options I don't want by rejecting config files that specify my actual requirements.

What gives?

I feel - because I am beginning to get annoyed with this - that I should point out that I have found the Dotfuscator documentation to be....not very good.

1

There are 1 best solutions below

5
On

The config file is invalid because the method node has no "name".

If you're just trying to exclude one particular method, you can use the UI to actually click the checkbox next to that method in the Renaming -> Excludes treeview on the left, which will generate the correct XML for you. If you decide to go this route, delete your existing <type> node first.

If you want it to match any method in ParentClass with that signature (even if there's only one), the xml should be (substitute in the correct value for <Namespace>):

 <type name="<Namespace>.ParentClass" excludetype="false">
    <method name=".*" regex="true" signature="void(System.Xml.XmlNode, string&amp;)"/>
 </type>

With the rule created, you can use the UI to navigate to the Rename -> Exclude tab, right click the method node in the Custom Rules treeview on the right and click Preview. It should highlight the method you're looking for. Here's a screenshot of what it should look like in the UI when Preview is clicked: http://files.preemptive.com/Support/CustomRuleRefParam.png