Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@@ -1,31 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26906.1
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication", "src\System.ServiceModel.Syndication.csproj", "{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication.Tests", "tests\System.ServiceModel.Syndication.Tests.csproj", "{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}"
ProjectSection(ProjectDependencies) = postProject
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74} = {C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication", "src\System.ServiceModel.Syndication.csproj", "{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}"
ProjectSection(ProjectDependencies) = postProject
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7} = {E81F4C7C-2000-4449-BEE6-B2E84DE218F7}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel.Syndication", "ref\System.ServiceModel.Syndication.csproj", "{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
netstandard-Debug|Any CPU = netstandard-Debug|Any CPU
netstandard-Release|Any CPU = netstandard-Release|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C509160C-D427-4B6F-A515-169B6BB2B210}
GlobalSection(NestedProjects) = preSolution
{A622B2C0-DD74-4218-9CF0-F9B2E52F4E91} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{C2AB129B-E3EC-465B-B1B7-0F7D414B1E74} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{E81F4C7C-2000-4449-BEE6-B2E84DE218F7} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
EndGlobal

View File

@@ -3,6 +3,7 @@
<PropertyGroup>
<BuildConfigurations>
netfx;
netcoreapp;
netstandard;
</BuildConfigurations>
</PropertyGroup>

View File

@@ -3,23 +3,31 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{E81F4C7C-2000-4449-BEE6-B2E84DE218F7}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netfx-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup>
<Compile Include="System.ServiceModel.Syndication.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Compile Include="System.ServiceModel.Syndication.netfx.cs" />
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="System.ServiceModel.Syndication.netcoreapp.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<ProjectReference Include="..\..\System.Collections\ref\System.Collections.csproj" />
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.Serialization.Primitives\ref\System.Runtime.Serialization.Primitives.csproj" />
<ProjectReference Include="..\..\System.Runtime.Serialization.Xml\ref\System.Runtime.Serialization.Xml.csproj" />
<ProjectReference Include="..\..\System.Xml.ReaderWriter\ref\System.Xml.ReaderWriter.csproj" />
<ProjectReference Include="..\..\System.Xml.XmlSerializer\ref\System.Xml.XmlSerializer.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<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" />

View File

@@ -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.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.ServiceModel.Syndication
{
public abstract partial class SyndicationFeedFormatter
{
}
}

