Re:Introducing .NET IL Linker
by SideburnsOfDoom on Thursday August 31, 2017 @05:22AM
(#15139149)
> However for .NET, since you can use reflection to load any type in an assembly and call any method dynamically, removing a method is isn't statically called could cause you to fail at runtime.
Indeed. it's not that common, but I would expect it to happen. One example is that many IoC Containers allow you to scan assemblies and register all class + interface pairs that match given rules.
There has to be some safety-hatch to express "yes, I really want to keep that class and its methods. Don't strip them out".
This seems to be documented here: https://github.com/dotnet/core/blob/master/samples/linker-in...
Since reflection and dynamic invocation is a major feature of the runtime, they have avoided this optimization before.