แก้ไข

แชร์ผ่าน


ObfuscationAttribute.Exclude Property

Definition

Gets or sets a Boolean value indicating whether the obfuscation tool should exclude the type or member from obfuscation.

public:
 property bool Exclude { bool get(); void set(bool value); };
public bool Exclude { get; set; }
member this.Exclude : bool with get, set
Public Property Exclude As Boolean

Property Value

true if the type or member to which this attribute is applied should be excluded from obfuscation; otherwise, false. The default is true.

Examples

The following code example shows a type that is marked to be excluded from obfuscation. It is not necessary to specify the Exclude property, because it defaults to true, but specifying it explicitly makes your intent clear. The ApplyToMembers is set to false, so that the exclusion from obfuscation does not apply to the members of the class. That is, the class name is visible but the members are obfuscated.

The MethodA method is marked with the value "default" for the Feature property. It is necessary to specify false for the Exclude property in order to avoid excluding MethodA from obfuscation, because the default for the Exclude property is true. The StripAfterObfuscation property is false so that the obfuscation tool will not strip the attribute after obfuscation.

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",
        StripAfterObfuscation=false)]
    public void MethodA() {}

    // This member is marked for obfuscation, because the
    // exclusion of the type is not applied to its members.
    public void MethodB() {}
}
<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", StripAfterObfuscation:=False)> _
    Public Sub MethodA()
    End Sub

    ' This member is marked for obfuscation, because the 
    ' exclusion of the type is not applied to its members.
    Public Sub MethodB()
    End Sub

End Class

Remarks

Important

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.

Applies to