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 です。

次のコード例は、難読化から除外するようにマークされている型を示しています。 プロパティの既定値trueは であるため、 プロパティをExclude指定する必要はありませんが、明示的に指定すると意図が明確になります。 ApplyToMembersは にfalse設定されているため、難読化からの除外は クラスのメンバーには適用されません。 つまり、クラス名は表示されますが、メンバーは難読化されます。

メソッドはMethodA、 プロパティの値"default"Featureでマークされます。 プロパティの既定値は であるため、難読化からの除外MethodAを回避するには、 プロパティtrueに を指定falseExcludeするExclude必要があります。 プロパティは 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 の推奨事項に従っている保証はありません。

適用対象