Obfuscation Attributes Reference
For a complete guide to Obfuscation Attributes see the Attributes page.
Referencing the Attributes
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.
Through the .NET Base Class Libraries
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 (released 2017)
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
.
Through a Dotfuscator Reference Assembly
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 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
.
Attribute Listing
This section lists the attributes that Dotfuscator recognizes to configure its obfuscation behavior.
ObfuscationAttribute
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 ofrenaming
.default
: an alias ofrenaming
.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.Config-specific Feature Map Strings: Alias of the feature(s) specified in the config.
Exclude: If
true
, Dotfuscator will exclude the annotated code element from the specified feature. Iffalse
, the code element will be included in the specified feature.Defaults to
true
.Use
true
for specifyingrenaming
andcontrolflow
exclusions.Use
false
for specifyingstringencryption
inclusions and Removaltrigger
s andconditionalinclude
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.
- Defaults to
true
.
- Defaults to
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.
ObfuscateAssemblyAttribute
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. Iffalse
, Dotfuscator will consider the assembly to be a library assembly, and therefore preserve the public contract of the assembly.- Defaults to
false
.
- Defaults to
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.