il-repack
il-repack copied to clipboard
Option to remove all non-referenced members from output assembly
It would be great to have an option to remove all items from an assembly that are non-referenced. .. With an option to exclude specified attribute names (allow for multiple) - I guess the obfuscation one should be respected by default IF no command line switch is passed in ... and another option to remove private & friend only (to allow for public libs)
Thanks
I vote for this!
There should be a way to exclude specific classes / methods, also to ensure InternalVisibleTo does not break (for example for unit tests). I'm not I'm a fan of attributing with ObfuscationAttribute, although it's a very simply solution (and I like those !). An exclusion based on (part of) the full name in configuration would be better in my mind.
This is a reasonable but unrealistic feature request for a small open source project of this size.
Tree shaking algorithm isn't simple, and even Microsoft works on this for years and takes several .NET Core releases to improve it.
You can use Microsoft remake of monolinker (which is used in Unity and Blazor) for it.
Agreed, you can use ILLink on the merged assembly after the fact to tree-shake it.
We do have a branch with a prototype of a linker here: https://github.com/gluck/il-repack/tree/linker
However it's 8 years old, and stale and I don't know what the state of it was.
https://github.com/dotnet/core/blob/main/samples/linker-instructions.md