Consider stripping names of fields that don't matter
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
Now that linker has a pretty good idea what fields are accessed through reflection (and warns whenever its not sure), we could consider stripping names of fields that are not observable.
A field name that is not observable could be defined as:
* Private field, or field on a private nested type
* Internal field, or field on an internal type when no InternalsVisibleTo is present
* Field that linker didn't see as used through reflection
* Not on a generic type (because of MemberRefs to TypeSpecs).
* If we have whole program view, we could extend to publics that are not accessed from other assemblies in the closure.
Stripping name means setting accessibility to `compilercontrolled` (`IsCompilerControlled = true` in Cecil) and setting name to null.
I experimentally tried this on Mono's WASM CoreLib and saw 1.3% savings. I didn't actually try whether things work. `compilercontrolled` is such a corner case that I wouldn't be surprised if there's bugs.
It would be more significant if we could do this to methods and types, but it's too easy to get to names of those without linker realizing the name is observable (e.g. `o.GetType().FullName` for types, or `new StackTrace().ToString()` for method names).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.