View File

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</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="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Atom10SpecRequiresTextConstruct" xml:space="preserve">
<value>The Atom10 specification requires '{0}' to have one of these values: \"text\", \"html\", \"xhtml\", however this value is '{1}' in the document being deserialized.</value>
</data>
<data name="DocumentFormatterDoesNotHaveDocument" xml:space="preserve">
<value>The document formatter must be configured with a document.</value>
</data>
<data name="ErrorInLine" xml:space="preserve">
<value>Error in line {0} position {1}.</value>
</data>
<data name="ErrorParsingDateTime" xml:space="preserve">
<value>An error was encountered when parsing a DateTime value in the XML.</value>
</data>
<data name="ErrorParsingDocument" xml:space="preserve">
<value>An error was encountered when parsing the document's XML. Refer to the inner exception for more details.</value>
</data>
<data name="ErrorParsingFeed" xml:space="preserve">
<value>An error was encountered when parsing the feed's XML. Refer to the inner exception for more details.</value>
</data>
<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="ExtensionNameNotSpecified" xml:space="preserve">
<value>The name of the extension element must be specified.</value>
</data>
<data name="FeedAuthorsIgnoredOnWrite" xml:space="preserve">
<value>The feed's authors were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="FeedContributorsIgnoredOnWrite" xml:space="preserve">
<value>The feed's contributors were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="FeedCreatedNullCategory" xml:space="preserve">
<value>The feed created a null category.</value>
</data>
<data name="FeedCreatedNullItem" xml:space="preserve">
<value>=The feed created a null item.</value>
</data>
<data name="FeedCreatedNullPerson" xml:space="preserve">
<value>The feed created a null person.</value>
</data>
<data name="FeedFormatterDoesNotHaveFeed" xml:space="preserve">
<value>The syndication feed formatter must be configured with a syndication feed.</value>
</data>
<data name="FeedHasNonContiguousItems" xml:space="preserve">
<value>The feed being deserialized has non-contiguous sets of items in it. This is not supported by '{0}'.</value>
</data>
<data name="FeedIdIgnoredOnWrite" xml:space="preserve">
<value>The feed's id was not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="FeedLinksIgnoredOnWrite" xml:space="preserve">
<value>The feed's links were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="InvalidObjectTypePassed" xml:space="preserve">
<value>The Type of object passed as parameter '{0}' is not derived from {1}. Ensure that the type of object passed is either of type {1} or derived from {1}.</value>
</data>
<data name="ItemAuthorsIgnoredOnWrite" xml:space="preserve">
<value>The item's authors were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="ItemContentIgnoredOnWrite" xml:space="preserve">
<value>The item's content was not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="ItemContributorsIgnoredOnWrite" xml:space="preserve">
<value>The item's contributors were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="ItemCopyrightIgnoredOnWrite" xml:space="preserve">
<value>The item's copyrights were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="ItemCreatedNullCategory" xml:space="preserve">
<value>The item created a null category.</value>
</data>
<data name="ItemCreatedNullPerson" xml:space="preserve">
<value>The item created a null person.</value>
</data>
<data name="ItemFormatterDoesNotHaveItem" xml:space="preserve">
<value>The syndication item formatter must be configured with a syndication item.</value>
</data>
<data name="ItemLastUpdatedTimeIgnoredOnWrite" xml:space="preserve">
<value>The item's last updated time was not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="ItemLinksIgnoredOnWrite" xml:space="preserve">
<value>The item's links were not serialized as part of serializing the feed in RSS 2.0 format.</value>
</data>
<data name="OuterElementNameNotSpecified" xml:space="preserve">
<value>The outer element name must be specified.</value>
</data>
<data name="OuterNameOfElementExtensionEmpty" xml:space="preserve">
<value>The outer name of the element extension cannot be empty.</value>
</data>
<data name="UnbufferedItemsCannotBeCloned" xml:space="preserve">
<value>A feed containing items that are not buffered (i.e. the items are not stored in an IList) cannot clone its items. Buffer the items in the feed before calling Clone on it or pass false to the Clone method.</value>
</data>
<data name="UnknownDocumentXml" xml:space="preserve">
<value>The element with name '{0}' and namespace '{1}' is not an allowed document format.</value>
</data>
<data name="UnknownFeedXml" xml:space="preserve">
<value>The element with name '{0}' and namespace '{1}' is not an allowed feed format.</value>
</data>
<data name="UnknownItemXml" xml:space="preserve">
<value>The element with name '{0}' and namespace '{1}' is not an allowed item format.</value>
</data>
<data name="UnsupportedRssVersion" xml:space="preserve">
<value>The Rss20Serializer does not support RSS version '{0}'.</value>
</data>
<data name="UriGeneratorSchemeMustNotBeEmpty" xml:space="preserve">
<value>The scheme parameter must not be empty.</value>
</data>
<data name="ValueMustBeNonNegative" xml:space="preserve">
<value>The value of this argument must be non-negative.</value>
</data>
<data name="XmlBufferInInvalidState" xml:space="preserve">
<value>An internal error has occurred. The XML buffer is not in the correct state to perform the operation.</value>
</data>
<data name="XmlFoundCData" xml:space="preserve">
<value>cdata '{0}'</value>
</data>
<data name="XmlFoundComment" xml:space="preserve">
<value>comment '{0}'</value>
</data>
<data name="XmlFoundElement" xml:space="preserve">
<value>element '{0}' from namespace '{1}'</value>
</data>
<data name="XmlFoundEndElement" xml:space="preserve">
<value>end element '{0}' from namespace '{1}'</value>
</data>
<data name="XmlFoundEndOfFile" xml:space="preserve">
<value>end of file</value>
</data>
<data name="XmlFoundNodeType" xml:space="preserve">
<value>node {0}</value>
</data>
<data name="XmlFoundText" xml:space="preserve">
<value>text '{0}'</value>
</data>
<data name="XmlLineInfo" xml:space="preserve">
<value>Line {0}, position {1}.</value>
</data>
<data name="XmlStartElementExpected" xml:space="preserve">
<value>Start element expected. Found {0}.</value>
</data>
</root>

