-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't trim ShouldSerializeXXX and ResetXXX members that may be called with reflection #102780
Don't trim ShouldSerializeXXX and ResetXXX members that may be called with reflection #102780
Conversation
Tagging subscribers to this area: @roji, @ajcvickers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look like the right fix. #102244 (comment) and the subsequent discussion discuss why.
I think this should use ILLink.LibraryBuild file like the original issue was suggesting so that these get preserved when we build the repo. After repo build it can be trimmed like anything else. ILLink.LibraryBuild is designed for these cases.
These DynamicDependency will keep things unconditionally in trimmed apps even if nobody uses TypeDescriptor/Json.NET/etc. It's a global fix for a local problem. It will regress the size for everyone, including the well behaved apps that don't use trim unsafe code this tries to fix. Everything that could need this should already be marked as trim unsafe. We don't need trim unsafe code to work in trimmed apps, it is okay and expected that trim unsafe code will be broken after trimming. It is the responsibility of whoever is turning on trimming on trim unsafe code to author XML descriptors if they wish to take the hard path.
The
TypeDescriptor
reflection-based model and the XML and Json.NET serializers use these conventions.
These are also trim unsafe and not expected to work after trimming. The issue this PR tries to address is a drop in the bucket, there are more fundamental trimming problems with these serializers.
I assume the change requested here is to move the DynamicDependency from source to XML like this: <type fullname="System.Data.DataSet">
<method signature="System.Void .ctor()">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute">
<argument>ResetRelations</argument>
</attribute> however, when I do that it appears trimming already occurred, meaning in the example above I'll get this error when building:
|
Yes, it should be in
I am not sure where this error is coming from. Could you please apply the change so that we can see it? |
I saw that right after I posted; I was using the wrong xml file. I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not reviewing whether this list is complete, but the approach looks good to me! Thanks!
src/libraries/System.Data.Common/src/ILLink/ILLink.Descriptors.LibraryBuild.xml
Outdated
Show resolved
Hide resolved
This should be considered for servicing once verified. |
@roji @AndriySvyryd fyi -- |
Fixes #102244
This change makes sure these members exist in the inbox version of the
System.Data.Common
assembly.The
TypeDescriptor
reflection-based model, the XML serializer, and the Json.NET serializer use these naming conventions to call the members with reflection.