ObfuscationAttribute.Exclude 屬性

定義

取得或設定 Boolean 值,指出模糊化工具是否應該將型別或成員排除模糊化。

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

屬性值

如果套用這項屬性的型別或成員應該排除模糊化,則為 true,否則為 false。 預設為 true

範例

下列程式代碼範例顯示標示為要從混淆中排除的類型。 不需要指定 Exclude 屬性,因為它預設為 true,但指定它會明確地讓您的意圖清楚。 設定 ApplyToMembersfalse,如此一來,模糊化排除就不會套用至 類別的成員。 也就是說,類別名稱是可見的,但成員會模糊化。

方法MethodA會以 屬性的值"default"Feature標示。 您必須為 屬性指定 false ,以避免從模糊化中排除MethodA,因為 屬性的Exclude預設值為 trueExclude 屬性 StripAfterObfuscationfalse 讓模糊化工具不會在模糊化之後移除屬性。

此程式代碼是可編譯和執行之較大範例的一部分。 請參閱 ObfuscationAttribute 類別。

[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

備註

重要

套用此屬性不會自動模糊您套用它的程式代碼實體。 套用 屬性是建立混淆工具組態檔的替代方案。 也就是說,它只會提供模糊化工具的指示。 Microsoft 建議廠商遵循此處所述的語意來混淆工具。 不過,不保證特定工具遵循 Microsoft 建議。

適用於