View File

@@ -1 +0,0 @@
5534250e892af7b6d8156f5b934427eb38bf7d79

View File

@@ -1,13 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.Threading;
using System.Globalization;
namespace System.ServiceModel.Channels
{
using System.Threading;
using System.Globalization;
using System.ServiceModel;
internal class UriGenerator
{
private long _id;
@@ -26,11 +25,10 @@ namespace System.ServiceModel.Channels
public UriGenerator(string scheme, string delimiter)
{
if (scheme == null)
throw new ArgumentException("scheme");
//throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("scheme"));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("scheme"));
if (scheme.Length == 0)
throw new ArgumentException(string.Format(SR.UriGeneratorSchemeMustNotBeEmpty, "scheme"));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.UriGeneratorSchemeMustNotBeEmpty), "scheme"));
_prefix = string.Concat(scheme, ":", Guid.NewGuid().ToString(), delimiter, "id=");
}

View File

@@ -0,0 +1,49 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace System.ServiceModel
{
/// <summary>
/// This is the Management utility class.
/// Adding Xml
/// </summary>
internal static class DiagnosticUtility
{
public static bool ShouldTraceInformation { get; internal set; }
internal static class ExceptionUtility
{
internal static ArgumentException ThrowHelperArgument(string message)
{
return (ArgumentException)ThrowHelperError(new ArgumentException(message));
}
internal static ArgumentException ThrowHelperArgument(string paramName, string message)
{
return (ArgumentException)ThrowHelperError(new ArgumentException(message, paramName));
}
internal static ArgumentNullException ThrowHelperArgumentNull(string paramName)
{
return (ArgumentNullException)ThrowHelperError(new ArgumentNullException(paramName));
}
internal static Exception ThrowHelperError(Exception exception)
{
return exception;
}
internal static Exception ThrowHelperWarning(Exception exception)
{
return exception;
}
}
}
}

View File

@@ -2,7 +2,6 @@
// 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
{
internal static class App10Constants

View File

@@ -2,11 +2,9 @@
// 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 static class Atom10Constants
internal static class Atom10Constants
{
public const string AlternateTag = "alternate";
public const string Atom10Namespace = "http://www.w3.org/2005/Atom";
@@ -48,6 +46,5 @@ namespace System.ServiceModel.Syndication
public const string XHtmlMediaType = "application/xhtml+xml";
public const string XHtmlType = "xhtml";
public const string XmlMediaType = "text/xml";
public const string IconTag = "icon";
}
}

View File

