Imported Upstream version 4.8.0.425

Former-commit-id: 56934f10a9ad11e3eb75c21da859e02f54766140
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-01-09 11:04:53 +00:00
parent 693afccc61
commit 2927bc3cc3
47 changed files with 479 additions and 354 deletions

View File

@@ -296,6 +296,7 @@ namespace MonoTests.System.Linq.Expressions {
Assert.AreEqual ("foo42", lamda (42, "foo"));
}
#if !FULL_AOT_RUNTIME
[Test]
public void CallDynamicMethod_ToString ()
{
@@ -325,6 +326,7 @@ namespace MonoTests.System.Linq.Expressions {
var lambda = Expression.Lambda<Func<int, int>> (e, i).Compile ();
Assert.AreEqual (42, lambda (42));
}
#endif
public static int Bang (Expression i)
{

View File

@@ -507,6 +507,11 @@ namespace MonoTests.System.IO.Compression
/// Simulate "CanSeek" is false, which is the case when you are retreiving data from web.
/// </summary>
public override bool CanSeek => false;
public override long Position {
get {throw new NotSupportedException();}
set {throw new NotSupportedException();}
}
}
[Test]
@@ -517,5 +522,16 @@ namespace MonoTests.System.IO.Compression
{
}
}
[Test]
public void ZipWriteNonSeekableStream() {
var stream = new MyFakeStream( "test.nupkg", FileMode.Open );
using ( var archive = new ZipArchive( stream, ZipArchiveMode.Create ) ) {
var entry = archive.CreateEntry( "foo" );
using ( var es = entry.Open() ) {
es.Write( new byte[] { 4, 2 }, 0, 2 );
}
}
}
}
}

View File

@@ -227,13 +227,20 @@ namespace System.IO.Compression
private void Save()
{
using (var newZip = new MemoryStream()) {
zipFile.SaveTo(newZip, CompressionType.Deflate, entryNameEncoding ?? Encoding.UTF8);
if (mode == ZipArchiveMode.Create)
{
zipFile.SaveTo(stream, CompressionType.Deflate, entryNameEncoding ?? Encoding.UTF8);
}
else {
using (var newZip = new MemoryStream())
{
zipFile.SaveTo(newZip, CompressionType.Deflate, entryNameEncoding ?? Encoding.UTF8);
stream.SetLength(0);
stream.Position = 0;
newZip.Position = 0;
newZip.CopyTo(stream);
stream.SetLength(0);
stream.Position = 0;
newZip.Position = 0;
newZip.CopyTo(stream);
}
}
}

View File

@@ -172,6 +172,33 @@ xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-micros
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root><foo attr='A'/><foo attr='B'/><foo attr='C'/></root>"))), null, sw);
}
[Test]
[Category ("MobileNotWorking")]
public void MSXslFormatDate ()
{
var arguments = new XsltArgumentList();
arguments.AddParam("date", "", new DateTime (2010, 11, 22, 5, 4, 3));
string xsl = @"
<xsl:stylesheet version=""1.0"" xmlns=""http://www.w3.org/1999/xhtml"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" exclude-result-prefixes=""msxsl"">
<xsl:param name='date'/>
<xsl:template match='/'>
<root>
<p>The current date is <xsl:value-of select=""msxsl:format-date($date, 'd MMMM yyyy')""/> and current time is <xsl:value-of select=""msxsl:format-time($date, 'HH:mm')""/>.</p>
</root>
</xsl:template>
</xsl:stylesheet>";
StringWriter sw = new StringWriter ();
var t = new XslCompiledTransform ();
t.Load (new XPathDocument (new StringReader (xsl)));
t.Transform (new XPathDocument (new XmlTextReader (new StringReader ("<root></root>"))), arguments, sw);
Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?><root xmlns=\"http://www.w3.org/1999/xhtml\"><p>The current date is 22 November 2010 and current time is 05:04.</p></root>", sw.ToString ());
}
[Test]
public void EvaluateEmptyVariableAsBoolean ()
{

View File

@@ -154,12 +154,9 @@ namespace Mono.Btls
}
}
Exception GetException (MonoBtlsSslError status)
static Exception GetException (MonoBtlsSslError status)
{
var error = MonoBtlsError.GetError ();
if (error == null)
return new MonoBtlsException (status);
var text = MonoBtlsError.GetErrorString (error);
return new MonoBtlsException ("{0} {1}", status, text);
}

View File

@@ -45,12 +45,14 @@ namespace Mono.Btls
static class MonoBtlsX509StoreManager
{
static bool initialized;
#if !ANDROID
static string machineTrustedRootPath;
static string machineIntermediateCAPath;
static string machineUntrustedPath;
static string userTrustedRootPath;
static string userIntermediateCAPath;
static string userUntrustedPath;
#endif
static void Initialize ()
{
@@ -75,9 +77,9 @@ namespace Mono.Btls
userUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted);
var machinePath = MX.X509StoreManager.NewLocalMachinePath;
machineTrustedRootPath = Path.Combine (userPath, MX.X509Stores.Names.TrustedRoot);
machineIntermediateCAPath = Path.Combine (userPath, MX.X509Stores.Names.IntermediateCA);
machineUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted);
machineTrustedRootPath = Path.Combine (machinePath, MX.X509Stores.Names.TrustedRoot);
machineIntermediateCAPath = Path.Combine (machinePath, MX.X509Stores.Names.IntermediateCA);
machineUntrustedPath = Path.Combine (machinePath, MX.X509Stores.Names.Untrusted);
#endif
}

