dotnet / dotnet/macios

Investigate whether we can remove more attributes in the linker

Open
#16,678 3 comments 0 reactions 0 assignees View on GitHub
app-size enhancement
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

We should create a list of all the attributes in our platform assembly (sorted by how often they appear), and go through each of them to answer if they're needed.

The investigation and implementation plan are documented in this [analysis gist](https://gist.github.com/rolfbjarne/a58fac569973e57d0f29f813919d0fc8).

Except for attributes that are safe to remove unconditionally, removal must only happen when all these conditions are true:

* `PrepareAssemblies=true`
* `PostProcessAssemblies=true`
* The `trimmable-static` registrar is used

Implementation checklist:

* [x] `Foundation.ProtocolMemberAttribute` — implemented in #26089; update its feature condition to include `PostProcessAssemblies=true`.
* [x] `Foundation.RequiredMemberAttribute` — remove unconditionally.
* [x] https://github.com/dotnet/macios/pull/26257
* [x] `Foundation.OptionalMemberAttribute` — remove unconditionally.
* [x] https://github.com/dotnet/macios/pull/26257
* [ ] `System.Runtime.CompilerServices.ExtensionAttribute` — remove under the shared eligibility gate.
* [ ] `Foundation.ModelAttribute` — remove under the shared eligibility gate.
* [ ] `ObjCRuntime.NativeAttribute` — remove under the shared eligibility gate.
* [ ] `Foundation.RegisterAttribute` — remove under the shared eligibility gate when `IsDirectBinding` is known to be `true`.
* [ ] `Foundation.ExportAttribute` — remove under the shared eligibility gate from eligible direct-binding `NSObject` wrappers and sealed `BaseWrapper` protocol wrappers, after verifying runtime block/delegate fallback paths.
* [ ] https://github.com/dotnet/macios/pull/26313

Attributes removed by `RemoveAttributesStep` should be moved to trimmer xml files like ProtocolMemberAttribute, because the `RemoveAttributesStep` isn't executed for NativeAOT:
* [ ] `Foundation.ProtocolAttribute`
* [ ] `ObjCRuntime.NativeNameAttribute`
* [ ] `ObjCRuntime.AdoptsAttribute`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.