@@ -2,24 +2,21 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*
* Some diagnostic lines have been commented
*
* */
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Schema;
using System.Runtime.CompilerServices;
namespace System.ServiceModel.Syndication
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
[XmlRoot(ElementName = Atom10Constants.EntryTag, Namespace = Atom10Constants.Atom10Namespace)]
public class Atom10ItemFormatter : SyndicationItemFormatter
public class Atom10ItemFormatter : SyndicationItemFormatter, IXmlSerializable
{
private Atom10FeedFormatter _feedSerializer;
private Type _itemType;
@@ -36,11 +33,12 @@ namespace System.ServiceModel.Syndication
{
if (itemTypeToCreate == null)
{
throw new ArgumentNullException(nameof(itemTypeToCreate));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("itemTypeToCreate");
}
if (!typeof(SyndicationItem).IsAssignableFrom(itemTypeToCreate))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(itemTypeToCreate), nameof(SyndicationItem)));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("itemTypeToCreate",
SR.Format(SR.InvalidObjectTypePassed, "itemTypeToCreate", "SyndicationItem"));
}
_feedSerializer = new Atom10FeedFormatter();
_feedSerializer.PreserveAttributeExtensions = _preserveAttributeExtensions = true;
@@ -95,33 +93,63 @@ namespace System.ServiceModel.Syndication
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return reader.IsStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
}
public override Task ReadFromAsync(XmlReader reader)
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
XmlSchema IXmlSerializable.GetSchema()
{
if (!CanRead(reader))
{
throw new XmlException(string.Format(SR.UnknownItemXml, reader.LocalName, reader.NamespaceURI));
}
return ReadItemAsync(reader);
return null;
}
public override async Task WriteToAsync(XmlWriter writer)
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
void IXmlSerializable.ReadXml(XmlReader reader)
{
if (reader == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
SyndicationFeedFormatter.TraceItemReadBegin();
ReadItem(reader);
SyndicationFeedFormatter.TraceItemReadEnd();
}
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
void IXmlSerializable.WriteXml(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
SyndicationFeedFormatter.TraceItemWriteBegin();
WriteItem(writer);
SyndicationFeedFormatter.TraceItemWriteEnd();
}
writer = XmlWriterWrapper.CreateFromWriter(writer);
public override void ReadFrom(XmlReader reader)
{
SyndicationFeedFormatter.TraceItemReadBegin();
if (!CanRead(reader))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.UnknownItemXml, reader.LocalName, reader.NamespaceURI)));
}
ReadItem(reader);
SyndicationFeedFormatter.TraceItemReadEnd();
}
await writer.WriteStartElementAsync(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
await WriteItemAsync(writer);
await writer.WriteEndElementAsync();
public override void WriteTo(XmlWriter writer)
{
if (writer == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
SyndicationFeedFormatter.TraceItemWriteBegin();
writer.WriteStartElement(Atom10Constants.EntryTag, Atom10Constants.Atom10Namespace);
WriteItem(writer);
writer.WriteEndElement();
SyndicationFeedFormatter.TraceItemWriteEnd();
}
protected override SyndicationItem CreateItemInstance()
@@ -129,20 +157,20 @@ namespace System.ServiceModel.Syndication
return SyndicationItemFormatter.CreateItemInstance(_itemType);
}
private Task ReadItemAsync(XmlReader reader)
private void ReadItem(XmlReader reader)
{
SetItem(CreateItemInstance());
return _feedSerializer.ReadItemFromAsync(XmlReaderWrapper.CreateFromReader(XmlDictionaryReader.CreateDictionaryReader(reader)), this.Item);
_feedSerializer.ReadItemFrom(XmlDictionaryReader.CreateDictionaryReader(reader), this.Item);
}
private Task WriteItemAsync(XmlWriter writer)
private void WriteItem(XmlWriter writer)
{
if (this.Item == null)
{
throw new InvalidOperationException(SR.ItemFormatterDoesNotHaveItem);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ItemFormatterDoesNotHaveItem)));
}
XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter(writer);
return _feedSerializer.WriteItemContentsAsync(w, this.Item);
_feedSerializer.WriteItemContents(w, this.Item);
}
}

View File

