Assembly: mscorlib (in mscorlib.dll)
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event|AttributeTargets::Interface|AttributeTargets::Parameter|AttributeTargets::Delegate, AllowMultiple=true, Inherited=false)] [ComVisibleAttribute(true)] public ref class ObfuscationAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Parameter|AttributeTargets.Delegate, AllowMultiple=true, Inherited=false) */ /** @attribute ComVisibleAttribute(true) */ public final class ObfuscationAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Parameter|AttributeTargets.Delegate, AllowMultiple=true, Inherited=false) ComVisibleAttribute(true) public final class ObfuscationAttribute extends Attribute
The ObfuscationAttribute and ObfuscateAssemblyAttribute attributes allow assembly authors to annotate their binaries so that obfuscation tools can process them correctly with minimal external configuration.
Applying this attribute does not automatically obfuscate the code entity to which you apply it. Applying the attribute is an alternative to creating a configuration file for the obfuscation tool. That is, it merely provides instructions for an obfuscation tool. Microsoft recommends that vendors of obfuscation tools follow the semantics described here. However, there is no guarantee that a particular tool follows Microsoft recommendations.
The ObfuscationAttribute attribute has a string Feature property. Obfuscation tools can map the string values of this property to features they implement, preferably by using an XML configuration file that users can access. The ObfuscationAttribute defines two feature strings, "default" and "all". The string "default" should map to the default obfuscation features of a tool, and "all" should map to the complete set of obfuscation features supported by a tool. The default value of the Feature property is "all", enabling the complete set of obfuscation features.
When applied to an assembly, ObfuscationAttribute also applies to all types within the assembly. If the ApplyToMembers property is not specified, or is set to true, the attribute applies to all members as well. ObfuscationAttribute does not specify whether an assembly is public or private. To specify whether an assembly is public or private, use the ObfuscateAssemblyAttribute attribute.
When applied to classes and structures, ObfuscationAttribute also applies to all members of the type if the ApplyToMembers property is not specified, or is set to true.
When applied to methods, parameters, fields, and properties, the attribute affects only the entity to which it is applied.
The following code example shows a public assembly with two types: Type1 and Type2. The assembly is marked for obfuscation with the ObfuscateAssemblyAttribute, which marks the assembly to be treated as public (that is, the AssemblyIsPrivate property is false).
Type1 is marked for obfuscation because the assembly is marked for obfuscation. One member of Type1 is excluded from obfuscation, using the Exclude property.
Type2 is excluded from obfuscation, but its members are marked for obfuscation because the ApplyToMembers property is false.
The MethodA method of Type2 is marked with the value "default" for the Feature property. It is necessary to specify false for the Exclude property to avoid excluding MethodA from obfuscation, because the default for the Exclude property is true. The obfuscation tool should not strip the attribute after obfuscation because the StripAfterObfuscation property is false. All the other attributes in this code example are stripped after obfuscation, because the StripAfterObfuscation property is not specified, and therefore defaults to true.
The code example includes code to display the attributes and their properties. You can also examine the attributes by opening the DLL with the MSIL Disassembler (Ildasm.exe).
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.