ObfuscationAttribute.Exclude Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
true
if the type or member to which this attribute is applied should be excluded from obfuscation; otherwise, false
. The default is true
.
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
Важливо
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.
Продукт | Версії |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: