Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -1555,6 +1555,13 @@ namespace MonoTests.System.XmlSerialization
Assert.AreEqual (new DateTime (2012,2,5,9,0,0,DateTimeKind.Utc), o.SomeDate.ToUniversalTime ());
}
[Test]
public void TimeWithUtc ()
{
XmlSerializer xs = new XmlSerializer (typeof (UtcTimeClass));
var o = (UtcTimeClass) xs.Deserialize (new StringReader ("<UtcTimeClass xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><DateTimeValue>12:34:56.0Z</DateTimeValue></UtcTimeClass>"));
Assert.AreEqual (new DateTime (1,1,1,12,34,56,DateTimeKind.Utc), o.DateTimeValue);
}
public class Foo
{

View File

@@ -1575,30 +1575,16 @@ namespace MonoTests.System.XmlSerialization
ser.Serialize (sw, d);
string str = sw.ToString ();
str = RemoveTZ (str, "MyTime");
str = RemoveTZ (str, "MyTimeNullable");
var expected =
"<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
"<root xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + Environment.NewLine +
" <MyTime>10:00:00.0000000$TZ$</MyTime>" + Environment.NewLine +
" <MyTimeNullable>10:00:00.0000000$TZ$</MyTimeNullable>" + Environment.NewLine +
" <MyTime>10:00:00.0000000Z</MyTime>" + Environment.NewLine +
" <MyTimeNullable>10:00:00.0000000Z</MyTimeNullable>" + Environment.NewLine +
" <MyDate>2012-01-03</MyDate>" + Environment.NewLine +
" <MyDateNullable>2012-01-03</MyDateNullable>" + Environment.NewLine +
"</root>";
Assert.AreEqual (expected, str);
}
static string RemoveTZ (string str, string tag)
{
var st = str.IndexOf ("<" + tag + ">");
var et = str.IndexOf ("</" + tag + ">");
if (st < 0 || et < 0)
return str;
var start = str.IndexOfAny (new [] { '+', '-' }, st, et - st);
return str.Substring (0, start) + "$TZ$" + str.Substring (et, str.Length - et);
}
}
}

View File

@@ -1071,6 +1071,12 @@ namespace MonoTests.System.Xml.TestClasses
public DateTime SomeDate;
}
public class UtcTimeClass
{
[XmlElementAttribute (DataType = "time")]
public DateTime DateTimeValue;
}
public class Bug8468BaseClass
{
public string Base;

View File

@@ -15,10 +15,8 @@ using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.XPath;
#if NET_4_5
using System.Threading;
using System.Threading.Tasks;
#endif
using NUnit.Framework;
@@ -2298,7 +2296,6 @@ namespace MonoTests.System.Xml
Assert.AreEqual ((UInt64) 1, xr.ReadContentAs (typeof (UInt64), null), "#8");
}
#if NET_4_5
[Test]
[ExpectedException(typeof(InvalidOperationException))]
public void MustSetAsyncFlag ()
@@ -2347,6 +2344,5 @@ namespace MonoTests.System.Xml
if (task.Result != null)
throw task.Result;
}
#endif
}
}

View File

@@ -419,7 +419,6 @@ namespace MonoTests.System.Xml
Assert.AreEqual ("urn:foo", r.BaseURI);
}
#if NET_4_5
[Test]
[ExpectedException (typeof (XmlException))]
public void ReadonlyAsync ()
@@ -444,6 +443,5 @@ namespace MonoTests.System.Xml
var r2 = XmlReader.Create (r, c);
Assert.IsTrue (r2.Settings.Async);
}
#endif
}
}

View File

@@ -103,7 +103,6 @@ namespace MonoTests.System.Xml {
Assert.IsTrue (u2.IsAbsoluteUri, "null,absolute/file");
}
#if NET_4_5
class AsyncXmlResolver : XmlResolver
{
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
@@ -121,6 +120,5 @@ namespace MonoTests.System.Xml {
var uri = new Uri ("http://www.mono-project.com");
ar.GetEntityAsync (uri, null, typeof(string));
}
#endif
}
}

View File

@@ -124,7 +124,6 @@ namespace MonoTests.System.Xml
Assert.IsTrue (site, "Site-2");
}
#if NET_4_5
[Test]
[Category("Async")]
public void TestAsync ()
@@ -139,7 +138,6 @@ namespace MonoTests.System.Xml
Assert.That (task.Wait (3000));
Assert.IsInstanceOfType (typeof (Stream), task.Result);
}
#endif
}
}

View File

@@ -10,9 +10,7 @@ using System;
using System.IO;
using System.Xml;
using NUnit.Framework;
#if NET_4_5
using System.Reflection;
#endif
namespace MonoTests.System.Xml
{
@@ -98,7 +96,6 @@ namespace MonoTests.System.Xml
Assert.AreEqual ("view:Standard.xslt", uri.AbsoluteUri, "#2");
}
#if NET_4_5
[Test]
public void TestAsync ()
{
@@ -126,6 +123,5 @@ namespace MonoTests.System.Xml
Assert.IsTrue (ex is XmlException);
}
}
#endif
}
}

View File

@@ -40,9 +40,7 @@ namespace MonoTests.System.Xml
Assert.AreEqual (false, s.NewLineOnAttributes);
Assert.AreEqual (false, s.OmitXmlDeclaration);
Assert.AreEqual (NewLineHandling.Replace, s.NewLineHandling);
#if NET_4_5
Assert.IsFalse (s.Async);
#endif
}
[Test]
@@ -381,7 +379,6 @@ namespace MonoTests.System.Xml
Assert.AreEqual (xml, sw.ToString ());
}
#if NET_4_5
[Test]
[ExpectedException (typeof (XmlException))]
public void ReadonlyAsync ()
@@ -408,7 +405,6 @@ namespace MonoTests.System.Xml
var w2 = XmlWriter.Create (w, c);
Assert.IsTrue (w2.Settings.Async);
}
#endif
}
}