Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2021-04-06 23:20:22 +0300
committerGitHub <noreply@github.com>2021-04-06 23:20:22 +0300
commit50e3ca63dc9a327eaded4fa90cdf79c0f005987c (patch)
tree745849907e4f1985111faa550ae5a87541169467 /docs
parent2674d7d0c36159aa1aec2fb0a53fffecf50e5780 (diff)
Extend attributes removal to support values matching (#1935)
* Extend attributes removal to support values matching This is useful for key/value pair like custom attributes removal * PR feedback
Diffstat (limited to 'docs')
-rw-r--r--docs/data-formats.md28
1 files changed, 23 insertions, 5 deletions
diff --git a/docs/data-formats.md b/docs/data-formats.md
index 91670c8d9..f3a11d981 100644
--- a/docs/data-formats.md
+++ b/docs/data-formats.md
@@ -528,15 +528,15 @@ attributes are applied.
<attribute fullname="SomecustomAttribute" feature="EnableOptionalFeature" featurevalue="false"/>
```
-### Special custom attributes
+### Removing custom attributes
-Also if the attribute is used in a type, a special property can be used to specify that the type
-is a Custom Attribute and it's instances should be removed by the linker. To do this use `internal="RemoveAttributeInstances"` instead of specifying `fullname` in the attribute as described in the following
-example:
+Any custom attribute can be annotated with a special custom attribute which can be used to specify
+that all instances of the attribute can be removed by the linker. To do this use `internal="RemoveAttributeInstances"`
+instead of specifying `fullname` in the attribute as described in the following example:
```xml
<linker>
- <assembly fullname="*">
+ <assembly fullname="*">
<type fullname="System.Runtime.CompilerServices.NullableAttribute">
<attribute internal="RemoveAttributeInstances" feature="EnableOptionalFeature" featurevalue="false" />
</type>
@@ -544,6 +544,24 @@ example:
</linker>
```
+In some cases, it's useful to remove only specific usage of the attribute. This can be achieved by specifying the value
+or values of the arguments to match. In the example below only `System.Reflection.AssemblyMetadataAttribute` custom attributes
+with the first argument equal to `RemovableValue` will be removed.
+
+```xml
+<linker>
+ <assembly fullname="*">
+ <type fullname="System.Reflection.AssemblyMetadataAttribute">
+ <attribute internal="RemoveAttributeInstances">
+ <argument type="System.Object">
+ <argument>RemovableValue</argument>
+ </argument>
+ </attribute>
+ </type>
+ </assembly>
+</linker>
+```
+
Notice that a descriptor file containing the custom attribute type overrides this behavior. In case the
custom attribute type is being referenced in a descriptor file and in the attribute annotations file
for removal, the custom attribute will not be removed.