@@ -2,17 +2,21 @@
// 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.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.ServiceModel.Channels;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace System.ServiceModel.Syndication
{
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
[XmlRoot(ElementName = App10Constants.Categories, Namespace = App10Constants.Namespace)]
public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter
public class AtomPub10CategoriesDocumentFormatter : CategoriesDocumentFormatter, IXmlSerializable
{
private Type _inlineDocumentType;
private int _maxExtensionSize;
@@ -30,24 +34,22 @@ namespace System.ServiceModel.Syndication
{
if (inlineDocumentType == null)
{
throw new ArgumentNullException(nameof(inlineDocumentType));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inlineDocumentType");
}
if (!typeof(InlineCategoriesDocument).IsAssignableFrom(inlineDocumentType))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(inlineDocumentType), nameof(InlineCategoriesDocument)));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("inlineDocumentType",
SR.Format(SR.InvalidObjectTypePassed, "inlineDocumentType", "InlineCategoriesDocument"));
}
if (referencedDocumentType == null)
{
throw new ArgumentNullException(nameof(referencedDocumentType));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("referencedDocumentType");
}
if (!typeof(ReferencedCategoriesDocument).IsAssignableFrom(referencedDocumentType))
{
throw new ArgumentException(string.Format(SR.InvalidObjectTypePassed, nameof(referencedDocumentType), nameof(ReferencedCategoriesDocument)));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("referencedDocumentType",
SR.Format(SR.InvalidObjectTypePassed, "referencedDocumentType", "ReferencedCategoriesDocument"));
}
_maxExtensionSize = int.MaxValue;
_preserveAttributeExtensions = true;
_preserveElementExtensions = true;
@@ -79,74 +81,95 @@ namespace System.ServiceModel.Syndication
get { return App10Constants.Namespace; }
}
public override Task<bool> CanReadAsync(XmlReader reader)
public override bool CanRead(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
XmlReaderWrapper wrappedReader = XmlReaderWrapper.CreateFromReader(reader);
return wrappedReader.IsStartElementAsync(App10Constants.Categories, App10Constants.Namespace);
return reader.IsStartElement(App10Constants.Categories, App10Constants.Namespace);
}
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
XmlSchema IXmlSerializable.GetSchema()
{
return null;
}
private Task ReadXmlAsync(XmlReaderWrapper reader)
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
void IXmlSerializable.ReadXml(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
return ReadDocumentAsync(reader);
TraceCategoriesDocumentReadBegin();
ReadDocument(reader);
TraceCategoriesDocumentReadEnd();
}
private Task WriteXmlAsync(XmlWriter writer)
[SuppressMessage("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes", Justification = "The IXmlSerializable implementation is only for exposing under WCF DataContractSerializer. The funcionality is exposed to derived class through the ReadFrom\\WriteTo methods")]
void IXmlSerializable.WriteXml(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (this.Document == null)
{
throw new InvalidOperationException(SR.DocumentFormatterDoesNotHaveDocument);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DocumentFormatterDoesNotHaveDocument)));
}
return WriteDocumentAsync(writer);
TraceCategoriesDocumentWriteBegin();
WriteDocument(writer);
TraceCategoriesDocumentWriteEnd();
}
public override async Task ReadFromAsync(XmlReader reader)
public override void ReadFrom(XmlReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
}
if (!await CanReadAsync(reader))
if (!CanRead(reader))
{
throw new XmlException(string.Format(SR.UnknownDocumentXml, reader.LocalName, reader.NamespaceURI));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.UnknownDocumentXml, reader.LocalName, reader.NamespaceURI)));
}
await ReadDocumentAsync(XmlReaderWrapper.CreateFromReader(reader));
TraceCategoriesDocumentReadBegin();
ReadDocument(reader);
TraceCategoriesDocumentReadEnd();
}
public override async Task WriteTo(XmlWriter writer)
public override void WriteTo(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (this.Document == null)
{
throw new InvalidOperationException(SR.DocumentFormatterDoesNotHaveDocument);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DocumentFormatterDoesNotHaveDocument)));
}
TraceCategoriesDocumentWriteBegin();
writer.WriteStartElement(App10Constants.Prefix, App10Constants.Categories, App10Constants.Namespace);
await WriteDocumentAsync(writer);
WriteDocument(writer);
writer.WriteEndElement();
TraceCategoriesDocumentWriteEnd();
}
internal static void TraceCategoriesDocumentReadBegin()
{
}
internal static void TraceCategoriesDocumentReadEnd()
{
}
internal static void TraceCategoriesDocumentWriteBegin()
{
}
internal static void TraceCategoriesDocumentWriteEnd()
{
}
protected override InlineCategoriesDocument CreateInlineCategoriesDocument()
@@ -173,12 +196,12 @@ namespace System.ServiceModel.Syndication
}
}
private async Task ReadDocumentAsync(XmlReaderWrapper reader)
private void ReadDocument(XmlReader reader)
{
try
{
await SyndicationFeedFormatter.MoveToStartElementAsync(reader);
SetDocument(await AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
SyndicationFeedFormatter.MoveToStartElement(reader);
SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
delegate ()
{
return this.CreateInlineCategoriesDocument();
@@ -195,19 +218,19 @@ namespace System.ServiceModel.Syndication
}
catch (FormatException e)
{
throw new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e));
}
catch (ArgumentException e)
{
throw new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e);
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(FeedUtils.AddLineInfo(reader, SR.ErrorParsingDocument), e));
}
}
private Task WriteDocumentAsync(XmlWriter writer)
private void WriteDocument(XmlWriter writer)
{
// declare the atom10 namespace upfront for compactness
writer.WriteAttributeString(Atom10Constants.Atom10Prefix, Atom10FeedFormatter.XmlNsNs, Atom10Constants.Atom10Namespace);
return AtomPub10ServiceDocumentFormatter.WriteCategoriesInnerXml(writer, this.Document, null, this.Version);
AtomPub10ServiceDocumentFormatter.WriteCategoriesInnerXml(writer, this.Document, null, this.Version);
}
}
}

