Imported Upstream version 5.8.0.88

Former-commit-id: 4b7216ffda08448e562271ce733688e761120fc5
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-11-28 19:36:51 +00:00
parent 7d05485754
commit 6123a772ed
277 changed files with 4817 additions and 941 deletions

View File

@@ -227,7 +227,7 @@ namespace Mono.Net.Security
if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
// Flush the write queue.
Debug ("ProcessOperation - flushing write queue");
await Parent.InnerWrite (RunSynchronously, cancellationToken);
await Parent.InnerWrite (RunSynchronously, cancellationToken).ConfigureAwait (false);
}
Debug ("ProcessOperation done: {0} -> {1}", status, newStatus);

View File

@@ -72,6 +72,8 @@ namespace System.Diagnostics
string process_name;
static ProcessModule current_main_module;
/* Private constructor called from other methods */
private Process (SafeProcessHandle handle, int id) {
SetProcessHandle (handle);
@@ -98,7 +100,14 @@ namespace System.Diagnostics
[MonitoringDescription ("The main module of the process.")]
public ProcessModule MainModule {
get {
return(this.Modules[0]);
/* Optimize Process.GetCurrentProcess ().MainModule */
if (processId == NativeMethods.GetCurrentProcessId ()) {
if (current_main_module == null)
current_main_module = this.Modules [0];
return current_main_module;
} else {
return this.Modules [0];
}
}
}

View File

@@ -322,7 +322,7 @@ namespace System.IO.Compression
UnmanagedReadOrWrite feeder; // This will be passed to unmanaged code and used there
Stream base_stream;
IntPtr z_stream;
SafeDeflateStreamHandle z_stream;
GCHandle data;
bool disposed;
byte [] io_buffer;
@@ -337,7 +337,7 @@ namespace System.IO.Compression
dsn.data = GCHandle.Alloc (dsn);
dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite (UnmanagedWrite) : new UnmanagedReadOrWrite (UnmanagedRead);
dsn.z_stream = CreateZStream (mode, gzip, dsn.feeder, GCHandle.ToIntPtr (dsn.data));
if (dsn.z_stream == IntPtr.Zero) {
if (dsn.z_stream.IsInvalid) {
dsn.Dispose (true);
return null;
}
@@ -359,10 +359,7 @@ namespace System.IO.Compression
io_buffer = null;
IntPtr zz = z_stream;
z_stream = IntPtr.Zero;
if (zz != IntPtr.Zero)
CloseZStream (zz); // This will Flush() the remaining output if any
z_stream.Dispose();
}
if (data.IsAllocated) {
@@ -488,21 +485,21 @@ namespace System.IO.Compression
#if !ORBIS
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);
static extern SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern int CloseZStream (IntPtr stream);
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern int Flush (IntPtr stream);
static extern int Flush (SafeDeflateStreamHandle stream);
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern int ReadZStream (IntPtr stream, IntPtr buffer, int length);
static extern int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length);
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern int WriteZStream (IntPtr stream, IntPtr buffer, int length);
static extern int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length);
#else
static IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data)
static SafeDeflateStreamHandle CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data)
{
throw new PlatformNotSupportedException ();
}
@@ -512,22 +509,39 @@ namespace System.IO.Compression
throw new PlatformNotSupportedException ();
}
static int Flush (IntPtr stream)
static int Flush (SafeDeflateStreamHandle stream)
{
throw new PlatformNotSupportedException ();
}
static int ReadZStream (IntPtr stream, IntPtr buffer, int length)
static int ReadZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length)
{
throw new PlatformNotSupportedException ();
}
static int WriteZStream (IntPtr stream, IntPtr buffer, int length)
static int WriteZStream (SafeDeflateStreamHandle stream, IntPtr buffer, int length)
{
throw new PlatformNotSupportedException ();
}
#endif
sealed class SafeDeflateStreamHandle : SafeHandle
{
public override bool IsInvalid
{
get { return handle == IntPtr.Zero; }
}
private SafeDeflateStreamHandle() : base(IntPtr.Zero, true)
{
}
override protected bool ReleaseHandle()
{
DeflateStreamNative.CloseZStream(handle);
return true;
}
}
}
}

View File

@@ -278,6 +278,7 @@ System.Net.Security/SslStreamTest.cs
System.Runtime.Versioning/FrameworkNameTest.cs
System.Security.AccessControl/SemaphoreSecurityTest.cs
System.Security.Cryptography/AsnEncodedDataTest.cs
System.Security.Cryptography/CryptoConfigTest.cs
System.Security.Cryptography/OidCollectionTest.cs
System.Security.Cryptography/OidEnumeratorTest.cs
System.Security.Cryptography/OidTest.cs

View File

@@ -26,7 +26,7 @@ namespace MonoTests.System.ComponentModel
SynchronizationContext sc1 = new SynchronizationContext ();
SynchronizationContext sc2 = new SynchronizationContext ();
#if MONOTOUCH || XAMMAC
#if MONOTOUCH
Assert.IsNotNull (SynchronizationContext.Current, "A1");
#else
Assert.IsNull (SynchronizationContext.Current, "A1");

View File

@@ -170,6 +170,9 @@ namespace MonoTests.System.Net
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
#if MONOTOUCH
[Ignore ("Randomly produces ObjectDisposedExceptions, in particular on device. See bug #39780.")]
#endif
public void HttpBasicAuthScheme ()
{
@@ -290,6 +293,9 @@ namespace MonoTests.System.Net
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
#if MONOTOUCH
[Ignore ("On device sometimes hangs in the call to listener.GetContext (). See bug #60542.")]
#endif
public void HttpRequestIgnoreBadCookies ()
{

View File

@@ -0,0 +1,54 @@
//
// CryptoConfig.cs - NUnit tests for CryptoConfig
//
// Author:
// Chris Hamons <chris.hamons@microsoft.com>
//
// Copyright (c) 2017 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using NUnit.Framework;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace MonoTests.System.Security.Cryptography
{
[TestFixture]
public class CryptoConfigTest
{
[Test]
[TestCase ("http://www.w3.org/2000/09/xmldsig#dsa-sha1")]
[TestCase ("http://www.w3.org/2000/09/xmldsig#rsa-sha1")]
[TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")]
[TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384")]
[TestCase ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512")]
public void CryptoConfig_NonNullDigest (string name)
{
SignatureDescription signatureDescription = CryptoConfig.CreateFromName (name) as SignatureDescription;
Assert.NotNull (signatureDescription.CreateDigest ());
}
}
}