System.Reflection.ObfuscationAttribute Class

Instructs obfuscation tools to take the specified actions for an assembly, type, or member.

See Also: ObfuscationAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Event | System.AttributeTargets.Interface | System.AttributeTargets.Parameter | System.AttributeTargets.Delegate | System.AttributeTargets.All, AllowMultiple=true, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ObfuscationAttribute : Attribute

Remarks

The System.Reflection.ObfuscationAttribute and System.Reflection.ObfuscateAssemblyAttribute attributes allow assembly authors to annotate their binaries so that obfuscation tools can process them correctly with minimal external configuration.

Note:

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 System.Reflection.ObfuscationAttribute attribute has a string ObfuscationAttribute.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 System.Reflection.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 ObfuscationAttribute.Feature property is "all", enabling the complete set of obfuscation features.

When applied to an assembly, System.Reflection.ObfuscationAttribute also applies to all types within the assembly. If the ObfuscationAttribute.ApplyToMembers property is not specified, or is set to true, the attribute applies to all members as well. System.Reflection.ObfuscationAttribute does not specify whether an assembly is public or private. To specify whether an assembly is public or private, use the System.Reflection.ObfuscateAssemblyAttribute attribute.

When applied to classes and structures, System.Reflection.ObfuscationAttribute also applies to all members of the type if the ObfuscationAttribute.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.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0