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;