Skip to content

Support for LinkerRemovableAttribute #1162

@marek-safar

Description

@marek-safar

Once #1118 is completed we should extend it further to allow specifying "always" removed attributes. This is will be used for the final app mode of linker where some of the attributes can be always removed but we don't want to hardcode them in the linked. The idea is to have them annotated in the code or inside the custom attribute annotations.

Custom Attributes to be included in the list

  • all nullable attributes
  • System.CLSCompliantAttribute
  • System.Security.UnverifiableCodeAttribute
  • etc (the full list will be collected separately and might be RID specific)

Proposal of how it can look like when building on top of #1118

<linker>
  <assembly fullname="System.Private.CoreLib">
    <type fullname="System.CLSCompliantAttribute">
		<attribute FullName="System.LinkerRemovableAttribute" AssemblyName="System.Private.CoreLib">
		</attribute>
    </type>
  </assembly>
</linker>

The attribute name System.LinkerRemovableAttribute will be the only name hardcoded in linker which will remove all attributes usages but not the attribute definition.

To make this even more effective and to allow removing attributes which are feature linker the XML format should be extended to support feature and featurevalue attributes like in substitutions format

<linker>
  <assembly fullname="Assembly">
    <type fullname="System.Runtime.InteropServices.GuidAttribute" feature="COM" featurevalue="false">
		<attribute FullName="System.LinkerRemovableAttribute" AssemblyName="System.Private.CoreLib">
		</attribute>
    </type>
  </assembly>
</linker>

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions