Custom Attributes

Babel supports declarative obfuscation using the custom attributes System.Reflection.ObfuscationAttribute and System.Reflection.ObfuscateAssemblyAttribute provided by the .NET Framework and .NET.

The ObfuscateAssembly Attribute

The System.Reflection.ObfuscateAssemblyAttribute, is an assembly-level attribute that instructs Babel Obfuscator to use obfuscation rules reserved for private assemblies.

A private assembly is an assembly that will not be used as a library: no other software components will use the assembly. Babel fully obfuscates private assemblies, which will rename all public symbols.

[assembly: ObfuscateAssembly(true)]

The Boolean constructor argument assemblyIsPrivate=true tells Babel that the assembly is used within the scope of one application and the public interface can be safely renamed.

The Obfuscation Attribute

The System.Reflection.ObfuscationAttribute attribute can be used on assembly members like types, methods, events, properties and fields to configure the action taken for a specific obfuscation feature.

The Obfuscation attribute has the following properties:


The Feature property maps a string value to a specific obfuscator feature or a list of features. The default value for the Feature property is “all”.

Babel uses “all” to map the complete set of available features. and “default” to map the renaming feature.

Please refer to the obfuscation feature table to know more.


Indicates whether the obfuscation feature should be excluded for the associated member.


Specifies whether the action taken by the obfuscator for the associated type should be applied to all its members.


Specifies whether the attribute should be removed after processing.

The following code example shows how ObfuscationAttribute can be used to target a method to enable code encryption:

[Obfuscation(Feature="msil encryption", Exclude=false)]
public string DoSomething()

Extended Feature Syntax

Babel Obfuscator supports an extended syntax for feature strings that will allow setting feature properties as a list of key-value pairs after the name of each feature.

[Obfuscation(Feature="msil encryption:source=opt;cache=true", Exclude=false)]#

The extended Feature syntax will allow setting the ObfuscationAttribute at the assembly level to configure features for the entire assembly:


[assembly: Obfuscation(Feature="renaming:flatten namespaces=ACME.Test.*", Exclude=false)]
[assembly: Obfuscation(Feature="renaming:flattenNamespaces=ACME.Data.*", Exclude=false)]
[assembly: Obfuscation(Feature="renaming:internalize=true;rename parameters=true", Exclude=false)]
[assembly: Obfuscation(Feature="renaming:overloaded=true;unicode=false", Exclude=false)]
[assembly: Obfuscation(Feature="renaming:name length=5;name prefix=Acme_", Exclude=false)]

Obfuscation Agent

Disable the obfuscation Agent for Serializable types and Reflected enum tasks.

[assembly: Obfuscation(Feature="agent:tasknamelist=Serializable types,Reflected enums", Exclude=true)]

Value Encryption

Encrypts values and arrays of methods having several instructions between 10 and 100.

[assembly: Obfuscation(Feature="value encryption:min instruction count=10; max instruction count=100", Exclude=false)]

The Obfuscation attribute alone is not sufficient to activate the chosen feature. The attribute can only function if the feature is globally enabled in the configuration.

Other Examples

Do not obfuscate compiler-generated code.

[assembly: Obfuscation(Feature="all:compilergenerated=true", Exclude=true)]

Last updated