Use the Renaming Editor to configure how Dotfuscator renames identifiers in your application.
The Renaming Editor allows you to:
- Configure renaming behavior.
- Select a renaming scheme.
- Configure XML serialization compatibility.
- Manage renaming exclusions.
- Apply built-in exclusion rules.
To open the Renaming Editor, go to the Rename tab in the Config Editor. The Renaming editor displays three configuration tabs:
- Exclude: Graphically set specific exclusions and custom exclusion rules
- Built-in Rules: Enable built-in rules to perform common renaming exclusions.
- Options: Configure other options related to renaming
Exclude Tab
The Exclude tab in the Rename Editor allows you to exclude specific code elements from renaming.
Exclusions can be applied to:
- Assemblies
- Namespaces
- Types
- Methods
- Fields
- Properties
- Events
Use exclusions when application functionality depends on specific names remaining unchanged.
There are two sections in the Exclude tab: the application tree view and the rules section.
Application tree view
You may exclude specific items from renaming by browsing the tree view of your application and checking the items you want to exclude.
The application tree view shades all items selected for exclusion. You can preview the cumulative effects of all rules, or preview a specific rule that you select.
Rules section
Create rules to exclude groups of code elements that share common characteristics. These rules are applied in addition to rules implied by options such as Library.
Rules are logically OR-ed together.
Regular Expressions (REs) may be used to select namespaces, types, methods or fields. The optional regex attribute is used for this purpose. The default value of regex is false. If regex is true then the value of the name attribute is interpreted as a regular expression; if it is false, the name is interpreted literally. This is important since regular expressions assign special meaning to certain characters, such as the period.
Some examples of simple regular expressions:
| Expression | Matches |
|---|---|
.* |
Anything |
MyLibrar. |
MyLibrary, MyLibrari, etc. |
My[\.]Test[\.]I.* |
My.Test.Int1, My.Test.Internal, etc. |
Get.* |
GetInt, GetValue, etc. |
Get* |
Ge, Get, Gett, Gettt, etc. |
For more information, see Identify Renaming Exclusions and The Rules Editor.
Built-In Rules Tab
The Built-In Rules tab in the Rename Editor provides access to predefined exclusion rules. These rules are standard exclusions that apply to specific application types or technologies. Each rule has a description that displays on the form when the rule is selected. You can enable a built-in rule in your config by checking its checkbox.
The rule definitions are found in the XML file with a name beginning with dotfuscatorReferenceRule in your installation location's Common subdirectory.
Options Tab
The Options tab in the Rename Editor contains settings that control how Dotfuscator renames identifiers.
| Option | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Use Enhanced Overload Induction | Allows Dotfuscator to assign the same name to additional methods and fields when the .NET runtime can still distinguish them based on their signatures, return types, or field types. This can increase the effectiveness of renaming by reducing the number of distinct names in the protected assembly. | ||||||||||||||||||||||||
| Include serializable types | Applies Enhanced Overload Induction to serializable types. By default, serializable types are excluded from Enhanced Overload Induction to help avoid serialization compatibility issues. | ||||||||||||||||||||||||
| Keep Namespace |
Preserves namespace names during renaming. For example, consider the following type: MyCompany.Security.CustomerManager After renaming with Keep Namespace enabled: MyCompany.Security.a The namespace remains unchanged, but the type name is renamed. When Keep Namespace is disabled: a.b.c Both the namespace and the type name may be renamed. Use this option when namespace names must remain unchanged for compatibility or organizational reasons. |
||||||||||||||||||||||||
| Keep Hierarchy |
Preserves type hierarchy information during renaming. For example, consider the following inheritance hierarchy: Animal ├─ Mammal │ └─ Dog Without Keep Hierarchy, the renamed types might appear as: a b c With Keep Hierarchy enabled, the renamed identifiers preserve information about their relationship: a a_b a_b_c Preserving hierarchy information can simplify debugging and analysis of protected assemblies while still providing obfuscation. |
||||||||||||||||||||||||
| Keep Managed Resource names | Dotfuscator automatically renames managed resources that are associated with renamed classes so that they load correctly at runtime. You should select Keep Managed Resource names if your application loads managed resources by constructing resource names programmatically. | ||||||||||||||||||||||||
| Renaming Scheme |
Dotfuscator allows you to choose from several predefined algorithms for generating obfuscated identifier names:
|
||||||||||||||||||||||||
| Randomize name assignment | Assigns replacement names in a non-sequential order, making relationships between renamed identifiers more difficult to infer. | ||||||||||||||||||||||||
| Compatibility with XML Serializer | Applies additional renaming rules to help maintain compatibility with XML serialization. | ||||||||||||||||||||||||
| Type Name Prefix |
Enforces unique top-level type names across assemblies when you can't run all assemblies through Dotfuscator in the same session. Select the Type Name Prefix checkbox to apply a prefix to every obfuscated top-level type name. Enter your own prefix in the text box, or leave it blank to have Dotfuscator generate one based on the module name. Example:
Note: A prefix ending in a period (e.g., `mynamespace.`) places obfuscated types in a custom common namespace, useful for namespace induction. |
||||||||||||||||||||||||
| Apply to members | Apply the type name prefix to members as well. |