ObfuscationAttribute.StripAfterObfuscation Property


Gets or sets a Boolean value indicating whether the obfuscation tool should remove this attribute after processing.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public bool StripAfterObfuscation { get; set; }

Property Value

Type: System.Boolean

true if an obfuscation tool should remove the attribute after processing; otherwise, false. The default is true.

Attributes should not be stripped if your library will be included as part of another application, and obfuscated as part of that application.


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 following code example shows an ObfuscationAttribute whose StripAfterObfuscation property is false so that the obfuscation tool will not strip the attribute after obfuscation. 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.

This code is part of a larger example that can be compiled and executed. See the ObfuscationAttribute class.

[ObfuscationAttribute(Exclude=true, ApplyToMembers=false)]
public class Type2

    // The exclusion of the type is not applied to its members,
    // however in order to mark the member with the "default" 
    // feature it is necessary to specify Exclude=false,
    // because the default value of Exclude is true. The tool
    // should not strip this attribute after obfuscation.
    [ObfuscationAttribute(Exclude=false, Feature="default", 
    public void MethodA() {}

    // This member is marked for obfuscation, because the 
    // exclusion of the type is not applied to its members.
    public void MethodB() {}


.NET Framework
Available since 2.0
Return to top