Strip the ILLinkTrim.xml file from System.Private.Xml#35547
Strip the ILLinkTrim.xml file from System.Private.Xml#35547eerhardt merged 2 commits intodotnet:masterfrom
Conversation
Is #30912 addressed then as well? The linker recognizes the pattern used in ? Should we add PreserveDependency anyway, to make it explicit? |
Yes, I tested it on a standalone application: static void Main(string[] args)
{
SqlXml x = new SqlXml();
XmlReader r = x.CreateReader();
Console.WriteLine(r);
}And told the linker
I think that is a good idea. I like being explicit so we don't have any surprises in case the linker changes behavior or has a bug. A problem to be solved here is how we test this so we can catch regressions. We don't really have the capability of linking test applications today. Maybe once Xamarin apps are fully plumbed into our builds, we could make a Xamarin app that does similar to the above, and we run it to ensure it behaves correctly? |
|
Just a note for the size difference this change makes on the Here's the linked app without the change: And here's the linked app with this change: NOTE: the linker-dependencies.xml.gz file is not part of the app. It contains the dependencies between all the code, and it helps analyze why a method/type is kept in the trimmed app. |
marek-safar
left a comment
There was a problem hiding this comment.
Perhaps instead of hard to notice flag in csproj we could call the XML file differently for this mode and use that to control the logic. We also need to be careful not to ever build this library twice.
6644f4c to
2dffab9
Compare
This is a good idea. I've implemented it. I went back and forth on some different names:
but settled on |
The two methods being preserved in System.Private.Xml (CreateSqlReader and GenerateSerializer) are large, and are not necessary when linking a mobile app. These methods only need to be preserved when linking the shared framework. When a normal app is linked, the linker is able to figure out if the two methods are necessary. Contributes to dotnet#35199
- Add PreserveDependencyAttribute to SqlXml to be explicit. - Rename ILLinkTrim.xml to ILLinkTrim_LibraryBuild.xml when it shouldn't be embedded in the resulting assembly.
3443af6 to
5f5229a
Compare
This looks good! About the name, I'd personally go with |


The two methods being preserved in System.Private.Xml (CreateSqlReader and GenerateSerializer) are large, and are not necessary when linking a mobile app. These methods only need to be preserved when linking the shared framework. When a normal app is linked, the linker is able to figure out if the two methods are necessary.
Contributes to #35199
Fixes #30912