You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@@ -3,7 +3,7 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ref\System.ServiceModel.Syndication.csproj">
|
||||
<SupportedFramework>net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
|
||||
<SupportedFramework>uap10.0.16299;net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\src\System.ServiceModel.Syndication.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}</ProjectGuid>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
|
||||
@@ -28,6 +29,7 @@
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
|
||||
@@ -7,8 +7,40 @@
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
public partial struct XmlDateTimeData
|
||||
{
|
||||
public XmlDateTimeData(string dateTimeString, System.Xml.XmlQualifiedName elementQualifiedName) { throw null; }
|
||||
public string DateTimeString { get; }
|
||||
public System.Xml.XmlQualifiedName ElementQualifiedName { get; }
|
||||
}
|
||||
public partial struct XmlUriData
|
||||
{
|
||||
public XmlUriData(string uriString, UriKind uriKind, System.Xml.XmlQualifiedName elementQualifiedName) { throw null; }
|
||||
public System.Xml.XmlQualifiedName ElementQualifiedName { get; }
|
||||
public System.UriKind UriKind { get; }
|
||||
public string UriString { get; }
|
||||
}
|
||||
public partial class SyndicationFeed
|
||||
{
|
||||
public System.ServiceModel.Syndication.SyndicationLink Documentation { get { throw null; } set { } }
|
||||
public System.Collections.ObjectModel.Collection<string> SkipDays { get { throw null; } }
|
||||
public System.Collections.ObjectModel.Collection<int> SkipHours { get { throw null; } }
|
||||
public System.ServiceModel.Syndication.SyndicationTextInput TextInput { get { throw null; } set { } }
|
||||
public System.TimeSpan? TimeToLive { get { throw null; } set { } }
|
||||
}
|
||||
public abstract partial class SyndicationFeedFormatter
|
||||
{
|
||||
|
||||
public System.ServiceModel.Syndication.TryParseDateTimeCallback DateTimeParser { get; set; }
|
||||
public System.ServiceModel.Syndication.TryParseUriCallback UriParser { get; set; }
|
||||
}
|
||||
public delegate bool TryParseDateTimeCallback(System.ServiceModel.Syndication.XmlDateTimeData data, out System.DateTimeOffset dateTimeOffset);
|
||||
public delegate bool TryParseUriCallback(System.ServiceModel.Syndication.XmlUriData data, out System.Uri uri);
|
||||
public partial class SyndicationTextInput
|
||||
{
|
||||
public string Description { get { throw null; } set { } }
|
||||
public System.ServiceModel.Syndication.SyndicationLink Link { get { throw null; } set { } }
|
||||
public string Name { get { throw null; } set { } }
|
||||
public string Title { get { throw null; } set { } }
|
||||
public SyndicationTextInput() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netfx-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
Compat issues with assembly System.ServiceModel.Syndication:
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.Documentation.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.Documentation.set(System.ServiceModel.Syndication.SyndicationLink)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.SkipDays.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.SkipHours.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.TextInput.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.TextInput.set(System.ServiceModel.Syndication.SyndicationTextInput)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.TimeToLive.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeed.TimeToLive.set(System.Nullable<System.TimeSpan>)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeedFormatter.DateTimeParser.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeedFormatter.DateTimeParser.set(System.ServiceModel.Syndication.TryParseDateTimeCallback)' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeedFormatter.UriParser.get()' does not exist in the implementation but it does exist in the contract.
|
||||
MembersMustExist : Member 'System.ServiceModel.Syndication.SyndicationFeedFormatter.UriParser.set(System.ServiceModel.Syndication.TryParseUriCallback)' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.ServiceModel.Syndication.SyndicationTextInput' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.ServiceModel.Syndication.TryParseDateTimeCallback' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.ServiceModel.Syndication.TryParseUriCallback' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.ServiceModel.Syndication.XmlDateTimeData' does not exist in the implementation but it does exist in the contract.
|
||||
TypesMustExist : Type 'System.ServiceModel.Syndication.XmlUriData' does not exist in the implementation but it does exist in the contract.
|
||||
Total Issues: 17
|
||||
@@ -105,15 +105,15 @@
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
@@ -138,6 +138,9 @@
|
||||
<data name="ErrorParsingItem" xml:space="preserve">
|
||||
<value>An error was encountered when parsing the item's XML. Refer to the inner exception for more details.</value>
|
||||
</data>
|
||||
<data name="ErrorParsingUri" xml:space="preserve">
|
||||
<value>An error was encountered when parsing a Uri value in the XML.</value>
|
||||
</data>
|
||||
<data name="ExtensionNameNotSpecified" xml:space="preserve">
|
||||
<value>The name of the extension element must be specified.</value>
|
||||
</data>
|
||||
@@ -151,7 +154,7 @@
|
||||
<value>The feed created a null category.</value>
|
||||
</data>
|
||||
<data name="FeedCreatedNullItem" xml:space="preserve">
|
||||
<value>=The feed created a null item.</value>
|
||||
<value>The feed created a null item.</value>
|
||||
</data>
|
||||
<data name="FeedCreatedNullPerson" xml:space="preserve">
|
||||
<value>The feed created a null person.</value>
|
||||
@@ -255,4 +258,10 @@
|
||||
<data name="XmlStartElementExpected" xml:space="preserve">
|
||||
<value>Start element expected. Found {0}.</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="InvalidSkipHourValue" xml:space="preserve">
|
||||
<value>Cannot parse string `{0}` as skip hour. The value for skip hours must be an integer betwen 0 and 23.</value>
|
||||
</data>
|
||||
<data name="InvalidTimeToLiveValue" xml:space="preserve">
|
||||
<value>The value for TimeToLive must be a non-negative whole number of minutes.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -5,11 +5,19 @@
|
||||
<AssemblyName>System.ServiceModel.Syndication</AssemblyName>
|
||||
<ProjectGuid>{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}</ProjectGuid>
|
||||
<NoWarn>$(NoWarn);1634;1691;649</NoWarn>
|
||||
<IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
|
||||
<OmitResources Condition="'$(TargetsNetFx)' == 'true'">true</OmitResources>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netfx-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup Condition="'$(TargetsNetFx)' != 'true'">
|
||||
<Compile Include="$(MsBuildThisFileDirectory)\**\*.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
@@ -71,7 +71,7 @@ namespace System.ServiceModel.Syndication
|
||||
_feedType = feedToWrite.GetType();
|
||||
}
|
||||
|
||||
internal override Func<string, string, string, DateTimeOffset> GetDefaultDateTimeParser()
|
||||
internal override TryParseDateTimeCallback GetDefaultDateTimeParser()
|
||||
{
|
||||
return DateTimeHelper.DefaultAtom10DateTimeParser;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
else if (reader.IsStartElement(Atom10Constants.LogoTag, Atom10Constants.Atom10Namespace))
|
||||
{
|
||||
result.ImageUrl = UriParser(reader.ReadElementString(), UriKind.RelativeOrAbsolute, Atom10Constants.LogoTag, Atom10Constants.Atom10Namespace);
|
||||
result.ImageUrl = UriFromString(reader.ReadElementString(), UriKind.RelativeOrAbsolute, Atom10Constants.LogoTag, Atom10Constants.Atom10Namespace, reader);
|
||||
}
|
||||
else if (reader.IsStartElement(Atom10Constants.RightsTag, Atom10Constants.Atom10Namespace))
|
||||
{
|
||||
@@ -728,7 +728,7 @@ namespace System.ServiceModel.Syndication
|
||||
|
||||
if (!string.IsNullOrEmpty(src))
|
||||
{
|
||||
result = new UrlSyndicationContent(UriParser(src, UriKind.RelativeOrAbsolute, Atom10Constants.ContentTag, Atom10Constants.Atom10Namespace), type);
|
||||
result = new UrlSyndicationContent(UriFromString(src, UriKind.RelativeOrAbsolute, Atom10Constants.ContentTag, Atom10Constants.Atom10Namespace, reader), type);
|
||||
bool isEmpty = reader.IsEmptyElement;
|
||||
if (reader.HasAttributes)
|
||||
{
|
||||
@@ -1081,7 +1081,7 @@ namespace System.ServiceModel.Syndication
|
||||
link.MediaType = mediaType;
|
||||
link.RelationshipType = relationship;
|
||||
link.Title = title;
|
||||
link.Uri = (val != null) ? UriParser(val, UriKind.RelativeOrAbsolute, Atom10Constants.LinkTag, Atom10Constants.Atom10Namespace) : null;
|
||||
link.Uri = (val != null) ? UriFromString(val, UriKind.RelativeOrAbsolute, Atom10Constants.LinkTag, Atom10Constants.Atom10Namespace, reader) : null;
|
||||
}
|
||||
|
||||
private SyndicationLink ReadLinkFrom(XmlReader reader, SyndicationFeed feed)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
@@ -11,44 +12,39 @@ namespace System.ServiceModel.Syndication
|
||||
{
|
||||
private const string Rfc3339DateTimeFormat = "yyyy-MM-ddTHH:mm:ssK";
|
||||
|
||||
public static DateTimeOffset DefaultRss20DateTimeParser(string dateTimeString, string localName, string ns)
|
||||
public static bool DefaultRss20DateTimeParser(XmlDateTimeData XmlDateTimeData, out DateTimeOffset dateTimeOffset)
|
||||
{
|
||||
DateTimeOffset dto;
|
||||
string dateTimeString = XmlDateTimeData.DateTimeString;
|
||||
|
||||
// First check if DateTimeOffset default parsing can parse the date
|
||||
if (DateTimeOffset.TryParse(dateTimeString, out dto))
|
||||
if (DateTimeOffset.TryParse(dateTimeString, out dateTimeOffset))
|
||||
{
|
||||
return dto;
|
||||
return true;
|
||||
}
|
||||
|
||||
// RSS specifies RFC822
|
||||
if (Rfc822DateTimeParser(dateTimeString, out dto))
|
||||
if (Rfc822DateTimeParser(dateTimeString, out dateTimeOffset))
|
||||
{
|
||||
return dto;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Event though RCS3339 is for Atom, someone might be using this for RSS
|
||||
if (Rfc3339DateTimeParser(dateTimeString, out dto))
|
||||
if (Rfc3339DateTimeParser(dateTimeString, out dateTimeOffset))
|
||||
{
|
||||
return dto;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unable to parse - using a default date;
|
||||
throw new FormatException(SR.ErrorParsingDateTime);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static DateTimeOffset DefaultAtom10DateTimeParser(string dateTimeString, string localName, string ns)
|
||||
public static bool DefaultAtom10DateTimeParser(XmlDateTimeData XmlDateTimeData, out DateTimeOffset dateTimeOffset)
|
||||
{
|
||||
if (Rfc3339DateTimeParser(dateTimeString, out DateTimeOffset dto))
|
||||
{
|
||||
return dto;
|
||||
}
|
||||
|
||||
throw new FormatException(SR.ErrorParsingDateTime);
|
||||
return Rfc3339DateTimeParser(XmlDateTimeData.DateTimeString, out dateTimeOffset);
|
||||
}
|
||||
|
||||
private static bool Rfc3339DateTimeParser(string dateTimeString, out DateTimeOffset dto)
|
||||
{
|
||||
dto = default(DateTimeOffset);
|
||||
dateTimeString = dateTimeString.Trim();
|
||||
if (dateTimeString.Length < 20)
|
||||
{
|
||||
@@ -72,6 +68,7 @@ namespace System.ServiceModel.Syndication
|
||||
|
||||
private static bool Rfc822DateTimeParser(string dateTimeString, out DateTimeOffset dto)
|
||||
{
|
||||
dto = default(DateTimeOffset);
|
||||
StringBuilder dateTimeStringBuilder = new StringBuilder(dateTimeString.Trim());
|
||||
if (dateTimeStringBuilder.Length < 18)
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
}
|
||||
|
||||
internal void WriteElementExtensions(XmlWriter writer)
|
||||
internal void WriteElementExtensions(XmlWriter writer, Func<string, string, bool> shouldSkipElement = null)
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
if (_elementExtensions != null)
|
||||
{
|
||||
_elementExtensions.WriteTo(writer);
|
||||
_elementExtensions.WriteTo(writer, shouldSkipElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,5 +34,13 @@ namespace System.ServiceModel.Syndication
|
||||
public const string UrlTag = "url";
|
||||
public const string Version = "2.0";
|
||||
public const string VersionTag = "version";
|
||||
public const string DocumentationTag = "docs";
|
||||
public const string TimeToLiveTag = "ttl";
|
||||
public const string TextInputTag = "textInput";
|
||||
public const string SkipHoursTag = "skipHours";
|
||||
public const string SkipDaysTag = "skipDays";
|
||||
public const string HourTag = "hour";
|
||||
public const string DayTag = "day";
|
||||
public const string NameTag = "name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace System.ServiceModel.Syndication
|
||||
_feedType = feedToWrite.GetType();
|
||||
}
|
||||
|
||||
internal override Func<string, string, string, DateTimeOffset> GetDefaultDateTimeParser()
|
||||
internal override TryParseDateTimeCallback GetDefaultDateTimeParser()
|
||||
{
|
||||
return DateTimeHelper.DefaultRss20DateTimeParser;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
}
|
||||
|
||||
private SyndicationLink ReadAlternateLink(XmlReader reader, Uri baseUri)
|
||||
internal static SyndicationLink ReadAlternateLink(XmlReader reader, Uri baseUri, TryParseUriCallback uriParser, bool preserveAttributeExtensions)
|
||||
{
|
||||
SyndicationLink link = new SyndicationLink();
|
||||
link.BaseUri = baseUri;
|
||||
@@ -290,7 +290,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
else if (!FeedUtils.IsXmlns(reader.LocalName, reader.NamespaceURI))
|
||||
{
|
||||
if (this.PreserveAttributeExtensions)
|
||||
if (preserveAttributeExtensions)
|
||||
{
|
||||
link.AttributeExtensions.Add(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI), reader.Value);
|
||||
}
|
||||
@@ -302,8 +302,9 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
}
|
||||
|
||||
string uri = reader.ReadElementString();
|
||||
link.Uri = UriParser(uri, UriKind.RelativeOrAbsolute, Rss20Constants.LinkTag, Rss20Constants.Rss20Namespace);
|
||||
string uriString = reader.ReadElementString();
|
||||
Uri uri = UriFromString(uriParser, uriString, UriKind.RelativeOrAbsolute, Rss20Constants.LinkTag, Rss20Constants.Rss20Namespace, reader);
|
||||
link.Uri = uri;
|
||||
return link;
|
||||
}
|
||||
|
||||
@@ -421,7 +422,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
else if (reader.IsStartElement(Rss20Constants.LinkTag, Rss20Constants.Rss20Namespace))
|
||||
{
|
||||
result.Links.Add(ReadAlternateLink(reader, result.BaseUri));
|
||||
result.Links.Add(ReadAlternateLink(reader, result.BaseUri, UriParser, PreserveAttributeExtensions));
|
||||
readAlternateLink = true;
|
||||
}
|
||||
else if (reader.IsStartElement(Rss20Constants.DescriptionTag, Rss20Constants.Rss20Namespace))
|
||||
@@ -494,7 +495,7 @@ namespace System.ServiceModel.Syndication
|
||||
string val = reader.Value;
|
||||
if (name == Rss20Constants.UrlTag && ns == Rss20Constants.Rss20Namespace)
|
||||
{
|
||||
feed.Links.Add(SyndicationLink.CreateSelfLink(UriParser(val, UriKind.RelativeOrAbsolute, Rss20Constants.UrlTag, Rss20Constants.Rss20Namespace)));
|
||||
feed.Links.Add(SyndicationLink.CreateSelfLink(UriFromString(val, UriKind.RelativeOrAbsolute, Rss20Constants.UrlTag, Rss20Constants.Rss20Namespace, reader)));
|
||||
}
|
||||
else if (!FeedUtils.IsXmlns(name, ns))
|
||||
{
|
||||
@@ -547,7 +548,7 @@ namespace System.ServiceModel.Syndication
|
||||
reader.ReadEndElement(); // item
|
||||
if (!readAlternateLink && fallbackAlternateLink != null)
|
||||
{
|
||||
result.Links.Add(SyndicationLink.CreateAlternateLink(UriParser(fallbackAlternateLink, UriKind.RelativeOrAbsolute, fallbackAlternateLinkLocalName, fallbackAlternateLinkNamespace)));
|
||||
result.Links.Add(SyndicationLink.CreateAlternateLink(UriFromString(fallbackAlternateLink, UriKind.RelativeOrAbsolute, fallbackAlternateLinkLocalName, fallbackAlternateLinkNamespace, reader)));
|
||||
readAlternateLink = true;
|
||||
}
|
||||
|
||||
@@ -593,7 +594,7 @@ namespace System.ServiceModel.Syndication
|
||||
string val = reader.Value;
|
||||
if (name == Rss20Constants.UrlTag && ns == Rss20Constants.Rss20Namespace)
|
||||
{
|
||||
link.Uri = UriParser(val, UriKind.RelativeOrAbsolute, Rss20Constants.EnclosureTag, Rss20Constants.Rss20Namespace);
|
||||
link.Uri = UriFromString(val, UriKind.RelativeOrAbsolute, Rss20Constants.EnclosureTag, Rss20Constants.Rss20Namespace, reader);
|
||||
}
|
||||
else if (name == Rss20Constants.TypeTag && ns == Rss20Constants.Rss20Namespace)
|
||||
{
|
||||
@@ -737,7 +738,7 @@ namespace System.ServiceModel.Syndication
|
||||
|
||||
if (!string.IsNullOrEmpty(baseUri))
|
||||
{
|
||||
result.BaseUri = UriParser(baseUri, UriKind.RelativeOrAbsolute, baseUriLocalName, baseUriNamespace);
|
||||
result.BaseUri = UriFromString(baseUri, UriKind.RelativeOrAbsolute, baseUriLocalName, baseUriNamespace, reader);
|
||||
}
|
||||
|
||||
bool areAllItemsRead = true;
|
||||
@@ -757,7 +758,7 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
else if (reader.IsStartElement(Rss20Constants.LinkTag, Rss20Constants.Rss20Namespace))
|
||||
{
|
||||
result.Links.Add(ReadAlternateLink(reader, result.BaseUri));
|
||||
result.Links.Add(ReadAlternateLink(reader, result.BaseUri, UriParser, PreserveAttributeExtensions));
|
||||
}
|
||||
else if (reader.IsStartElement(Rss20Constants.DescriptionTag, Rss20Constants.Rss20Namespace))
|
||||
{
|
||||
@@ -811,7 +812,7 @@ namespace System.ServiceModel.Syndication
|
||||
{
|
||||
if (reader.IsStartElement(Rss20Constants.UrlTag, Rss20Constants.Rss20Namespace))
|
||||
{
|
||||
result.ImageUrl = UriParser(reader.ReadElementString(), UriKind.RelativeOrAbsolute, Rss20Constants.UrlTag, Rss20Constants.Rss20Namespace);
|
||||
result.ImageUrl = UriFromString(reader.ReadElementString(), UriKind.RelativeOrAbsolute, Rss20Constants.UrlTag, Rss20Constants.Rss20Namespace, reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1025,6 +1026,53 @@ namespace System.ServiceModel.Syndication
|
||||
writer.WriteEndElement(); // image
|
||||
}
|
||||
|
||||
// Optional spec items
|
||||
if (Feed.InternalDocumentation?.Uri != null)
|
||||
{
|
||||
writer.WriteElementString(Rss20Constants.DocumentationTag, Feed.InternalDocumentation.Uri.ToString());
|
||||
}
|
||||
|
||||
if (Feed.InternalTimeToLive != null)
|
||||
{
|
||||
writer.WriteElementString(Rss20Constants.TimeToLiveTag, ((int)Feed.InternalTimeToLive.Value.TotalMinutes).ToString());
|
||||
}
|
||||
|
||||
if (Feed.InternalSkipHours?.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(Rss20Constants.SkipHoursTag);
|
||||
|
||||
foreach (int hour in Feed.InternalSkipHours)
|
||||
{
|
||||
writer.WriteElementString(Rss20Constants.HourTag, hour.ToString());
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
if (Feed.InternalSkipDays?.Count > 0)
|
||||
{
|
||||
writer.WriteStartElement(Rss20Constants.SkipDaysTag);
|
||||
|
||||
foreach (string day in Feed.InternalSkipDays)
|
||||
{
|
||||
writer.WriteElementString(Rss20Constants.DayTag, day);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
if (Feed.InternalTextInput != null)
|
||||
{
|
||||
writer.WriteStartElement(Rss20Constants.TextInputTag);
|
||||
|
||||
writer.WriteElementString(Rss20Constants.DescriptionTag, Feed.InternalTextInput.Description);
|
||||
writer.WriteElementString(Rss20Constants.TitleTag, Feed.InternalTextInput.Title);
|
||||
writer.WriteElementString(Rss20Constants.LinkTag, Feed.InternalTextInput.Link.GetAbsoluteUri().ToString());
|
||||
writer.WriteElementString(Rss20Constants.NameTag, Feed.InternalTextInput.Name);
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
if (_serializeExtensionsAsAtom)
|
||||
{
|
||||
_atomSerializer.WriteElement(writer, Atom10Constants.IdTag, this.Feed.Id);
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace System.ServiceModel.Syndication
|
||||
return ReadExtensions<TExtension>(extensionName, extensionNamespace, null, serializer);
|
||||
}
|
||||
|
||||
internal void WriteTo(XmlWriter writer)
|
||||
internal void WriteTo(XmlWriter writer, Func<string, string, bool> shouldSkipElement)
|
||||
{
|
||||
if (_buffer != null)
|
||||
{
|
||||
@@ -142,6 +142,12 @@ namespace System.ServiceModel.Syndication
|
||||
reader.ReadStartElement();
|
||||
while (reader.IsStartElement())
|
||||
{
|
||||
if (shouldSkipElement != null && shouldSkipElement(reader.LocalName, reader.NamespaceURI))
|
||||
{
|
||||
reader.Skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
writer.WriteNode(reader, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Globalization;
|
||||
using System.Xml.Serialization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
// NOTE: This class implements Clone so if you add any members, please update the copy ctor
|
||||
public class SyndicationFeed : IExtensibleSyndicationObject
|
||||
{
|
||||
private static readonly HashSet<string> s_acceptedDays = new HashSet<string>(
|
||||
new string[] { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday" },
|
||||
StringComparer.OrdinalIgnoreCase
|
||||
);
|
||||
|
||||
private Collection<SyndicationPerson> _authors;
|
||||
private Uri _baseUri;
|
||||
private Collection<SyndicationCategory> _categories;
|
||||
@@ -34,6 +34,13 @@ namespace System.ServiceModel.Syndication
|
||||
private Collection<SyndicationLink> _links;
|
||||
private TextSyndicationContent _title;
|
||||
|
||||
// optional RSS tags
|
||||
private SyndicationLink _documentation;
|
||||
private TimeSpan? _timeToLive;
|
||||
private Collection<int> _skipHours;
|
||||
private Collection<string> _skipDays;
|
||||
private SyndicationTextInput _textInput;
|
||||
|
||||
public SyndicationFeed()
|
||||
: this((IEnumerable<SyndicationItem>)null)
|
||||
{
|
||||
@@ -265,6 +272,273 @@ namespace System.ServiceModel.Syndication
|
||||
set { _title = value; }
|
||||
}
|
||||
|
||||
internal SyndicationLink InternalDocumentation => _documentation;
|
||||
|
||||
public SyndicationLink Documentation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_documentation == null)
|
||||
{
|
||||
_documentation = TryReadDocumentationFromExtension(ElementExtensions);
|
||||
}
|
||||
|
||||
return _documentation;
|
||||
}
|
||||
set
|
||||
{
|
||||
_documentation = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal TimeSpan? InternalTimeToLive => _timeToLive;
|
||||
|
||||
public TimeSpan? TimeToLive
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_timeToLive.HasValue)
|
||||
{
|
||||
_timeToLive = TryReadTimeToLiveFromExtension(ElementExtensions);
|
||||
}
|
||||
|
||||
return _timeToLive;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue && (value.Value.Milliseconds != 0 || value.Value.Seconds != 0 || value.Value.TotalMinutes < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value.Value, SR.InvalidTimeToLiveValue);
|
||||
}
|
||||
|
||||
_timeToLive = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal Collection<int> InternalSkipHours => _skipHours;
|
||||
|
||||
public Collection<int> SkipHours
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_skipHours == null)
|
||||
{
|
||||
var skipHours = new Collection<int>();
|
||||
TryReadSkipHoursFromExtension(ElementExtensions, skipHours);
|
||||
_skipHours = skipHours;
|
||||
}
|
||||
|
||||
return _skipHours;
|
||||
}
|
||||
}
|
||||
|
||||
internal Collection<string> InternalSkipDays => _skipDays;
|
||||
|
||||
public Collection<string> SkipDays
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_skipDays == null)
|
||||
{
|
||||
var skipDays = new Collection<string>();
|
||||
TryReadSkipDaysFromExtension(ElementExtensions, skipDays);
|
||||
_skipDays = skipDays;
|
||||
}
|
||||
|
||||
return _skipDays;
|
||||
}
|
||||
}
|
||||
|
||||
internal SyndicationTextInput InternalTextInput => _textInput;
|
||||
|
||||
public SyndicationTextInput TextInput
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_textInput == null)
|
||||
{
|
||||
_textInput = TryReadTextInputFromExtension(ElementExtensions);
|
||||
}
|
||||
|
||||
return _textInput;
|
||||
}
|
||||
set
|
||||
{
|
||||
_textInput = value;
|
||||
}
|
||||
}
|
||||
|
||||
private SyndicationLink TryReadDocumentationFromExtension(SyndicationElementExtensionCollection elementExtensions)
|
||||
{
|
||||
SyndicationElementExtension documentationElement = elementExtensions
|
||||
.Where(e => e.OuterName == Rss20Constants.DocumentationTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (documentationElement == null)
|
||||
return null;
|
||||
|
||||
using (XmlReader reader = documentationElement.GetReader())
|
||||
{
|
||||
SyndicationLink documentation = Rss20FeedFormatter.ReadAlternateLink(reader, BaseUri, SyndicationFeedFormatter.DefaultUriParser, preserveAttributeExtensions: true);
|
||||
return documentation;
|
||||
}
|
||||
}
|
||||
|
||||
private TimeSpan? TryReadTimeToLiveFromExtension(SyndicationElementExtensionCollection elementExtensions)
|
||||
{
|
||||
SyndicationElementExtension timeToLiveElement = elementExtensions
|
||||
.FirstOrDefault(e => e.OuterName == Rss20Constants.TimeToLiveTag && e.OuterNamespace == Rss20Constants.Rss20Namespace);
|
||||
|
||||
if (timeToLiveElement == null)
|
||||
return null;
|
||||
|
||||
using (XmlReader reader = timeToLiveElement.GetReader())
|
||||
{
|
||||
string value = reader.ReadElementString();
|
||||
if (int.TryParse(value, out int timeToLive))
|
||||
{
|
||||
if (timeToLive >= 0)
|
||||
{
|
||||
return TimeSpan.FromMinutes(timeToLive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TryReadSkipHoursFromExtension(SyndicationElementExtensionCollection elementExtensions, Collection<int> skipHours)
|
||||
{
|
||||
SyndicationElementExtension skipHoursElement = elementExtensions
|
||||
.Where(e => e.OuterName == Rss20Constants.SkipHoursTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (skipHoursElement == null)
|
||||
return;
|
||||
|
||||
using (XmlReader reader = skipHoursElement.GetReader())
|
||||
{
|
||||
reader.ReadStartElement();
|
||||
|
||||
while (reader.IsStartElement())
|
||||
{
|
||||
if (reader.LocalName == Rss20Constants.HourTag)
|
||||
{
|
||||
string value = reader.ReadElementString();
|
||||
int hour;
|
||||
bool parsed = int.TryParse(value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out hour);
|
||||
|
||||
if (!parsed || (hour < 0 || hour > 23))
|
||||
{
|
||||
throw new FormatException(string.Format(SR.InvalidSkipHourValue, value));
|
||||
}
|
||||
|
||||
skipHours.Add(hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TryReadSkipDaysFromExtension(SyndicationElementExtensionCollection elementExtensions, Collection<string> skipDays)
|
||||
{
|
||||
SyndicationElementExtension skipDaysElement = elementExtensions
|
||||
.Where(e => e.OuterName == Rss20Constants.SkipDaysTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (skipDaysElement == null)
|
||||
return;
|
||||
|
||||
using (XmlReader reader = skipDaysElement.GetReader())
|
||||
{
|
||||
reader.ReadStartElement();
|
||||
|
||||
while (reader.IsStartElement())
|
||||
{
|
||||
if (reader.LocalName == Rss20Constants.DayTag)
|
||||
{
|
||||
string day = reader.ReadElementString();
|
||||
|
||||
//Check if the day is actually an accepted day.
|
||||
if (IsValidDay(day))
|
||||
{
|
||||
skipDays.Add(day);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsValidDay(string day) => s_acceptedDays.Contains(day);
|
||||
|
||||
private SyndicationTextInput TryReadTextInputFromExtension(SyndicationElementExtensionCollection elementExtensions)
|
||||
{
|
||||
SyndicationElementExtension textInputElement = elementExtensions
|
||||
.Where(e => e.OuterName == Rss20Constants.TextInputTag && e.OuterNamespace == Rss20Constants.Rss20Namespace)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (textInputElement == null)
|
||||
return null;
|
||||
|
||||
var textInput = new SyndicationTextInput();
|
||||
using (XmlReader reader = textInputElement.GetReader())
|
||||
{
|
||||
reader.ReadStartElement();
|
||||
while (reader.IsStartElement())
|
||||
{
|
||||
string name = reader.LocalName;
|
||||
string value = reader.ReadElementString();
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case Rss20Constants.DescriptionTag:
|
||||
textInput.Description = value;
|
||||
break;
|
||||
|
||||
case Rss20Constants.TitleTag:
|
||||
textInput.Title = value;
|
||||
break;
|
||||
|
||||
case Rss20Constants.LinkTag:
|
||||
textInput.Link = new SyndicationLink(new Uri(value, UriKind.RelativeOrAbsolute));
|
||||
break;
|
||||
|
||||
case Rss20Constants.NameTag:
|
||||
textInput.Name = value;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
}
|
||||
|
||||
return IsValidTextInput(textInput) ? textInput : null;
|
||||
}
|
||||
|
||||
private static bool IsValidTextInput(SyndicationTextInput textInput)
|
||||
{
|
||||
//All textInput items are required, we check if all items were instantiated.
|
||||
return textInput.Description != null && textInput.Title != null && textInput.Name != null && textInput.Link != null;
|
||||
}
|
||||
|
||||
public static SyndicationFeed Load(XmlReader reader)
|
||||
{
|
||||
return Load<SyndicationFeed>(reader);
|
||||
@@ -359,7 +633,33 @@ namespace System.ServiceModel.Syndication
|
||||
|
||||
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
|
||||
{
|
||||
_extensions.WriteElementExtensions(writer);
|
||||
_extensions.WriteElementExtensions(writer, ShouldSkipWritingElements);
|
||||
}
|
||||
|
||||
private bool ShouldSkipWritingElements(string localName, string ns)
|
||||
{
|
||||
if (ns == Rss20Constants.Rss20Namespace)
|
||||
{
|
||||
switch (localName)
|
||||
{
|
||||
case Rss20Constants.DocumentationTag:
|
||||
return InternalDocumentation != null;
|
||||
|
||||
case Rss20Constants.TimeToLiveTag:
|
||||
return InternalTimeToLive != null;
|
||||
|
||||
case Rss20Constants.TextInputTag:
|
||||
return InternalTextInput != null;
|
||||
|
||||
case Rss20Constants.SkipHoursTag:
|
||||
return InternalSkipHours != null;
|
||||
|
||||
case Rss20Constants.SkipDaysTag:
|
||||
return InternalSkipDays != null;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace System.ServiceModel.Syndication
|
||||
using System.Xml;
|
||||
using DiagnosticUtility = System.ServiceModel.DiagnosticUtility;
|
||||
|
||||
public delegate bool TryParseDateTimeCallback(XmlDateTimeData data, out DateTimeOffset dateTimeOffset);
|
||||
public delegate bool TryParseUriCallback(XmlUriData data, out Uri uri);
|
||||
|
||||
[DataContract]
|
||||
public abstract class SyndicationFeedFormatter
|
||||
{
|
||||
@@ -40,19 +43,20 @@ namespace System.ServiceModel.Syndication
|
||||
}
|
||||
}
|
||||
|
||||
public Func<string, UriKind, string, string, Uri> UriParser { get; set; } = DefaultUriParser;
|
||||
public TryParseUriCallback UriParser { get; set; } = DefaultUriParser;
|
||||
|
||||
// Different DateTimeParsers are needed for Atom and Rss so can't set inline
|
||||
public Func<string, string, string, DateTimeOffset> DateTimeParser { get; set; }
|
||||
public TryParseDateTimeCallback DateTimeParser { get; set; }
|
||||
|
||||
internal virtual Func<string, string, string, DateTimeOffset> GetDefaultDateTimeParser()
|
||||
internal virtual TryParseDateTimeCallback GetDefaultDateTimeParser()
|
||||
{
|
||||
return NotImplementedDateTimeParser;
|
||||
}
|
||||
|
||||
private DateTimeOffset NotImplementedDateTimeParser(string dtoString, string localName, string ns)
|
||||
private bool NotImplementedDateTimeParser(XmlDateTimeData XmlDateTimeData, out DateTimeOffset dateTimeOffset)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
dateTimeOffset = default(DateTimeOffset);
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract string Version
|
||||
@@ -391,22 +395,69 @@ namespace System.ServiceModel.Syndication
|
||||
_feed = feed;
|
||||
}
|
||||
|
||||
internal Uri UriFromString(string uriString, UriKind uriKind, string localName, string namespaceURI, XmlReader reader)
|
||||
{
|
||||
return UriFromString(UriParser, uriString, uriKind, localName, namespaceURI, reader);
|
||||
}
|
||||
|
||||
internal static Uri UriFromString(TryParseUriCallback uriParser, string uriString, UriKind uriKind, string localName, string namespaceURI, XmlReader reader)
|
||||
{
|
||||
Uri uri = null;
|
||||
var elementQualifiedName = new XmlQualifiedName(localName, namespaceURI);
|
||||
var xmlUriData = new XmlUriData(uriString, uriKind, elementQualifiedName);
|
||||
object[] args = new object[] { xmlUriData, uri };
|
||||
try
|
||||
{
|
||||
foreach (Delegate parser in uriParser.GetInvocationList())
|
||||
{
|
||||
if ((bool)parser.Method.Invoke(parser.Target, args))
|
||||
{
|
||||
uri = (Uri)args[args.Length - 1];
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingUri), e));
|
||||
}
|
||||
|
||||
DefaultUriParser(xmlUriData, out uri);
|
||||
return uri;
|
||||
}
|
||||
|
||||
internal DateTimeOffset DateFromString(string dateTimeString, XmlReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DateTimeParser(dateTimeString, reader.LocalName, reader.NamespaceURI);
|
||||
DateTimeOffset dateTimeOffset = default(DateTimeOffset);
|
||||
var elementQualifiedName = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI);
|
||||
var xmlDateTimeData = new XmlDateTimeData(dateTimeString, elementQualifiedName);
|
||||
object[] args = new object[] { xmlDateTimeData, dateTimeOffset };
|
||||
foreach (Delegate dateTimeParser in DateTimeParser.GetInvocationList())
|
||||
{
|
||||
if ((bool)dateTimeParser.Method.Invoke(dateTimeParser.Target, args))
|
||||
{
|
||||
dateTimeOffset = (DateTimeOffset)args[args.Length - 1];
|
||||
return dateTimeOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FormatException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDateTime), e));
|
||||
}
|
||||
|
||||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
|
||||
new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDateTime)));
|
||||
}
|
||||
|
||||
private static Uri DefaultUriParser(string value, UriKind kind, string localName, string ns)
|
||||
internal static bool DefaultUriParser(XmlUriData XmlUriData, out Uri uri)
|
||||
{
|
||||
return new Uri(value, kind);
|
||||
uri = new Uri(XmlUriData.UriString, XmlUriData.UriKind);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void CloseBuffer(XmlBuffer buffer, XmlDictionaryWriter extWriter)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
public class SyndicationTextInput
|
||||
{
|
||||
public string Description { get; set; }
|
||||
public string Title { get; set; }
|
||||
public SyndicationLink Link { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
public struct XmlDateTimeData
|
||||
{
|
||||
public XmlDateTimeData(string dateTimeString, XmlQualifiedName elementQualifiedName)
|
||||
{
|
||||
DateTimeString = dateTimeString;
|
||||
ElementQualifiedName = elementQualifiedName;
|
||||
}
|
||||
|
||||
public string DateTimeString { get; }
|
||||
|
||||
public XmlQualifiedName ElementQualifiedName { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Xml;
|
||||
|
||||
namespace System.ServiceModel.Syndication
|
||||
{
|
||||
public struct XmlUriData
|
||||
{
|
||||
public XmlUriData(string uriString, UriKind uriKind, XmlQualifiedName elementQualifiedName)
|
||||
{
|
||||
UriString = uriString;
|
||||
UriKind = uriKind;
|
||||
ElementQualifiedName = elementQualifiedName;
|
||||
}
|
||||
|
||||
public XmlQualifiedName ElementQualifiedName { get; }
|
||||
|
||||
public UriKind UriKind { get; }
|
||||
|
||||
public string UriString { get; }
|
||||
}
|
||||
}
|
||||
@@ -23,15 +23,16 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
try
|
||||
{
|
||||
// *** SETUP *** \\
|
||||
SyndicationFeed sf = new SyndicationFeed("First feed on .net core ever!!", "This is the first feed on .net core ever!", new Uri("https://github.com/dotnet/wcf"));
|
||||
var sf = new SyndicationFeed("First feed on .net core ever!!", "This is the first feed on .net core ever!", new Uri("https://github.com/dotnet/wcf"));
|
||||
Assert.True(sf != null);
|
||||
|
||||
XmlWriter xmlw = XmlWriter.Create(filePath);
|
||||
Rss20FeedFormatter rssf = new Rss20FeedFormatter(sf);
|
||||
using (XmlWriter xmlw = XmlWriter.Create(filePath))
|
||||
{
|
||||
var rssf = new Rss20FeedFormatter(sf);
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
rssf.WriteTo(xmlw);
|
||||
xmlw.Close();
|
||||
// *** EXECUTE *** \\
|
||||
rssf.WriteTo(xmlw);
|
||||
}
|
||||
|
||||
// *** VALIDATE *** \\
|
||||
Assert.True(File.Exists(filePath));
|
||||
@@ -51,16 +52,20 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
try
|
||||
{
|
||||
// *** SETUP *** \\\
|
||||
XmlReader xmlr = XmlReader.Create(@"SimpleRssFeed.xml");
|
||||
SyndicationFeed sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
SyndicationFeed sf;
|
||||
using (XmlReader xmlr = XmlReader.Create(@"SimpleRssFeed.xml"))
|
||||
{
|
||||
sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
}
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
//Write the same feed that was read.
|
||||
XmlWriter xmlw = XmlWriter.Create(path);
|
||||
Rss20FeedFormatter atomFeed = new Rss20FeedFormatter(sf);
|
||||
atomFeed.WriteTo(xmlw);
|
||||
xmlw.Close();
|
||||
using (XmlWriter xmlw = XmlWriter.Create(path))
|
||||
{
|
||||
var rss20FeedFormatter = new Rss20FeedFormatter(sf);
|
||||
rss20FeedFormatter.WriteTo(xmlw);
|
||||
}
|
||||
|
||||
// *** VALIDATE *** \\
|
||||
Assert.True(File.Exists(path));
|
||||
@@ -80,19 +85,21 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
try
|
||||
{
|
||||
// *** SETUP *** \\\
|
||||
XmlReaderSettings settingsReader = new XmlReaderSettings();
|
||||
XmlReader xmlr = XmlReader.Create(@"rssSpecExample.xml", settingsReader);
|
||||
SyndicationFeed sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
SyndicationFeed sf;
|
||||
using (XmlReader xmlr = XmlReader.Create(@"rssSpecExample.xml"))
|
||||
{
|
||||
sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
}
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
//Write the same feed that was read.
|
||||
XmlWriterSettings settingsWriter = new XmlWriterSettings();
|
||||
XmlWriter xmlw = XmlWriter.Create(path, settingsWriter);
|
||||
Rss20FeedFormatter atomFeed = new Rss20FeedFormatter(sf);
|
||||
atomFeed.WriteTo(xmlw);
|
||||
|
||||
xmlw.Close();
|
||||
using (XmlWriter xmlw = XmlWriter.Create(path, settingsWriter))
|
||||
{
|
||||
var rss20FeedFormatter = new Rss20FeedFormatter(sf);
|
||||
rss20FeedFormatter.WriteTo(xmlw);
|
||||
}
|
||||
|
||||
// *** VALIDATE *** \\
|
||||
Assert.True(File.Exists(path));
|
||||
@@ -112,17 +119,20 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
try
|
||||
{
|
||||
// *** SETUP *** \\\
|
||||
XmlReaderSettings setting = new XmlReaderSettings();
|
||||
XmlReader xmlr = XmlReader.Create(@"SimpleAtomFeed.xml", setting);
|
||||
SyndicationFeed sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
SyndicationFeed sf;
|
||||
using (XmlReader xmlr = XmlReader.Create(@"SimpleAtomFeed.xml"))
|
||||
{
|
||||
sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
}
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
//Write the same feed that was read.
|
||||
XmlWriter xmlw = XmlWriter.Create(path);
|
||||
Atom10FeedFormatter atomFeed = new Atom10FeedFormatter(sf);
|
||||
atomFeed.WriteTo(xmlw);
|
||||
xmlw.Close();
|
||||
using (XmlWriter xmlw = XmlWriter.Create(path))
|
||||
{
|
||||
var atom10FeedFormatter = new Atom10FeedFormatter(sf);
|
||||
atom10FeedFormatter.WriteTo(xmlw);
|
||||
}
|
||||
|
||||
// *** VALIDATE *** \\
|
||||
Assert.True(File.Exists(path));
|
||||
@@ -142,19 +152,20 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
try
|
||||
{
|
||||
// *** SETUP *** \\\
|
||||
XmlReaderSettings readerSettings = new XmlReaderSettings();
|
||||
XmlReader xmlr = XmlReader.Create(@"atom_spec_example.xml", readerSettings);
|
||||
SyndicationFeed sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
SyndicationFeed sf;
|
||||
using (XmlReader xmlr = XmlReader.Create(@"atom_spec_example.xml"))
|
||||
{
|
||||
sf = SyndicationFeed.Load(xmlr);
|
||||
Assert.True(sf != null);
|
||||
}
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
//Write the same feed that was read.
|
||||
XmlWriterSettings writerSettings = new XmlWriterSettings();
|
||||
|
||||
XmlWriter xmlw = XmlWriter.Create(path, writerSettings);
|
||||
Atom10FeedFormatter atomFeed = new Atom10FeedFormatter(sf);
|
||||
atomFeed.WriteTo(xmlw);
|
||||
xmlw.Close();
|
||||
using (XmlWriter xmlw = XmlWriter.Create(path))
|
||||
{
|
||||
var atom10FeedFormatter = new Atom10FeedFormatter(sf);
|
||||
atom10FeedFormatter.WriteTo(xmlw);
|
||||
}
|
||||
|
||||
// *** VALIDATE *** \\
|
||||
Assert.True(File.Exists(path));
|
||||
@@ -195,22 +206,19 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
feed.BaseUri = new Uri("http://mypage.com");
|
||||
|
||||
// Write to XML > rss
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
XmlWriter xmlwRss = XmlWriter.Create(RssPath, settings);
|
||||
Rss20FeedFormatter rssff = new Rss20FeedFormatter(feed);
|
||||
using (XmlWriter xmlwRss = XmlWriter.Create(RssPath))
|
||||
{
|
||||
Rss20FeedFormatter rssff = new Rss20FeedFormatter(feed);
|
||||
rssff.WriteTo(xmlwRss);
|
||||
}
|
||||
|
||||
// Write to XML > atom
|
||||
|
||||
XmlWriter xmlwAtom = XmlWriter.Create(AtomPath);
|
||||
Atom10FeedFormatter atomf = new Atom10FeedFormatter(feed);
|
||||
|
||||
|
||||
// *** EXECUTE *** \\
|
||||
rssff.WriteTo(xmlwRss);
|
||||
xmlwRss.Close();
|
||||
|
||||
atomf.WriteTo(xmlwAtom); ;
|
||||
xmlwAtom.Close();
|
||||
using (XmlWriter xmlwAtom = XmlWriter.Create(AtomPath))
|
||||
{
|
||||
Atom10FeedFormatter atomf = new Atom10FeedFormatter(feed);
|
||||
atomf.WriteTo(xmlwAtom);
|
||||
}
|
||||
|
||||
// *** ASSERT *** \\
|
||||
Assert.True(File.Exists(RssPath));
|
||||
@@ -247,6 +255,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Disjoint items not supported on NetFX")]
|
||||
public static void SyndicationFeed_Rss_TestDisjointItems()
|
||||
{
|
||||
using (XmlReader reader = XmlReader.Create(@"RssDisjointItems.xml"))
|
||||
@@ -267,6 +276,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Disjoint items not supported on NetFX")]
|
||||
public static void SyndicationFeed_Atom_TestDisjointItems()
|
||||
{
|
||||
using (XmlReader reader = XmlReader.Create(@"AtomDisjointItems.xml"))
|
||||
@@ -286,6 +296,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Deferred date exception throwing not implemented on NetFX")]
|
||||
public static void SyndicationFeed_Rss_WrongDateFormat()
|
||||
{
|
||||
// *** SETUP *** \\
|
||||
@@ -302,7 +313,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
SyndicationItem[] items = res.Items.ToArray();
|
||||
DateTimeOffset dateTimeOffset;
|
||||
Assert.Throws<XmlException>(() => dateTimeOffset = items[2].PublishDate);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void AtomEntryPositiveTest()
|
||||
@@ -487,7 +498,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
}
|
||||
}
|
||||
|
||||
private static void ReadWriteSyndicationFeed(string file, Func<SyndicationFeed, SyndicationFeedFormatter> feedFormatter, List<AllowableDifference> allowableDifferences = null)
|
||||
private static void ReadWriteSyndicationFeed(string file, Func<SyndicationFeed, SyndicationFeedFormatter> feedFormatter, List<AllowableDifference> allowableDifferences = null, Action<SyndicationFeed> verifySyndicationFeedRead = null)
|
||||
{
|
||||
string serializeFilePath = Path.GetTempFileName();
|
||||
bool toDeletedFile = true;
|
||||
@@ -500,6 +511,7 @@ namespace System.ServiceModel.Syndication.Tests
|
||||
using (XmlReader reader = XmlDictionaryReader.CreateTextReader(fileStream, XmlDictionaryReaderQuotas.Max))
|
||||
{
|
||||
feedObjct = SyndicationFeed.Load(reader);
|
||||
verifySyndicationFeedRead?.Invoke(feedObjct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
|
||||
<Compile Include="$(MsBuildThisFileDirectory)netcoreapp\**\*.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
|
||||
<ReferenceFromRuntime Include="System.ServiceModel.Syndication">
|
||||
<Private>true</Private>
|
||||
</ReferenceFromRuntime>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="$(MsBuildThisFileDirectory)\TestFeeds\**\*.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user