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")); Assert.AreEqual ("foo42", lamda (42, "foo"));
} }
#if !FULL_AOT_RUNTIME
[Test] [Test]
public void CallDynamicMethod_ToString () public void CallDynamicMethod_ToString ()
{ {
@ -325,6 +326,7 @@ namespace MonoTests.System.Linq.Expressions {
var lambda = Expression.Lambda<Func<int, int>> (e, i).Compile (); var lambda = Expression.Lambda<Func<int, int>> (e, i).Compile ();
Assert.AreEqual (42, lambda (42)); Assert.AreEqual (42, lambda (42));
} }
#endif
public static int Bang (Expression i) 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. /// Simulate "CanSeek" is false, which is the case when you are retreiving data from web.
/// </summary> /// </summary>
public override bool CanSeek => false; public override bool CanSeek => false;
public override long Position {
get {throw new NotSupportedException();}
set {throw new NotSupportedException();}
}
} }
[Test] [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,7 +227,13 @@ namespace System.IO.Compression
private void Save() private void Save()
{ {
using (var newZip = new MemoryStream()) { 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); zipFile.SaveTo(newZip, CompressionType.Deflate, entryNameEncoding ?? Encoding.UTF8);
stream.SetLength(0); stream.SetLength(0);
@ -236,6 +242,7 @@ namespace System.IO.Compression
newZip.CopyTo(stream); newZip.CopyTo(stream);
} }
} }
}
internal void RemoveEntryInternal(ZipArchiveEntry entry) internal void RemoveEntryInternal(ZipArchiveEntry entry)
{ {

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); 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] [Test]
public void EvaluateEmptyVariableAsBoolean () 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 (); var error = MonoBtlsError.GetError ();
if (error == null)
return new MonoBtlsException (status);
var text = MonoBtlsError.GetErrorString (error); var text = MonoBtlsError.GetErrorString (error);
return new MonoBtlsException ("{0} {1}", status, text); return new MonoBtlsException ("{0} {1}", status, text);
} }

View File

