Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2018-04-02 00:54:57 +0300
committerMarek Safar <marek.safar@gmail.com>2018-04-02 00:54:57 +0300
commitf4951179bb053a9264f063c824720d6237ae55f1 (patch)
treef7beda10c1e1c9f8a8f4c21a000993598ea0502c /src/System.Private.Xml.Linq
parente89c5c9646d29d74a069f8f9630e35858b6bb076 (diff)
parent79b3c40e4322fd1778ad075214c90af93e5d2adf (diff)
Merge remote-tracking branch 'upstream/release/2.1' into 2.1-merge
Diffstat (limited to 'src/System.Private.Xml.Linq')
-rw-r--r--src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs28
-rw-r--r--src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj1
-rw-r--r--src/System.Private.Xml.Linq/tests/misc/XAttribute.cs22
-rw-r--r--src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs26
4 files changed, 57 insertions, 20 deletions
diff --git a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs
index 7a3ae67461..31c5801dbd 100644
--- a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs
+++ b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs
@@ -108,7 +108,7 @@ namespace System.Xml.Linq
/// <item>TimeSpan</item>
/// <item>Any type implementing ToString()</item>
/// <item>Any type implementing IEnumerable</item>
- ///
+ ///
/// </list>
/// When adding complex content, a number of types may be passed to this method.
/// <list>
@@ -117,19 +117,19 @@ namespace System.Xml.Linq
/// <item>XAttribute</item>
/// <item>Any type implementing IEnumerable</item>
/// </list>
- ///
+ ///
/// If an object implements IEnumerable, then the collection in the object is enumerated,
/// and all items in the collection are added. If the collection contains simple content,
/// then the simple content in the collection is concatenated and added as a single
/// string of simple content. If the collection contains complex content, then each item
/// in the collection is added separately.
- ///
+ ///
/// If content is null, nothing is added. This allows the results of a query to be passed
/// as content. If the query returns null, no contents are added, and this method does not
/// throw a NullReferenceException.
- ///
+ ///
/// Attributes and simple content can't be added to a document.
- ///
+ ///
/// An added attribute must have a unique name within the element to
/// which it is being added.
/// </remarks>
@@ -235,7 +235,7 @@ namespace System.Xml.Linq
}
/// <summary>
- /// Creates an <see cref="XmlWriter"/> used to add either nodes
+ /// Creates an <see cref="XmlWriter"/> used to add either nodes
/// or attributes to the <see cref="XContainer"/>. The later option
/// applies only for <see cref="XElement"/>.
/// </summary>
@@ -259,7 +259,7 @@ namespace System.Xml.Linq
/// <summary>
/// Returns the descendant <see cref="XElement"/>s of this <see cref="XContainer"/>. Note this method will
/// not return itself in the resulting IEnumerable. See <see cref="XElement.DescendantsAndSelf()"/> if you
- /// need to include the current <see cref="XElement"/> in the results.
+ /// need to include the current <see cref="XElement"/> in the results.
/// <seealso cref="XElement.DescendantsAndSelf()"/>
/// </summary>
/// <returns>
@@ -275,7 +275,7 @@ namespace System.Xml.Linq
/// of XElement.
/// </summary>
/// <param name="name">The <see cref="XName"/> to match against descendant <see cref="XElement"/>s.</param>
- /// <returns>An <see cref="IEnumerable"/> of <see cref="XElement"/></returns>
+ /// <returns>An <see cref="IEnumerable"/> of <see cref="XElement"/></returns>
public IEnumerable<XElement> Descendants(XName name)
{
return name != null ? GetDescendants(name, false) : XElement.EmptySequence;
@@ -346,7 +346,7 @@ namespace System.Xml.Linq
/// that the content does not include <see cref="XAttribute"/>s.
/// <seealso cref="XElement.Attributes()"/>
/// </summary>
- /// <returns>The contents of this <see cref="XContainer"/></returns>
+ /// <returns>The contents of this <see cref="XContainer"/></returns>
public IEnumerable<XNode> Nodes()
{
XNode n = LastNode;
@@ -385,7 +385,7 @@ namespace System.Xml.Linq
{
if (this is XElement)
{
- // Change in the serialization of an empty element:
+ // Change in the serialization of an empty element:
// from start/end tag pair to empty tag
NotifyChanging(this, XObjectChangeEventArgs.Value);
if ((object)s != (object)content) throw new InvalidOperationException(SR.InvalidOperation_ExternalCode);
@@ -554,7 +554,7 @@ namespace System.Xml.Linq
{
if (this is XElement)
{
- // Change in the serialization of an empty element:
+ // Change in the serialization of an empty element:
// from empty tag to start/end tag pair
NotifyChanging(this, XObjectChangeEventArgs.Value);
if (content != null) throw new InvalidOperationException(SR.InvalidOperation_ExternalCode);
@@ -830,7 +830,7 @@ namespace System.Xml.Linq
}
else if (value is DateTime)
{
- s = ((DateTime)value).ToString("o"); // Round-trip date/time pattern.
+ s = XmlConvert.ToString((DateTime) value, XmlDateTimeSerializationMode.RoundtripKind);
}
else if (value is DateTimeOffset)
{
@@ -855,7 +855,7 @@ namespace System.Xml.Linq
internal void ReadContentFrom(XmlReader r)
{
if (r.ReadState != ReadState.Interactive) throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
-
+
ContentReader cr = new ContentReader(this);
while (cr.ReadContentFrom(this, r) && r.Read()) ;
}
@@ -893,7 +893,7 @@ namespace System.Xml.Linq
return;
}
if (r.ReadState != ReadState.Interactive) throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
-
+
ContentReader cr = new ContentReader(this, r, o);
do
{
diff --git a/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj b/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
index 37d30161d0..def58e5d8c 100644
--- a/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
+++ b/src/System.Private.Xml.Linq/tests/misc/System.Xml.Linq.Misc.Tests.csproj
@@ -16,6 +16,7 @@
<Compile Include="XHashtable.cs" />
<Compile Include="XLinqErrata4.cs" />
<Compile Include="XNameAPI.cs" />
+ <Compile Include="XAttribute.cs" />
<Compile Include="LoadSaveAsyncTests.cs" Condition="'$(TargetGroup)'=='netcoreapp'" />
</ItemGroup>
<ItemGroup>
diff --git a/src/System.Private.Xml.Linq/tests/misc/XAttribute.cs b/src/System.Private.Xml.Linq/tests/misc/XAttribute.cs
new file mode 100644
index 0000000000..5bb72329eb
--- /dev/null
+++ b/src/System.Private.Xml.Linq/tests/misc/XAttribute.cs
@@ -0,0 +1,22 @@
+// 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 Microsoft.Test.ModuleCore;
+using Xunit;
+
+namespace System.Xml.Linq.Tests
+{
+ public class XAttributeTests
+ {
+ [Fact]
+ public void FormattedDate()
+ {
+ // Ensure we are compatible with the full framework
+ Assert.Equal("CreatedTime=\"2018-01-01T12:13:14Z\"", new XAttribute("CreatedTime", new DateTime(2018, 1, 1, 12, 13, 14, DateTimeKind.Utc)).ToString());
+ }
+ }
+}
diff --git a/src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs b/src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs
index bf5589d9cb..4fa4ab03de 100644
--- a/src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs
+++ b/src/System.Private.Xml.Linq/tests/xNodeBuilder/CommonTests.cs
@@ -9,6 +9,7 @@ using System.Linq;
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
+using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XmlDiff;
@@ -3418,8 +3419,12 @@ namespace CoreXml.Test.XLinq
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
{
- string expectedMsg = "Cannot have ']]>' inside an XML CDATA block.";
- Assert.Equal(expectedMsg, exception.Message);
+ // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
+ // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
+ // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
+ Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("]]>") + @"[\p{Pf}\p{Po}]"));
+ Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
+ Assert.True(Regex.IsMatch(exception.Message, @"\b" + "CDATA" + @"\b"));
}
}
}
@@ -3612,8 +3617,13 @@ namespace CoreXml.Test.XLinq
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
{
- string expectedMsg = "An XML comment cannot contain '--', and '-' cannot be the last character.";
- Assert.Equal(expectedMsg, exception.Message);
+ // \b word boundary
+ // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
+ // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
+ // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
+ Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
+ Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("--") + @"[\p{Pf}\p{Po}]"));
+ Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("-") + @"[\p{Pf}\p{Po}]"));
}
}
}
@@ -4215,8 +4225,12 @@ namespace CoreXml.Test.XLinq
Exception exception = AssertExtensions.Throws<ArgumentException>(null, () => MoveToFirstElement(reader).ReadOuterXml());
if (!PlatformDetection.IsNetNative) // .Net Native toolchain optimizes away Exception messages
{
- string expectedMsg = "Cannot have '?>' inside an XML processing instruction.";
- Assert.Equal(expectedMsg, exception.Message);
+ // \b word boundary
+ // \p{Pi} any kind of opening quote https://www.compart.com/en/unicode/category/Pi
+ // \p{Pf} any kind of closing quote https://www.compart.com/en/unicode/category/Pf
+ // \p{Po} any kind of punctuation character that is not a dash, bracket, quote or connector https://www.compart.com/en/unicode/category/Po
+ Assert.True(Regex.IsMatch(exception.Message, @"[\p{Pi}\p{Po}]" + Regex.Escape("?>") + @"[\p{Pf}\p{Po}]"));
+ Assert.True(Regex.IsMatch(exception.Message, @"\b" + "XML" + @"\b"));
}
}
}