View File

@@ -153,16 +153,23 @@ namespace Mono.Net.Security
}
}
const string LegacyProviderTypeName = "Mono.Net.Security.LegacyTlsProvider";
const string BtlsProviderTypeName = "Mono.Btls.MonoBtlsProvider";
static void InitializeProviderRegistration ()
{
lock (locker) {
if (providerRegistration != null)
return;
providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("legacy", "Mono.Net.Security.LegacyTlsProvider");
providerRegistration.Add ("default", "Mono.Net.Security.LegacyTlsProvider");
if (IsBtlsSupported ())
providerRegistration.Add ("btls", "Mono.Btls.MonoBtlsProvider");
providerRegistration.Add ("legacy", LegacyProviderTypeName);
bool btls_supported = IsBtlsSupported ();
if (btls_supported)
providerRegistration.Add ("btls", BtlsProviderTypeName);
providerRegistration.Add ("default", btls_supported && !Platform.IsMacOS ? BtlsProviderTypeName : LegacyProviderTypeName);
X509Helper2.Initialize ();
}
}

View File

@@ -361,7 +361,7 @@ namespace System.Net
return host;
}
if (!HasTimedOut)
if (!HasTimedOut && host != null)
return host;
lastDnsResolve = DateTime.UtcNow;

View File

@@ -17,7 +17,14 @@ namespace MonoTests.System.Net.WebSockets
public class ClientWebSocketTest
{
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
int Port = NetworkHelpers.FindFreePort ();
int port;
int Port {
get {
if (port == 0)
port = NetworkHelpers.FindFreePort ();
return port;
}
}
HttpListener _listener;
HttpListener listener {
get {
@@ -158,7 +165,12 @@ namespace MonoTests.System.Net.WebSockets
Assert.AreEqual (WebSocketState.Closed, socket.State);
}
[Test, ExpectedException (typeof (InvalidOperationException))]
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (InvalidOperationException))]
#endif
public void SendAsyncArgTest_NotConnected ()
{
socket.SendAsync (new ArraySegment<byte> (new byte[0]), WebSocketMessageType.Text, true, CancellationToken.None);
@@ -172,7 +184,11 @@ namespace MonoTests.System.Net.WebSockets
socket.SendAsync (new ArraySegment<byte> (), WebSocketMessageType.Text, true, CancellationToken.None);
}
[Test, ExpectedException (typeof (InvalidOperationException))]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (InvalidOperationException))]
#endif
public void ReceiveAsyncArgTest_NotConnected ()
{
socket.ReceiveAsync (new ArraySegment<byte> (new byte[0]), CancellationToken.None);

View File

@@ -1 +1 @@
0314861ee197046bdbbaf9680511292bbde83c39
9ae3f67f2d49337f9132b2676053d84cf34ff5d3

View File

@@ -1 +1 @@
b3586ea6fa1c0ea2a774b82321dc5ea824f48240
76e2f81fd4a9717c4a69a495cc31a486008065b1

View File

@@ -1 +1 @@
b3f8f8c80a38ce31cc9e392a4bb960e58d84a21a
e2132b7cb721bf4a4f23e20d5e295687d21b1ddf

View File

@@ -291,7 +291,7 @@ namespace System.Xml.Xsl.Runtime {
}
return d;
}
#if !MONO
// CharSet.Auto is needed to work on Windows 98 and Windows Me
[DllImport("kernel32.dll", CharSet=CharSet.Auto, BestFitMapping=false)]
// SxS: Time formatting does not expose any system resource hence Resource Exposure scope is None.
@@ -325,7 +325,7 @@ namespace System.Xml.Xsl.Runtime {
this.Milliseconds = (ushort)dateTime.Millisecond;
}
}
#endif
// string ms:format-date(string datetime[, string format[, string language]])
// string ms:format-time(string datetime[, string format[, string language]])
//
@@ -339,12 +339,24 @@ namespace System.Xml.Xsl.Runtime {
// passed, the current culture is used. If language is not recognized, a runtime error happens.
public static string MSFormatDateTime(string dateTime, string format, string lang, bool isDate) {
try {
int locale = GetCultureInfo(lang).LCID;
XsdDateTime xdt;
if (! XsdDateTime.TryParse(dateTime, XsdDateTimeFlags.AllXsd | XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrTimeNoTz, out xdt)) {
return string.Empty;
}
#if MONO
string locale = GetCultureInfo(lang).Name;
DateTime dt = xdt.ToZulu();
// If format is the empty string or not specified, use the default format for the given locale
if (format.Length == 0)
{
format = null;
}
return dt.ToString(format, new CultureInfo(locale));
#else
int locale = GetCultureInfo(lang).LCID;
SystemTime st = new SystemTime(xdt.ToZulu());
StringBuilder sb = new StringBuilder(format.Length + 16);
@@ -373,6 +385,7 @@ namespace System.Xml.Xsl.Runtime {
}
}
return sb.ToString();
#endif
} catch (ArgumentException) { // Operations with DateTime can throw this exception eventualy
return string.Empty;
}