Description
In #80246, we are adding support for RuntimeFeature.IsDynamicCodeSupported to be a feature switch, instead of being hard-coded to true
for CoreCLR. This allows developers to test their code simulating it running with NativeAOT, without actually needing to publish for NativeAOT.
As part of adding this feature switch, I don't want to regress app sizes for existing apps. Since CoreCLR currently hard-codes RuntimeFeature.IsDynamicCodeSupported
to true
. So when you trim a CoreCLR app with code like the following:
RuntimeFeature.IsDynamicCodeSupported ?
new ReflectionEmitCachingMemberAccessor() :
new ReflectionMemberAccessor();
The ReflectionMemberAccessor
class can be trimmed, since IsDynamicCodeSupported
will always be true
.
To do this, I wanted to use a featuredefault
option in my ILLink.Substitutions.xml
. This would tell the trimmer that if no one specifies the RuntimeFeature.IsDynamicCodeSupported feature switch, assume it is true
.
However, since we run the trimmer during the build of System.Private.CoreLib, this featuredefault
is getting applied during the "library build" time. Which means the property is getting hard-coded to true
at the build time, and the code in the RuntimeFeature.IsDynamicCodeSupported property is getting removed.
We should figure out a way where a library can embed a featuredefault
ILLink.Substitutions.xml element, but only have it apply during "app publish" time.
Metadata
Metadata
Assignees
Type
Projects
Status