Getting Started
Understanding Protection
Understanding Obfuscation
Understanding Checks
Understanding Instrumentation
Using the GUI
References
When processing an input assembly, Dotfuscator recognizes a number of attributes that are used in Declarative Obfuscation. By using these attributes on your source code, you can configure many protection features inline with your application code. This page details these attributes.
Note that you can also configure these same protection features using the Dotfuscator user interface. For information on when you might want to configure via the user interface and when you might want to use attributes, see the When to Use Attributes section.
You can reference the obfuscation attributes either through the .NET Base Class Libraries or through a Dotfuscator Reference Assembly. The namespace of the attributes vary depending on which reference you use, but otherwise the attributes are identical.
The obfuscation attributes are defined in both of the following .NET Base Class Libraries:
mscorlib.dll
for the original .NET Framework, as of version 2.0 (released in 2005)
netstandard.dll
for .NET Standard, as of version 2.0 (release forthcoming)
Most .NET projects reference one of these by default, so you usually do not need to add a new reference to your project.
The namespace of these attributes is System.Reflection
.
If you are using an older framework or platform that does not have access to the obfuscation attributes in System.Reflection
, Dotfuscator ships with an alternative assembly that can be referenced instead.
The assembly is named PreEmptive.ObfuscationAttributes.dll
and is located in the same directory where Dotfuscator is installed.
The easiest way to find the path to this assembly is to:
Open a Dotfuscator command prompt.
Run the command where PreEmptive.ObfuscationAttributes.dll
and copy the result.
You can then add a reference to this assembly to your project. Note that the assembly has no dependencies besides the framework itself, so it can be copied to a different location if desired.
The namespace of the attributes defined in this alternative assembly is PreEmptive.Dotfuscator.ObfuscationAttributes
.
This section lists the attributes that Dotfuscator recognizes to configure its obfuscation behavior.
Specifies how an assembly or code element should be obfuscated. Each use of the attribute specifies a protection transform and whether the annotated element should be excluded or included by that feature when Dotfuscator processes the compiled assembly.
Also see the full ObfuscationAttribute
documentation on Microsoft Docs.
Namespace: System.Reflection
or PreEmptive.Dotfuscator.ObfuscationAttributes
(depending on which DLL you referenced)
Applies to: Assembly, type, or member
Multiple allowed on one code element: Yes
Requirements:
For Dotfuscator to recognize uses of this attribute and obfuscate accordingly, the Honor Obfuscation Attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
For Dotfuscator to remove uses of this attribute from the protected assembly, at least one of the following must be true:
The Strip Obfuscation Attributes input option for the input assembly that contains this attribute must be enabled, which it is by default; or,
The StripAfterObfuscation property of the attribute must be true
, which it is by default.
Properties:
Feature: The name of the obfuscation transform to specify.
Defaults to all
, which is an alias of renaming
.
default
: an alias of renaming
.
renaming
: Use to specify Renaming exclusions.
controlflow
: Use to specify Control Flow exclusions.
stringencryption
: Use to specify String Encryption inclusions.
trigger
: Use to specify Removal Entry Points.
conditionalinclude
: Use to specify conditional Removal inclusions.
Project-specific Feature Map Strings: Alias of the feature(s) specified in the project.
Exclude: If true
, Dotfuscator will exclude the annotated code element from the specified feature. If false
, the code element will be included in the specified feature.
Defaults to true
.
Use true
for specifying renaming
and controlflow
exclusions.
Use false
for specifying stringencryption
inclusions and Removal trigger
s and conditionalinclude
s.
Dotfuscator supports one value of the Exclude property for any given transform. Dotfuscator will ignore rules that have unsupported Exclude values. Therefore, the feature-specific values as specified above should be used.
ApplyToMembers: If annotating a type, indicates whether the attribute's obfuscation feature should be applied to all of the type's members and nested types.
true
.StripAfterObfuscation: If true
, Dotfuscator will remove this attribute usage from the output assembly.
Defaults to true
.
Dotfuscator will always strip all attribute usages from an input assembly, regardless of this property, when Strip Obfuscation Attributes setting input option is enabled, which it is by default.
Specifies whether or not an assembly is considered a library assembly or not. Use of this attribute overrides the Library Mode input option.
Also see the full ObfuscateAssemblyAttribute
documentation on Microsoft Docs.
Namespace: System.Reflection
or PreEmptive.Dotfuscator.ObfuscationAttributes
(depending on which DLL you referenced)
Applies to: Assembly
Multiple allowed on one code element: No
Requirements:
For Dotfuscator to recognize uses of this attribute and obfuscate accordingly, the Honor Obfuscation Attributes input option for the input assembly that contains this attribute must be enabled, which it is by default.
For Dotfuscator to remove uses of this attribute from the protected assembly, at least one of the following must be true:
The Strip Obfuscation Attributes input option for the input assembly that contains this attribute must be enabled, which it is by default; or,
The StripAfterObfuscation property of the attribute must be true
, which it is by default.
Properties:
AssemblyIsPrivate: If true
, Dotfuscator will consider the assembly to be a non-library assembly, and therefore obfuscate more aggressively. If false
, Dotfuscator will consider the assembly to be a library assembly, and therefore preserve the public contract of the assembly.
false
.StripAfterObfuscation: If true
, Dotfuscator will remove this attribute usage from the output assembly.
Defaults to true
.
Dotfuscator will always strip all attribute usages from an input assembly, regardless of this property, when Strip Obfuscation Attributes setting input option is enabled, which it is by default.
Dotfuscator Version 4.33.0.6680. Copyright © 2017 PreEmptive Solutions, LLC