@ -45,12 +45,14 @@ namespace Mono.Btls
static class MonoBtlsX509StoreManager static class MonoBtlsX509StoreManager
{ {
static bool initialized; static bool initialized;
#if !ANDROID
static string machineTrustedRootPath; static string machineTrustedRootPath;
static string machineIntermediateCAPath; static string machineIntermediateCAPath;
static string machineUntrustedPath; static string machineUntrustedPath;
static string userTrustedRootPath; static string userTrustedRootPath;
static string userIntermediateCAPath; static string userIntermediateCAPath;
static string userUntrustedPath; static string userUntrustedPath;
#endif
static void Initialize () static void Initialize ()
{ {
@ -75,9 +77,9 @@ namespace Mono.Btls
userUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted); userUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted);
var machinePath = MX.X509StoreManager.NewLocalMachinePath; var machinePath = MX.X509StoreManager.NewLocalMachinePath;
machineTrustedRootPath = Path.Combine (userPath, MX.X509Stores.Names.TrustedRoot); machineTrustedRootPath = Path.Combine (machinePath, MX.X509Stores.Names.TrustedRoot);
machineIntermediateCAPath = Path.Combine (userPath, MX.X509Stores.Names.IntermediateCA); machineIntermediateCAPath = Path.Combine (machinePath, MX.X509Stores.Names.IntermediateCA);
machineUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted); machineUntrustedPath = Path.Combine (machinePath, MX.X509Stores.Names.Untrusted);
#endif #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 () static void InitializeProviderRegistration ()
{ {
lock (locker) { lock (locker) {
if (providerRegistration != null) if (providerRegistration != null)
return; return;
providerRegistration = new Dictionary<string,string> (); providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("legacy", "Mono.Net.Security.LegacyTlsProvider"); providerRegistration.Add ("legacy", LegacyProviderTypeName);
providerRegistration.Add ("default", "Mono.Net.Security.LegacyTlsProvider");
if (IsBtlsSupported ()) bool btls_supported = IsBtlsSupported ();
providerRegistration.Add ("btls", "Mono.Btls.MonoBtlsProvider"); if (btls_supported)
providerRegistration.Add ("btls", BtlsProviderTypeName);
providerRegistration.Add ("default", btls_supported && !Platform.IsMacOS ? BtlsProviderTypeName : LegacyProviderTypeName);
X509Helper2.Initialize (); X509Helper2.Initialize ();
} }
} }

View File

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

View File

@ -17,7 +17,14 @@ namespace MonoTests.System.Net.WebSockets
public class ClientWebSocketTest public class ClientWebSocketTest
{ {
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx"; 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;
HttpListener listener { HttpListener listener {
get { get {
@ -158,7 +165,12 @@ namespace MonoTests.System.Net.WebSockets
Assert.AreEqual (WebSocketState.Closed, socket.State); 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 () public void SendAsyncArgTest_NotConnected ()
{ {
socket.SendAsync (new ArraySegment<byte> (new byte[0]), WebSocketMessageType.Text, true, CancellationToken.None); 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); 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 () public void ReceiveAsyncArgTest_NotConnected ()
{ {
socket.ReceiveAsync (new ArraySegment<byte> (new byte[0]), CancellationToken.None); 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; return d;
} }
#if !MONO
// CharSet.Auto is needed to work on Windows 98 and Windows Me // CharSet.Auto is needed to work on Windows 98 and Windows Me
[DllImport("kernel32.dll", CharSet=CharSet.Auto, BestFitMapping=false)] [DllImport("kernel32.dll", CharSet=CharSet.Auto, BestFitMapping=false)]
// SxS: Time formatting does not expose any system resource hence Resource Exposure scope is None. // 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; this.Milliseconds = (ushort)dateTime.Millisecond;
} }
} }
#endif
// string ms:format-date(string datetime[, string format[, string language]]) // string ms:format-date(string datetime[, string format[, string language]])
// string ms:format-time(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. // 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) { public static string MSFormatDateTime(string dateTime, string format, string lang, bool isDate) {
try { try {
int locale = GetCultureInfo(lang).LCID;
XsdDateTime xdt; XsdDateTime xdt;
if (! XsdDateTime.TryParse(dateTime, XsdDateTimeFlags.AllXsd | XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrTimeNoTz, out xdt)) { if (! XsdDateTime.TryParse(dateTime, XsdDateTimeFlags.AllXsd | XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrTimeNoTz, out xdt)) {
return string.Empty; 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()); SystemTime st = new SystemTime(xdt.ToZulu());
StringBuilder sb = new StringBuilder(format.Length + 16); StringBuilder sb = new StringBuilder(format.Length + 16);
@ -373,6 +385,7 @@ namespace System.Xml.Xsl.Runtime {
} }
} }
return sb.ToString(); return sb.ToString();
#endif
} catch (ArgumentException) { // Operations with DateTime can throw this exception eventualy } catch (ArgumentException) { // Operations with DateTime can throw this exception eventualy
return string.Empty; return string.Empty;
} }

View File

@ -1 +1 @@
bb2bd6e19718cad38c3cf37e8eb131b1b6581685 a9748379086bbde75a62e2c78329576af82f3755

View File

@ -10,6 +10,7 @@ class X
if (ReferenceEquals (a, b)) if (ReferenceEquals (a, b))
return 2; return 2;
a = new byte[0];
b = new byte[0]; b = new byte[0];
if (a.Equals (b)) if (a.Equals (b))
return 3; return 3;

View File

@ -1 +1 @@
f9c8f8b2465c7c00ddc1831c311422c9785ad594 87b874ce09a0b6bdfc9838d7b448fc99531f03a8

View File

@ -372,7 +372,7 @@ class MakeBundle {
if (fetch_target != null){ if (fetch_target != null){
var directory = Path.Combine (targets_dir, fetch_target); var directory = Path.Combine (targets_dir, fetch_target);
var zip_download = Path.Combine (directory, "sdk.zip"); var zip_download = Path.Combine (directory, "sdk.zip");
Directory.CreateDirectory (Path.GetDirectoryName (directory)); Directory.CreateDirectory (directory);
var wc = new WebClient (); var wc = new WebClient ();
var uri = new Uri ($"{target_server}{fetch_target}"); var uri = new Uri ($"{target_server}{fetch_target}");
try { try {

View File

@ -32,7 +32,12 @@ namespace Mono
return false; return false;
TypeDefinition type = null; TypeDefinition type = null;
var nested = sfData.TypeFullName.Split ('+'); string[] nested;
if (sfData.TypeFullName.IndexOf ('/') >= 0)
nested = sfData.TypeFullName.Split ('/');
else
nested = sfData.TypeFullName.Split ('+');
var types = assembly.MainModule.Types; var types = assembly.MainModule.Types;
foreach (var ntype in nested) { foreach (var ntype in nested) {
if (type == null) { if (type == null) {
@ -53,11 +58,16 @@ namespace Mono
var parensStart = sfData.MethodSignature.IndexOf ('('); var parensStart = sfData.MethodSignature.IndexOf ('(');
var methodName = sfData.MethodSignature.Substring (0, parensStart).TrimEnd (); var methodName = sfData.MethodSignature.Substring (0, parensStart).TrimEnd ();
var methodParameters = sfData.MethodSignature.Substring (parensStart); var methodParameters = sfData.MethodSignature.Substring (parensStart);
var method = type.Methods.FirstOrDefault (m => CompareName (m, methodName) && CompareParameters (m.Parameters, methodParameters)); var methods = type.Methods.Where (m => CompareName (m, methodName) && CompareParameters (m.Parameters, methodParameters)).ToArray ();
if (method == null) { if (methods.Length == 0) {
logger.LogWarning ("Could not find method: {0}", methodName); logger.LogWarning ("Could not find method: {0}", methodName);
return false; return false;
} }
if (methods.Length > 1) {
logger.LogWarning ("Ambiguous match for method: {0}", sfData.MethodSignature);
return false;
}
var method = methods [0];
int ilOffset; int ilOffset;
if (sfData.IsILOffset) { if (sfData.IsILOffset) {
@ -102,6 +112,9 @@ namespace Mono
return false; return false;
var genStart = expected.IndexOf ('['); var genStart = expected.IndexOf ('[');
if (genStart < 0)
genStart = expected.IndexOf ('<');
if (genStart < 0) if (genStart < 0)
return false; return false;
@ -117,6 +130,36 @@ namespace Mono
return candidate.GenericParameters.Count == arity; return candidate.GenericParameters.Count == arity;
} }
static string RemoveGenerics (string expected, char open, char close)
{
if (expected.IndexOf (open) < 0)
return expected;
var sb = new StringBuilder ();
for (int i = 0; i < expected.Length;) {
int start = expected.IndexOf (open, i);
int end = expected.IndexOf (close, i);
if (start < 0 || end < 0) {
sb.Append (expected, i, expected.Length - i);
break;
}
bool is_ginst = false;
for (int j = start + 1; j < end; ++j) {
if (expected [j] != ',')
is_ginst = true;
}
if (is_ginst) //discard the the generic args
sb.Append (expected, i, start - i);
else //include array arity
sb.Append (expected, i, end + 1 - i);
i = end + 1;
}
return sb.ToString ();
}
static bool CompareParameters (Collection<ParameterDefinition> candidate, string expected) static bool CompareParameters (Collection<ParameterDefinition> candidate, string expected)
{ {
var builder = new StringBuilder (); var builder = new StringBuilder ();
@ -131,11 +174,6 @@ namespace Mono
builder.Append ("...,"); builder.Append ("...,");
var pt = parameter.ParameterType; var pt = parameter.ParameterType;
if (!string.IsNullOrEmpty (pt.Namespace)) {
builder.Append (pt.Namespace);
builder.Append (".");
}
FormatElementType (pt, builder); FormatElementType (pt, builder);
builder.Append (" "); builder.Append (" ");
@ -144,7 +182,150 @@ namespace Mono
builder.Append (")"); builder.Append (")");
return builder.ToString () == expected; if (builder.ToString () == RemoveGenerics (expected, '[', ']'))
return true;
//now try the compact runtime format.
builder.Clear ();
builder.Append ("(");
for (int i = 0; i < candidate.Count; i++) {
var parameter = candidate [i];
if (i > 0)
builder.Append (",");
if (parameter.ParameterType.IsSentinel)
builder.Append ("...,");
var pt = parameter.ParameterType;
RuntimeFormatElementType (pt, builder);
}
builder.Append (")");
if (builder.ToString () == RemoveGenerics (expected, '<', '>'))
return true;
return false;
}
static void RuntimeFormatElementType (TypeReference tr, StringBuilder builder)
{
var ts = tr as TypeSpecification;
if (ts != null) {
if (ts.IsByReference) {
RuntimeFormatElementType (ts.ElementType, builder);
builder.Append ("&");
return;
}
}
switch (tr.MetadataType) {
case MetadataType.Void:
builder.Append ("void");
break;
case MetadataType.Boolean:
builder.Append ("bool");
break;
case MetadataType.Char:
builder.Append ("char");
break;
case MetadataType.SByte:
builder.Append ("sbyte");
break;
case MetadataType.Byte:
builder.Append ("byte");
break;
case MetadataType.Int16:
builder.Append ("int16");
break;
case MetadataType.UInt16:
builder.Append ("uint16");
break;
case MetadataType.Int32:
builder.Append ("int");
break;
case MetadataType.UInt32:
builder.Append ("uint");
break;
case MetadataType.Int64:
builder.Append ("long");
break;
case MetadataType.UInt64:
builder.Append ("ulong");
break;
case MetadataType.Single:
builder.Append ("single");
break;
case MetadataType.Double:
builder.Append ("double");
break;
case MetadataType.String:
builder.Append ("string");
break;
case MetadataType.Pointer:
builder.Append (((TypeSpecification)tr).ElementType);
builder.Append ("*");
break;
case MetadataType.ValueType:
case MetadataType.Class:
case MetadataType.GenericInstance: {
FormatName (tr, builder, '/');
break;
}
case MetadataType.Var:
case MetadataType.MVar:
builder.Append (tr.Name);
builder.Append ("_REF");
break;
case MetadataType.Array: {
var array = (ArrayType)tr;
RuntimeFormatElementType (array.ElementType, builder);
builder.Append ("[");
for (int i = 0; i < array.Rank - 1; ++i)
builder.Append (",");
builder.Append ("]");
break;
}
case MetadataType.TypedByReference:
builder.Append ("typedbyref");
break;
case MetadataType.IntPtr:
builder.Append ("intptr");
break;
case MetadataType.UIntPtr:
builder.Append ("uintptr");
break;
case MetadataType.FunctionPointer:
builder.Append ("*()");
break;
case MetadataType.Object:
builder.Append ("object");
break;
default:
builder.Append ("-unknown-");
break;
}
}
static void FormatName (TypeReference tr, StringBuilder builder, char sep)
{
if (tr.IsNested && !(tr.MetadataType == MetadataType.Var || tr.MetadataType == MetadataType.MVar)) {
FormatName (tr.DeclaringType, builder, sep);
builder.Append (sep);
}
if (!string.IsNullOrEmpty (tr.Namespace)) {
builder.Append (tr.Namespace);
builder.Append (".");
}
builder.Append (tr.Name);
} }
static void FormatElementType (TypeReference tr, StringBuilder builder) static void FormatElementType (TypeReference tr, StringBuilder builder)
@ -170,8 +351,7 @@ namespace Mono
return; return;
} }
} }
FormatName (tr, builder, '+');
builder.Append (tr.Name);
} }
} }
} }

View File

@ -84,7 +84,8 @@ namespace Mono
typeFullName = str.Substring (0, typeNameEnd); typeFullName = str.Substring (0, typeNameEnd);
// Remove generic parameters // Remove generic parameters
typeFullName = Regex.Replace (typeFullName, @"\[[^\[\]]*\]", ""); typeFullName = Regex.Replace (typeFullName, @"\[[^\[\]]*\]$", "");
typeFullName = Regex.Replace (typeFullName, @"\<[^\[\]]*\>$", "");
methodSignature = str.Substring (typeNameEnd + 1); methodSignature = str.Substring (typeNameEnd + 1);

View File

@ -163,7 +163,10 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
break; break;
case MONO_TYPE_ARRAY: case MONO_TYPE_ARRAY:
mono_type_get_desc (res, &type->data.array->eklass->byval_arg, include_namespace); mono_type_get_desc (res, &type->data.array->eklass->byval_arg, include_namespace);
g_string_append_printf (res, "[%d]", type->data.array->rank); g_string_append_c (res, '[');
for (i = 1; i < type->data.array->rank; ++i)
g_string_append_c (res, ',');
g_string_append_c (res, ']');
break; break;
case MONO_TYPE_SZARRAY: case MONO_TYPE_SZARRAY:
mono_type_get_desc (res, &type->data.klass->byval_arg, include_namespace); mono_type_get_desc (res, &type->data.klass->byval_arg, include_namespace);

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