Dotfuscator User's Guide
Excluding By Custom Attribute

Types, methods, fields, and properties may be selectively excluded by custom attribute. A custom attribute rule selects an item (type, method, field or property) based on matching against the names of custom attributes that annotate the item. One or more custom attribute rules may be nested inside any rule that selects types, methods, fields, or properties.

A type, method, field, or property rule may have multiple custom attribute rules associated with it. In this case, an item is selected if at least one of the custom attribute rules selects it.

The following example selects all types that are annotated with either MyCustomAttribute or MyOtherCustomAttribute:

Types Annotated with MyCustomAttribute or MyOther CustomAttribute:
Copy Code
<type name=".*" excludetype="false" regex="true>
   <customattribute name="MyCustomAttribute"/>
...<customattribute name="MyOtherCustomAttribute"/>
</type>

Custom attribute rules can also be written using regular expressions to match custom attribute names. The following example is another way to select all types annotated with either MyCustomAttribute or MyOtherCustomAttribute:

Types Annotated with MyCustomAttribute or MyOther CustomAttribute: 
Copy Code
<type name=".*" excludetype="false" regex="true>
   <customattribute name="My.*CustomAttribute" regex="true"/>
</type>

The next example shows how to exclude all methods annotated with a custom attribute named MyCustomAttribute:

Exclude Annotated Methods
Copy Code
<type name=".*" excludetype="false" regex="true">
   <method name=".*" regex="true">
      <customattribute name="MyCustomAttribute"/>
   </method>
</type>

Custom attribute rules can be applied to subtypes or overriding methods and properties by specifying the allowinheritance attribute. When the value of this attribute is set to true then subtypes or overriding methods and properties with the specified custom attribute will also be excluded.

 

 


© 2016 PreEmptive Solutions, LLC. All Rights Reserved.

www.preemptive.com