View File

@@ -2,15 +2,16 @@
// 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;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Runtime.CompilerServices;
namespace System.ServiceModel.Syndication
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Xml;
public abstract class CategoriesDocument : IExtensibleSyndicationObject
{
private Uri _baseUri;
@@ -69,10 +70,10 @@ namespace System.ServiceModel.Syndication
return new ReferencedCategoriesDocument(linkToCategoriesDocument);
}
public static async Task<CategoriesDocument> LoadAsync(XmlReader reader)
public static CategoriesDocument Load(XmlReader reader)
{
AtomPub10CategoriesDocumentFormatter formatter = new AtomPub10CategoriesDocumentFormatter();
await formatter.ReadFromAsync(reader);
formatter.ReadFrom(reader);
return formatter.Document;
}
@@ -96,17 +97,17 @@ namespace System.ServiceModel.Syndication
return false;
}
protected internal virtual Task WriteAttributeExtensionsAsync(XmlWriter writer, string version)
protected internal virtual void WriteAttributeExtensions(XmlWriter writer, string version)
{
return _extensions.WriteAttributeExtensionsAsync(writer);
_extensions.WriteAttributeExtensions(writer);
}
protected internal virtual Task WriteElementExtensionsAsync(XmlWriter writer, string version)
protected internal virtual void WriteElementExtensions(XmlWriter writer, string version)
{
return _extensions.WriteElementExtensionsAsync(writer);
_extensions.WriteElementExtensions(writer);
}
internal void LoadElementExtensions(XmlReaderWrapper readerOverUnparsedExtensions, int maxExtensionSize)
internal void LoadElementExtensions(XmlReader readerOverUnparsedExtensions, int maxExtensionSize)
{
_extensions.LoadElementExtensions(readerOverUnparsedExtensions, maxExtensionSize);
}

View File

