diff --git a/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.cs b/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.cs index e885ecd521be68..da3365c2536808 100644 --- a/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.cs +++ b/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.cs @@ -11,7 +11,8 @@ public partial class Atom10FeedFormatter : System.ServiceModel.Syndication.Syndi { public Atom10FeedFormatter() { } public Atom10FeedFormatter(System.ServiceModel.Syndication.SyndicationFeed feedToWrite) { } - public Atom10FeedFormatter(System.Type feedTypeToCreate) { } + public Atom10FeedFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type feedTypeToCreate) { } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected System.Type FeedType { get { throw null; } } public bool PreserveAttributeExtensions { get { throw null; } set { } } public bool PreserveElementExtensions { get { throw null; } set { } } @@ -40,7 +41,8 @@ public partial class Atom10ItemFormatter : System.ServiceModel.Syndication.Syndi { public Atom10ItemFormatter() { } public Atom10ItemFormatter(System.ServiceModel.Syndication.SyndicationItem itemToWrite) { } - public Atom10ItemFormatter(System.Type itemTypeToCreate) { } + public Atom10ItemFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type itemTypeToCreate) { } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected System.Type ItemType { get { throw null; } } public bool PreserveAttributeExtensions { get { throw null; } set { } } public bool PreserveElementExtensions { get { throw null; } set { } } @@ -65,7 +67,7 @@ public partial class AtomPub10CategoriesDocumentFormatter : System.ServiceModel. { public AtomPub10CategoriesDocumentFormatter() { } public AtomPub10CategoriesDocumentFormatter(System.ServiceModel.Syndication.CategoriesDocument documentToWrite) { } - public AtomPub10CategoriesDocumentFormatter(System.Type inlineDocumentType, System.Type referencedDocumentType) { } + public AtomPub10CategoriesDocumentFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type inlineDocumentType, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type referencedDocumentType) { } public override string Version { get { throw null; } } public override bool CanRead(System.Xml.XmlReader reader) { throw null; } protected override System.ServiceModel.Syndication.InlineCategoriesDocument CreateInlineCategoriesDocument() { throw null; } @@ -81,7 +83,7 @@ public partial class AtomPub10ServiceDocumentFormatter : System.ServiceModel.Syn { public AtomPub10ServiceDocumentFormatter() { } public AtomPub10ServiceDocumentFormatter(System.ServiceModel.Syndication.ServiceDocument documentToWrite) { } - public AtomPub10ServiceDocumentFormatter(System.Type documentTypeToCreate) { } + public AtomPub10ServiceDocumentFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type documentTypeToCreate) { } public override string Version { get { throw null; } } public override bool CanRead(System.Xml.XmlReader reader) { throw null; } protected override System.ServiceModel.Syndication.ServiceDocument CreateDocumentInstance() { throw null; } @@ -98,6 +100,7 @@ public AtomPub10ServiceDocumentFormatter() { } public AtomPub10ServiceDocumentFormatter(TServiceDocument documentToWrite) { } protected override System.ServiceModel.Syndication.ServiceDocument CreateDocumentInstance() { throw null; } } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public abstract partial class CategoriesDocument { internal CategoriesDocument() { } @@ -173,7 +176,8 @@ public partial class Rss20FeedFormatter : System.ServiceModel.Syndication.Syndic public Rss20FeedFormatter() { } public Rss20FeedFormatter(System.ServiceModel.Syndication.SyndicationFeed feedToWrite) { } public Rss20FeedFormatter(System.ServiceModel.Syndication.SyndicationFeed feedToWrite, bool serializeExtensionsAsAtom) { } - public Rss20FeedFormatter(System.Type feedTypeToCreate) { } + public Rss20FeedFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type feedTypeToCreate) { } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected System.Type FeedType { get { throw null; } } public bool PreserveAttributeExtensions { get { throw null; } set { } } public bool PreserveElementExtensions { get { throw null; } set { } } @@ -206,7 +210,8 @@ public partial class Rss20ItemFormatter : System.ServiceModel.Syndication.Syndic public Rss20ItemFormatter() { } public Rss20ItemFormatter(System.ServiceModel.Syndication.SyndicationItem itemToWrite) { } public Rss20ItemFormatter(System.ServiceModel.Syndication.SyndicationItem itemToWrite, bool serializeExtensionsAsAtom) { } - public Rss20ItemFormatter(System.Type itemTypeToCreate) { } + public Rss20ItemFormatter([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] System.Type itemTypeToCreate) { } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected System.Type ItemType { get { throw null; } } public bool PreserveAttributeExtensions { get { throw null; } set { } } public bool PreserveElementExtensions { get { throw null; } set { } } @@ -228,6 +233,7 @@ public Rss20ItemFormatter(TSyndicationItem itemToWrite) { } public Rss20ItemFormatter(TSyndicationItem itemToWrite, bool serializeExtensionsAsAtom) { } protected override System.ServiceModel.Syndication.SyndicationItem CreateItemInstance() { throw null; } } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public partial class ServiceDocument { public ServiceDocument() { } @@ -313,8 +319,12 @@ protected SyndicationContent(System.ServiceModel.Syndication.SyndicationContent public static System.ServiceModel.Syndication.TextSyndicationContent CreatePlaintextContent(string content) { throw null; } public static System.ServiceModel.Syndication.UrlSyndicationContent CreateUrlContent(System.Uri url, string mediaType) { throw null; } public static System.ServiceModel.Syndication.TextSyndicationContent CreateXhtmlContent(string content) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public static System.ServiceModel.Syndication.XmlSyndicationContent CreateXmlContent(object dataContractObject) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public static System.ServiceModel.Syndication.XmlSyndicationContent CreateXmlContent(object dataContractObject, System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public static System.ServiceModel.Syndication.XmlSyndicationContent CreateXmlContent(object xmlSerializerObject, System.Xml.Serialization.XmlSerializer serializer) { throw null; } public static System.ServiceModel.Syndication.XmlSyndicationContent CreateXmlContent(System.Xml.XmlReader xmlReader) { throw null; } protected abstract void WriteContentsTo(System.Xml.XmlWriter writer); @@ -322,16 +332,28 @@ public void WriteTo(System.Xml.XmlWriter writer, string outerElementName, string } public partial class SyndicationElementExtension { + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public SyndicationElementExtension(object dataContractExtension) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public SyndicationElementExtension(object dataContractExtension, System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public SyndicationElementExtension(object xmlSerializerExtension, System.Xml.Serialization.XmlSerializer serializer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public SyndicationElementExtension(string outerName, string outerNamespace, object dataContractExtension) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public SyndicationElementExtension(string outerName, string outerNamespace, object dataContractExtension, System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { } public SyndicationElementExtension(System.Xml.XmlReader xmlReader) { } public string OuterName { get { throw null; } } public string OuterNamespace { get { throw null; } } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TExtension GetObject() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TExtension GetObject(System.Runtime.Serialization.XmlObjectSerializer serializer) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TExtension GetObject(System.Xml.Serialization.XmlSerializer serializer) { throw null; } public System.Xml.XmlReader GetReader() { throw null; } public void WriteTo(System.Xml.XmlWriter writer) { } @@ -339,21 +361,34 @@ public void WriteTo(System.Xml.XmlWriter writer) { } public sealed partial class SyndicationElementExtensionCollection : System.Collections.ObjectModel.Collection { internal SyndicationElementExtensionCollection() { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public void Add(object extension) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public void Add(object dataContractExtension, System.Runtime.Serialization.DataContractSerializer serializer) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public void Add(object xmlSerializerExtension, System.Xml.Serialization.XmlSerializer serializer) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public void Add(string outerName, string outerNamespace, object dataContractExtension) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public void Add(string outerName, string outerNamespace, object dataContractExtension, System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { } public void Add(System.Xml.XmlReader xmlReader) { } protected override void ClearItems() { } public System.Xml.XmlReader GetReaderAtElementExtensions() { throw null; } protected override void InsertItem(int index, System.ServiceModel.Syndication.SyndicationElementExtension item) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public System.Collections.ObjectModel.Collection ReadElementExtensions(string extensionName, string extensionNamespace) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public System.Collections.ObjectModel.Collection ReadElementExtensions(string extensionName, string extensionNamespace, System.Runtime.Serialization.XmlObjectSerializer serializer) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public System.Collections.ObjectModel.Collection ReadElementExtensions(string extensionName, string extensionNamespace, System.Xml.Serialization.XmlSerializer serializer) { throw null; } protected override void RemoveItem(int index) { } protected override void SetItem(int index, System.ServiceModel.Syndication.SyndicationElementExtension item) { } } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public partial class SyndicationFeed { public SyndicationFeed() { } @@ -443,6 +478,7 @@ protected internal static void WriteElementExtensions(System.Xml.XmlWriter write protected internal static void WriteElementExtensions(System.Xml.XmlWriter writer, System.ServiceModel.Syndication.SyndicationPerson person, string version) { } public abstract void WriteTo(System.Xml.XmlWriter writer); } + [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public partial class SyndicationItem { public SyndicationItem() { } @@ -613,7 +649,10 @@ protected internal virtual void WriteElementExtensions(System.Xml.XmlWriter writ public partial class XmlSyndicationContent : System.ServiceModel.Syndication.SyndicationContent { protected XmlSyndicationContent(System.ServiceModel.Syndication.XmlSyndicationContent source) { } + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public XmlSyndicationContent(string type, object dataContractExtension, System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public XmlSyndicationContent(string type, object xmlSerializerExtension, System.Xml.Serialization.XmlSerializer serializer) { } public XmlSyndicationContent(string type, System.ServiceModel.Syndication.SyndicationElementExtension extension) { } public XmlSyndicationContent(System.Xml.XmlReader reader) { } @@ -621,8 +660,14 @@ public XmlSyndicationContent(System.Xml.XmlReader reader) { } public override string Type { get { throw null; } } public override System.ServiceModel.Syndication.SyndicationContent Clone() { throw null; } public System.Xml.XmlDictionaryReader GetReaderAtContent() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TContent ReadContent() { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TContent ReadContent(System.Runtime.Serialization.XmlObjectSerializer dataContractSerializer) { throw null; } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Serialization and deserialization requires dynamic code generation")] + [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Members from serialized and deserialized types may be trimmed if not referenced directly")] public TContent ReadContent(System.Xml.Serialization.XmlSerializer serializer) { throw null; } protected override void WriteContentsTo(System.Xml.XmlWriter writer) { } } diff --git a/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.csproj b/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.csproj index 7fae0526ada67c..75e86f11a23b87 100644 --- a/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.csproj +++ b/src/libraries/System.ServiceModel.Syndication/ref/System.ServiceModel.Syndication.csproj @@ -13,6 +13,14 @@ + + + + + + + + diff --git a/src/libraries/System.ServiceModel.Syndication/src/ILLink/ILLink.Suppressions.xml b/src/libraries/System.ServiceModel.Syndication/src/ILLink/ILLink.Suppressions.xml deleted file mode 100644 index b597302f946ec7..00000000000000 --- a/src/libraries/System.ServiceModel.Syndication/src/ILLink/ILLink.Suppressions.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtension.#ctor(System.Object,System.Xml.Serialization.XmlSerializer) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtension.ExtensionDataWriter.ComputeOuterNameAndNs(System.String@,System.String@) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtension.ExtensionDataWriter.WriteTo(System.Xml.XmlWriter) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtension.GetObject``1(System.Runtime.Serialization.XmlObjectSerializer) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtension.GetObject``1(System.Xml.Serialization.XmlSerializer) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.SyndicationElementExtensionCollection.Add(System.Object,System.Xml.Serialization.XmlSerializer) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.XmlSyndicationContent.ReadContent``1(System.Runtime.Serialization.XmlObjectSerializer) - - - ILLink - IL2026 - member - M:System.ServiceModel.Syndication.XmlSyndicationContent.ReadContent``1(System.Xml.Serialization.XmlSerializer) - - - ILLink - IL2067 - member - M:System.ServiceModel.Syndication.SyndicationFeedFormatter.CreateFeedInstance(System.Type) - - - ILLink - IL2067 - member - M:System.ServiceModel.Syndication.SyndicationItemFormatter.CreateItemInstance(System.Type) - - - ILLink - IL2077 - member - M:System.ServiceModel.Syndication.AtomPub10CategoriesDocumentFormatter.CreateInlineCategoriesDocument - - - ILLink - IL2077 - member - M:System.ServiceModel.Syndication.AtomPub10CategoriesDocumentFormatter.CreateReferencedCategoriesDocument - - - ILLink - IL2077 - member - M:System.ServiceModel.Syndication.AtomPub10ServiceDocumentFormatter.CreateDocumentInstance - - - \ No newline at end of file diff --git a/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj b/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj index 29a05a68ef6492..056eb0c2b3d3ae 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj +++ b/src/libraries/System.ServiceModel.Syndication/src/System.ServiceModel.Syndication.csproj @@ -2,7 +2,6 @@ $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) - false true false true @@ -64,6 +63,14 @@ + + + + + + + + diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs index 3953b79f907f93..ba616cd3795017 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs @@ -35,7 +35,7 @@ public Atom10FeedFormatter() : this(typeof(SyndicationFeed)) { } - public Atom10FeedFormatter(Type feedTypeToCreate) : base() + public Atom10FeedFormatter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type feedTypeToCreate) : base() { if (feedTypeToCreate is null) { @@ -69,6 +69,7 @@ internal override TryParseDateTimeCallback GetDefaultDateTimeParser() public override string Version => SyndicationVersions.Atom10; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected Type FeedType { get; } public override bool CanRead(XmlReader reader) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10ItemFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10ItemFormatter.cs index 04014f9dad07d1..eb59c9834442de 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10ItemFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10ItemFormatter.cs @@ -19,7 +19,7 @@ public Atom10ItemFormatter() : this(typeof(SyndicationItem)) { } - public Atom10ItemFormatter(Type itemTypeToCreate) : base() + public Atom10ItemFormatter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type itemTypeToCreate) : base() { if (itemTypeToCreate is null) { @@ -61,6 +61,7 @@ public bool PreserveElementExtensions public override string Version => SyndicationVersions.Atom10; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected Type ItemType { get; } public override bool CanRead(XmlReader reader) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10CategoriesDocumentFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10CategoriesDocumentFormatter.cs index 88d45208da4dd1..7ebb7e6088d029 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10CategoriesDocumentFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10CategoriesDocumentFormatter.cs @@ -11,15 +11,19 @@ namespace System.ServiceModel.Syndication [XmlRoot(ElementName = App10Constants.Categories, Namespace = App10Constants.Namespace)] public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter, IXmlSerializable { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] private readonly Type _inlineDocumentType; private readonly int _maxExtensionSize; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] private readonly Type _referencedDocumentType; public AtomPub10CategoriesDocumentFormatter() : this(typeof(InlineCategoriesDocument), typeof(ReferencedCategoriesDocument)) { } - public AtomPub10CategoriesDocumentFormatter(Type inlineDocumentType, Type referencedDocumentType) : base() + public AtomPub10CategoriesDocumentFormatter( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type inlineDocumentType, + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type referencedDocumentType) : base() { if (inlineDocumentType == null) { diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10ServiceDocumentFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10ServiceDocumentFormatter.cs index 752fa84d51caf9..44ca7c65e51084 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10ServiceDocumentFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10ServiceDocumentFormatter.cs @@ -15,6 +15,7 @@ namespace System.ServiceModel.Syndication [XmlRoot(ElementName = App10Constants.Service, Namespace = App10Constants.Namespace)] public class AtomPub10ServiceDocumentFormatter : ServiceDocumentFormatter, IXmlSerializable { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] private readonly Type _documentType; private readonly int _maxExtensionSize; @@ -22,7 +23,7 @@ public AtomPub10ServiceDocumentFormatter() : this(typeof(ServiceDocument)) { } - public AtomPub10ServiceDocumentFormatter(Type documentTypeToCreate) : base() + public AtomPub10ServiceDocumentFormatter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type documentTypeToCreate) : base() { if (documentTypeToCreate is null) { diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/CategoriesDocument.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/CategoriesDocument.cs index bb4e319b09be7a..8007136ad87102 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/CategoriesDocument.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/CategoriesDocument.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics.CodeAnalysis; using System.Xml; namespace System.ServiceModel.Syndication { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public abstract class CategoriesDocument : IExtensibleSyndicationObject { private ExtensibleSyndicationObject _extensions; diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs index b71004972ad700..8e0129f609f4cf 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs @@ -28,7 +28,7 @@ public Rss20FeedFormatter() : this(typeof(SyndicationFeed)) { } - public Rss20FeedFormatter(Type feedTypeToCreate) : base() + public Rss20FeedFormatter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type feedTypeToCreate) : base() { if (feedTypeToCreate is null) { @@ -69,6 +69,7 @@ public Rss20FeedFormatter(SyndicationFeed feedToWrite, bool serializeExtensionsA public override string Version => SyndicationVersions.Rss20; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected Type FeedType { get; } public override bool CanRead(XmlReader reader) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20ItemFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20ItemFormatter.cs index 7f9b1c5f01b475..3e62362bcbd837 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20ItemFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20ItemFormatter.cs @@ -20,7 +20,7 @@ public Rss20ItemFormatter() : this(typeof(SyndicationItem)) { } - public Rss20ItemFormatter(Type itemTypeToCreate) : base() + public Rss20ItemFormatter([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type itemTypeToCreate) : base() { if (itemTypeToCreate is null) { @@ -84,6 +84,7 @@ public bool SerializeExtensionsAsAtom public override string Version => SyndicationVersions.Rss20; + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] protected Type ItemType { get; } public override bool CanRead(XmlReader reader) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ServiceDocument.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ServiceDocument.cs index 7533214a331113..ee1d303c8aaf0a 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ServiceDocument.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ServiceDocument.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics.CodeAnalysis; using System.Xml; namespace System.ServiceModel.Syndication { + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public class ServiceDocument : IExtensibleSyndicationObject { private ExtensibleSyndicationObject _extensions; diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationContent.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationContent.cs index cf689db1874780..f2ac6f1f8c2a0b 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationContent.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationContent.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Xml; using System.Xml.Serialization; @@ -45,11 +46,13 @@ public static TextSyndicationContent CreateXhtmlContent(string content) return new TextSyndicationContent(content, TextSyndicationContentKind.XHtml); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public static XmlSyndicationContent CreateXmlContent(object dataContractObject) { return new XmlSyndicationContent(Atom10Constants.XmlMediaType, dataContractObject, (DataContractSerializer)null); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public static XmlSyndicationContent CreateXmlContent(object dataContractObject, XmlObjectSerializer dataContractSerializer) { return new XmlSyndicationContent(Atom10Constants.XmlMediaType, dataContractObject, dataContractSerializer); @@ -60,6 +63,8 @@ public static XmlSyndicationContent CreateXmlContent(XmlReader xmlReader) return new XmlSyndicationContent(xmlReader); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public static XmlSyndicationContent CreateXmlContent(object xmlSerializerObject, XmlSerializer serializer) { return new XmlSyndicationContent(Atom10Constants.XmlMediaType, xmlSerializerObject, serializer); diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtension.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtension.cs index 9c7f0c170d08a9..8a8ecc3caf213b 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtension.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtension.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.Serialization; using System.Xml; @@ -41,20 +42,24 @@ public SyndicationElementExtension(XmlReader xmlReader) _bufferElementIndex = 0; } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public SyndicationElementExtension(object dataContractExtension) : this(dataContractExtension, (XmlObjectSerializer)null) { } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public SyndicationElementExtension(object dataContractExtension, XmlObjectSerializer dataContractSerializer) : this(null, null, dataContractExtension, dataContractSerializer) { } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] 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) { if (dataContractExtension is null) @@ -74,6 +79,8 @@ public SyndicationElementExtension(string outerName, string outerNamespace, obje _extensionDataWriter = new ExtensionDataWriter(_extensionData, dataContractSerializer, _outerName, _outerNamespace); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public SyndicationElementExtension(object xmlSerializerExtension, XmlSerializer serializer) { if (xmlSerializerExtension is null) @@ -96,6 +103,8 @@ internal SyndicationElementExtension(XmlBuffer buffer, int bufferElementIndex, s public string OuterName { + [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) @@ -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) @@ -120,8 +131,12 @@ public string OuterNamespace } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TExtension GetObject() => GetObject(new DataContractSerializer(typeof(TExtension))); + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TExtension GetObject(XmlObjectSerializer serializer) { if (serializer is null) @@ -139,6 +154,8 @@ public TExtension GetObject(XmlObjectSerializer serializer) } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TExtension GetObject(XmlSerializer serializer) { if (serializer is null) @@ -174,6 +191,8 @@ public XmlReader GetReader() return reader; } + [UnconditionalSuppressMessage("Trimming", "IL2026:RequiresUnreferencedCode", Justification = "Constructors not marked RequiresUnreferencedCode always set _extensionDataWriter to null.")] + [UnconditionalSuppressMessage("AOT", "IL3050:RequiresDynamicCode", Justification = "Constructors not marked RequiresUnreferencedCode always set _extensionDataWriter to null.")] public void WriteTo(XmlWriter writer) { if (writer is null) @@ -211,6 +230,8 @@ private void EnsureBuffer() } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] private void EnsureOuterNameAndNs() { Debug.Assert(_extensionDataWriter != null, "outer name is null only for datacontract and xmlserializer cases"); @@ -242,6 +263,8 @@ public ExtensionDataWriter(object extensionData, XmlSerializer serializer) _extensionData = extensionData; } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public void WriteTo(XmlWriter writer) { if (_xmlSerializer != null) @@ -265,6 +288,8 @@ public void WriteTo(XmlWriter writer) } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] internal void ComputeOuterNameAndNs(out string name, out string ns) { Debug.Assert(_outerName == null, "All callers of this function should already check for a null outer name."); @@ -302,6 +327,8 @@ internal void ComputeOuterNameAndNs(out string name, out string ns) } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] internal void ReadOuterNameAndNs(out string name, out string ns) { using (MemoryStream stream = new MemoryStream()) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtensionCollection.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtensionCollection.cs index f6530db583de52..c430092942dcc2 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtensionCollection.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationElementExtensionCollection.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Xml; using System.Xml.Serialization; @@ -39,6 +40,7 @@ internal SyndicationElementExtensionCollection(SyndicationElementExtensionCollec _initialized = true; } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public void Add(object extension) { if (extension is SyndicationElementExtension) @@ -51,16 +53,19 @@ public void Add(object extension) } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public void Add(string outerName, string outerNamespace, object dataContractExtension) { Add(outerName, outerNamespace, dataContractExtension, null); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public void Add(object dataContractExtension, DataContractSerializer serializer) { Add(null, null, dataContractExtension, serializer); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public void Add(string outerName, string outerNamespace, object dataContractExtension, XmlObjectSerializer dataContractSerializer) { if (dataContractExtension is null) @@ -72,6 +77,8 @@ public void Add(string outerName, string outerNamespace, object dataContractExte base.Add(new SyndicationElementExtension(outerName, outerNamespace, dataContractExtension, dataContractSerializer)); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public void Add(object xmlSerializerExtension, XmlSerializer serializer) { if (xmlSerializerExtension is null) @@ -101,11 +108,15 @@ public XmlReader GetReaderAtElementExtensions() return reader; } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public Collection ReadElementExtensions(string extensionName, string extensionNamespace) { return ReadElementExtensions(extensionName, extensionNamespace, new DataContractSerializer(typeof(TExtension))); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public Collection ReadElementExtensions(string extensionName, string extensionNamespace, XmlObjectSerializer serializer) { if (serializer is null) @@ -116,6 +127,8 @@ public Collection ReadElementExtensions(string extension return ReadExtensions(extensionName, extensionNamespace, serializer, null); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public Collection ReadElementExtensions(string extensionName, string extensionNamespace, XmlSerializer serializer) { if (serializer is null) @@ -235,6 +248,8 @@ private void PopulateElements() } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] private Collection ReadExtensions(string extensionName, string extensionNamespace, XmlObjectSerializer dcSerializer, XmlSerializer xmlSerializer) { if (string.IsNullOrEmpty(extensionName)) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs index 968cb3af12cbca..4cc0376bbb75b3 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Xml; @@ -10,6 +11,7 @@ namespace System.ServiceModel.Syndication { // NOTE: This class implements Clone so if you add any members, please update the copy ctor + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public class SyndicationFeed : IExtensibleSyndicationObject { private static readonly HashSet s_acceptedDays = new HashSet( diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeedFormatter.cs index b3e631745fd43d..3f22cabcf7d821 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeedFormatter.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; -using System.Globalization; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Xml; @@ -16,6 +16,10 @@ public abstract class SyndicationFeedFormatter { private SyndicationFeed _feed; + // Trimmer warning messages + internal const string RequiresUnreferencedCodeWarning = "Members from serialized and deserialized types may be trimmed if not referenced directly"; + internal const string RequiresDynamicCodeWarning = "Serialization and deserialization requires dynamic code generation"; + protected SyndicationFeedFormatter() { _feed = null; @@ -497,7 +501,7 @@ internal static void CreateBufferIfRequiredAndWriteNode(ref XmlBuffer buffer, re extWriter.WriteNode(reader, false); } - internal static SyndicationFeed CreateFeedInstance(Type feedType) + internal static SyndicationFeed CreateFeedInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type feedType) { if (feedType.Equals(typeof(SyndicationFeed))) { diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItem.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItem.cs index 625da27aaff4ed..e5ebf6e3609fc2 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItem.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItem.cs @@ -9,6 +9,7 @@ namespace System.ServiceModel.Syndication { // NOTE: This class implements Clone so if you add any members, please update the copy ctor + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public class SyndicationItem : IExtensibleSyndicationObject { private Collection _authors; diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItemFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItemFormatter.cs index c1f5dd064bcd3f..fe7579fbc2d6f8 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItemFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItemFormatter.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Xml; @@ -48,7 +49,7 @@ protected internal virtual void SetItem(SyndicationItem item) _item = item; } - internal static SyndicationItem CreateItemInstance(Type itemType) + internal static SyndicationItem CreateItemInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type itemType) { if (itemType.Equals(typeof(SyndicationItem))) { diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/XmlSyndicationContent.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/XmlSyndicationContent.cs index c9b5d4352840dd..80ef522b84512f 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/XmlSyndicationContent.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/XmlSyndicationContent.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; using System.Xml; using System.Xml.Serialization; @@ -53,12 +54,15 @@ public XmlSyndicationContent(XmlReader reader) _contentBuffer.Close(); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] public XmlSyndicationContent(string type, object dataContractExtension, XmlObjectSerializer dataContractSerializer) { _type = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type; Extension = new SyndicationElementExtension(dataContractExtension, dataContractSerializer); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public XmlSyndicationContent(string type, object xmlSerializerExtension, XmlSerializer serializer) { _type = string.IsNullOrEmpty(type) ? Atom10Constants.XmlMediaType : type; @@ -96,8 +100,12 @@ public XmlDictionaryReader GetReaderAtContent() return _contentBuffer.GetReader(0); } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TContent ReadContent() => ReadContent((DataContractSerializer)null); + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TContent ReadContent(XmlObjectSerializer dataContractSerializer) { dataContractSerializer ??= new DataContractSerializer(typeof(TContent)); @@ -117,6 +125,8 @@ public TContent ReadContent(XmlObjectSerializer dataContractSerializer } } + [RequiresUnreferencedCode(SyndicationFeedFormatter.RequiresUnreferencedCodeWarning)] + [RequiresDynamicCode(SyndicationFeedFormatter.RequiresDynamicCodeWarning)] public TContent ReadContent(XmlSerializer serializer) { serializer ??= new XmlSerializer(typeof(TContent));