-
Notifications
You must be signed in to change notification settings - Fork 5k
Annotate System.ServiceModel.Syndication for trimming and AOT #114028
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
base: main
Are you sure you want to change the base?
Annotate System.ServiceModel.Syndication for trimming and AOT #114028
Conversation
Note regarding the
|
Note regarding the
|
public SyndicationElementExtension(string outerName, string outerNamespace, object dataContractExtension) | ||
: this(outerName, outerNamespace, dataContractExtension, null) | ||
{ | ||
} | ||
|
||
[RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] | ||
public SyndicationElementExtension(string outerName, string outerNamespace, object dataContractExtension, XmlObjectSerializer dataContractSerializer) |
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.
DataContractSerializer
's constructor isn't RequiresUnreferencedCode
, but all of the methods on it are. This constructor just creates a DataContractSerializer
without using it, so technically it doesn't need RequiresUnreferencedCode
.
If you use this constructor, a bunch of other members on this class will use that DataContractSerializer
. If you use the constructor taking XmlReader
, they don't use any serializer and are perfectly trim-compatible.
So, I think it's better to leave the attribute on this constructor. Otherwise, all those members would need to be marked RequiresUnreferencedCode
. This way, if you use the XmlReader
constructor, you won't get warnings.
Does that make sense?
@@ -109,6 +118,8 @@ public string OuterName | |||
|
|||
public string OuterNamespace | |||
{ | |||
[UnconditionalSuppressMessage("Trimming", "IL2026:RequiresUnreferencedCode", Justification = "Constructors not marked RequiresUnreferencedCode always set _outerName to a non-null value.")] | |||
[UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", Justification = "Constructors not marked RequiresUnreferencedCode always set _outerName to a non-null value.")] | |||
get | |||
{ | |||
if (_outerName == null) |
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.
Since this path is statically reachable, the linker will still keep around bits of XmlSerializer
and DataContractSerializer
, right? Is there something easy we can do about it?
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.
You can split the ExtensionDataWriter
nested class into a base abstract class (or interface) and a concrete implementation, and create the latter only in the trim-unsafe constructors.
Despite the closeness of this library to XML and WCF, the reflection usage in this library is nicely cordoned off and mostly limited to convenience methods. Thus, the library is largely trimming-compatible.
Fixes #113990
Contributes to #75480