@@ -2,14 +2,16 @@
// 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.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Xml;
using System.Runtime.CompilerServices;
namespace System.ServiceModel.Syndication
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using System.Xml;
[DataContract]
public abstract class CategoriesDocumentFormatter
{
private CategoriesDocument _document;
@@ -21,7 +23,7 @@ namespace System.ServiceModel.Syndication
{
if (documentToWrite == null)
{
throw new ArgumentNullException(nameof(documentToWrite));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("documentToWrite");
}
_document = documentToWrite;
}
@@ -34,9 +36,9 @@ namespace System.ServiceModel.Syndication
public abstract string Version
{ get; }
public abstract Task<bool> CanReadAsync(XmlReader reader);
public abstract Task ReadFromAsync(XmlReader reader);
public abstract Task WriteTo(XmlWriter writer);
public abstract bool CanRead(XmlReader reader);
public abstract void ReadFrom(XmlReader reader);
public abstract void WriteTo(XmlWriter writer);
protected virtual InlineCategoriesDocument CreateInlineCategoriesDocument()
{

View File

@@ -0,0 +1,217 @@
// 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.Globalization;
using System.Text;
namespace System.ServiceModel.Syndication
{
internal static class DateTimeHelper
{
private const string Rfc3339DateTimeFormat = "yyyy-MM-ddTHH:mm:ssK";
public static DateTimeOffset DefaultRss20DateTimeParser(string dateTimeString, string localName, string ns)
{
DateTimeOffset dto;
// First check if DateTimeOffset default parsing can parse the date
if (DateTimeOffset.TryParse(dateTimeString, out dto))
{
return dto;
}
// RSS specifies RFC822
if (Rfc822DateTimeParser(dateTimeString, out dto))
{
return dto;
}
// Event though RCS3339 is for Atom, someone might be using this for RSS
if (Rfc3339DateTimeParser(dateTimeString, out dto))
{
return dto;
}
// Unable to parse - using a default date;
throw new FormatException(SR.ErrorParsingDateTime);
}
public static DateTimeOffset DefaultAtom10DateTimeParser(string dateTimeString, string localName, string ns)
{
if (Rfc3339DateTimeParser(dateTimeString, out DateTimeOffset dto))
{
return dto;
}
throw new FormatException(SR.ErrorParsingDateTime);
}
private static bool Rfc3339DateTimeParser(string dateTimeString, out DateTimeOffset dto)
{
dateTimeString = dateTimeString.Trim();
if (dateTimeString.Length < 20)
{
return false;
}
if (dateTimeString[19] == '.')
{
// remove any fractional seconds, we choose to ignore them
int i = 20;
while (dateTimeString.Length > i && char.IsDigit(dateTimeString[i]))
{
++i;
}
dateTimeString = dateTimeString.Substring(0, 19) + dateTimeString.Substring(i);
}
return DateTimeOffset.TryParseExact(dateTimeString, Rfc3339DateTimeFormat, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.None, out dto);
}
private static bool Rfc822DateTimeParser(string dateTimeString, out DateTimeOffset dto)
{
StringBuilder dateTimeStringBuilder = new StringBuilder(dateTimeString.Trim());
if (dateTimeStringBuilder.Length < 18)
{
return false;
}
int timeZoneStartIndex;
for (timeZoneStartIndex = dateTimeStringBuilder.Length - 1; dateTimeStringBuilder[timeZoneStartIndex] != ' '; timeZoneStartIndex--)
;
timeZoneStartIndex++;
int timeZoneLength = dateTimeStringBuilder.Length - timeZoneStartIndex;
string timeZoneSuffix = dateTimeStringBuilder.ToString(timeZoneStartIndex, timeZoneLength);
dateTimeStringBuilder.Remove(timeZoneStartIndex, timeZoneLength);
bool isUtc;
dateTimeStringBuilder.Append(NormalizeTimeZone(timeZoneSuffix, out isUtc));
string wellFormattedString = dateTimeStringBuilder.ToString();
DateTimeOffset theTime;
string[] parseFormat =
{
"ddd, dd MMMM yyyy HH:mm:ss zzz",
"dd MMMM yyyy HH:mm:ss zzz",
"ddd, dd MMM yyyy HH:mm:ss zzz",
"dd MMM yyyy HH:mm:ss zzz",
"ddd, dd MMMM yyyy HH:mm zzz",
"dd MMMM yyyy HH:mm zzz",
"ddd, dd MMM yyyy HH:mm zzz",
"dd MMM yyyy HH:mm zzz",
// The original RFC822 spec listed 2 digit years. RFC1123 updated the format to include 4 digit years and states that you should use 4 digits.
// Technically RSS2.0 specifies RFC822 but it's presumed that RFC1123 will be used as we're now past Y2K and everyone knows better. The 4 digit
// formats are listed first for performance reasons as it's presumed they will be more likely to match first.
"ddd, dd MMMM yy HH:mm:ss zzz",
"dd MMMM yyyy HH:mm:ss zzz",
"ddd, dd MMM yy HH:mm:ss zzz",
"dd MMM yyyy HH:mm:ss zzz",
"ddd, dd MMMM yy HH:mm zzz",
"dd MMMM yyyy HH:mm zzz",
"ddd, dd MMM yy HH:mm zzz",
"dd MMM yyyy HH:mm zzz"
};
if (DateTimeOffset.TryParseExact(wellFormattedString, parseFormat,
CultureInfo.InvariantCulture.DateTimeFormat,
(isUtc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None), out theTime))
{
dto = theTime;
return true;
}
return false;
}
private static string NormalizeTimeZone(string rfc822TimeZone, out bool isUtc)
{
isUtc = false;
// return a string in "-08:00" format
if (rfc822TimeZone[0] == '+' || rfc822TimeZone[0] == '-')
{
// the time zone is supposed to be 4 digits but some feeds omit the initial 0
StringBuilder result = new StringBuilder(rfc822TimeZone);
if (result.Length == 4)
{
// the timezone is +/-HMM. Convert to +/-HHMM
result.Insert(1, '0');
}
result.Insert(3, ':');
return result.ToString();
}
switch (rfc822TimeZone)
{
case "UT":
case "Z":
isUtc = true;
return "-00:00";
case "GMT":
return "-00:00";
case "A":
return "-01:00";
case "B":
return "-02:00";
case "C":
return "-03:00";
case "D":
case "EDT":
return "-04:00";
case "E":
case "EST":
case "CDT":
return "-05:00";
case "F":
case "CST":
case "MDT":
return "-06:00";
case "G":
case "MST":
case "PDT":
return "-07:00";
case "H":
case "PST":
return "-08:00";
case "I":
return "-09:00";
case "K":
return "-10:00";
case "L":
return "-11:00";
case "M":
return "-12:00";
case "N":
return "+01:00";
case "O":
return "+02:00";
case "P":
return "+03:00";
case "Q":
return "+04:00";
case "R":
return "+05:00";
case "S":
return "+06:00";
case "T":
return "+07:00";
case "U":
return "+08:00";
case "V":
return "+09:00";
case "W":
return "+10:00";
case "X":
return "+11:00";
case "Y":
return "+12:00";
default:
return "";
}
}
}
}

View File

@@ -2,14 +2,14 @@
// 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.Collections.ObjectModel;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Xml;
namespace System.ServiceModel.Syndication
{
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Xml;
using System.Threading.Tasks;
// NOTE: This class implements Clone so if you add any members, please update the copy ctor
internal struct ExtensibleSyndicationObject : IExtensibleSyndicationObject
{
@@ -85,12 +85,11 @@ namespace System.ServiceModel.Syndication
{
if (readerOverUnparsedExtensions == null)
{
throw new ArgumentNullException(nameof(readerOverUnparsedExtensions));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerOverUnparsedExtensions");
}
if (maxExtensionSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxExtensionSize));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxExtensionSize"));
}
XmlDictionaryReader r = XmlDictionaryReader.CreateDictionaryReader(readerOverUnparsedExtensions);
_elementExtensions = new SyndicationElementExtensionCollection(CreateXmlBuffer(r, maxExtensionSize));
@@ -102,35 +101,31 @@ namespace System.ServiceModel.Syndication
_elementExtensions = new SyndicationElementExtensionCollection(buffer);
}
internal async Task WriteAttributeExtensionsAsync(XmlWriter writer)
internal void WriteAttributeExtensions(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
writer = XmlWriterWrapper.CreateFromWriter(writer);
if (_attributeExtensions != null)
{
foreach (XmlQualifiedName qname in _attributeExtensions.Keys)
{
string value = _attributeExtensions[qname];
await writer.WriteAttributeStringAsync(qname.Name, qname.Namespace, value);
writer.WriteAttributeString(qname.Name, qname.Namespace, value);
}
}
}
internal async Task WriteElementExtensionsAsync(XmlWriter writer)
internal void WriteElementExtensions(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException(nameof(writer));
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
}
if (_elementExtensions != null)
{
await _elementExtensions.WriteToAsync(writer);
_elementExtensions.WriteTo(writer);
}
}

Some files were not shown because too many files have changed in this diff Show More