If a framework library contains code which:
- Produces a trim warning
- Is not referenced from public API
- Is rooted via a LibraryBuild descriptor for testing purposes
Then runtime build will not report the trim warning anywhere. But dotnet/sdk will fail a test when such framework makes it into the SDK repo.
We have 3 runs of illink on a framework assembly:
- First is in runtime when we trim the assembly for shipping (the per assembly run). This runs with the "library" mode, but it also passes the
ILLink.Descriptors.LibraryBuild.xml which is a descriptor, which roots more code (typically for testing purposes - I assume the tests create these via reflection for now). This run actually sees the problem in the code, but we disable all trim related warnings in this run, so it's not reported.
- Second is in runtime, the "sfx" run - where we trim the entire framework in "library" mode, but in this case, we don't apply the
ILLink.Descriptors.LibraryBuild.xml, so the affected code is not rooted. And thus the trimmer doesn't even see the affected code.
- Third run is in SDK, where we trim the entire framework in "copy" mode, which sees all code, and thus reports the problem.
Found in dotnet/sdk#31571. Related discussion in #84272.
If a framework library contains code which:
Then runtime build will not report the trim warning anywhere. But dotnet/sdk will fail a test when such framework makes it into the SDK repo.
We have 3 runs of illink on a framework assembly:
ILLink.Descriptors.LibraryBuild.xmlwhich is a descriptor, which roots more code (typically for testing purposes - I assume the tests create these via reflection for now). This run actually sees the problem in the code, but we disable all trim related warnings in this run, so it's not reported.ILLink.Descriptors.LibraryBuild.xml, so the affected code is not rooted. And thus the trimmer doesn't even see the affected code.Found in dotnet/sdk#31571. Related discussion in #84272.