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

@@ -27,6 +27,11 @@ namespace System
{
LocalAppContext.DefineSwitchDefault(LocalAppContextSwitches.DontEnableSchUseStrongCryptoName, true);
}
if (version <= 40601)
{
LocalAppContext.DefineSwitchDefault(LocalAppContextSwitches.MemberDescriptorEqualsReturnsFalseIfEquivalentName, true);
}
break;
}
case "WindowsPhone":
@@ -34,7 +39,7 @@ namespace System
{
if (version <= 80100)
{
LocalAppContext.DefineSwitchDefault(LocalAppContextSwitches.DontEnableSchUseStrongCryptoName, true);
LocalAppContext.DefineSwitchDefault(LocalAppContextSwitches.DontEnableSchUseStrongCryptoName, true);
}
break;
}

View File

@@ -11,7 +11,21 @@ namespace System
internal static class LocalAppContextSwitches
{
#region System.Net quirks
#region System quirks
private static int _memberDescriptorEqualsReturnsFalseIfEquivalent;
internal const string MemberDescriptorEqualsReturnsFalseIfEquivalentName = @"Switch.System.MemberDescriptorEqualsReturnsFalseIfEquivalent";
public static bool MemberDescriptorEqualsReturnsFalseIfEquivalent
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return LocalAppContext.GetCachedSwitchValue(MemberDescriptorEqualsReturnsFalseIfEquivalentName, ref _memberDescriptorEqualsReturnsFalseIfEquivalent);
}
}
#endregion
#region System.Net quirks
private static int _dontEnableSchUseStrongCrypto;
internal const string DontEnableSchUseStrongCryptoName = @"Switch.System.Net.DontEnableSchUseStrongCrypto";
@@ -23,9 +37,7 @@ namespace System
return LocalAppContext.GetCachedSwitchValue(DontEnableSchUseStrongCryptoName, ref _dontEnableSchUseStrongCrypto);
}
}
#endregion
#region System.Net.WebSockets.HttpListenerAsyncEventArgs
private static int _allocateOverlappedOnDemand;
internal const string AllocateOverlappedOnDemandName = @"Switch.System.Net.WebSockets.HttpListenerAsyncEventArgs.AllocateOverlappedOnDemand";
@@ -37,7 +49,18 @@ namespace System
return LocalAppContext.GetCachedSwitchValue(AllocateOverlappedOnDemandName, ref _allocateOverlappedOnDemand);
}
}
#endregion
private static int _dontEnableSchSendAuxRecord;
internal const string DontEnableSchSendAuxRecordName = @"Switch.System.Net.DontEnableSchSendAuxRecord";
public static bool DontEnableSchSendAuxRecord
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return LocalAppContext.GetCachedSwitchValue(DontEnableSchSendAuxRecordName, ref _dontEnableSchSendAuxRecord);
}
}
#endregion
}
}

View File

@@ -34,6 +34,7 @@ namespace System.IO.Ports
#endif
internal static String GetMessage(int errorCode)
{
#if !MONO
StringBuilder sb = new StringBuilder(512);
int result = SafeNativeMethods.FormatMessage(NativeMethods.FORMAT_MESSAGE_IGNORE_INSERTS |
NativeMethods.FORMAT_MESSAGE_FROM_SYSTEM | NativeMethods.FORMAT_MESSAGE_ARGUMENT_ARRAY,
@@ -47,6 +48,7 @@ namespace System.IO.Ports
return s;
}
else
#endif
{
return SR.GetString(SR.IO_UnknownError, errorCode);
}
@@ -76,6 +78,7 @@ namespace System.IO.Ports
}
#endif
#if !MONO
#if FEATURE_NETCORE
[SecuritySafeCritical]
#endif
@@ -93,6 +96,7 @@ namespace System.IO.Ports
int errorCode = Marshal.GetLastWin32Error();
WinIOError(errorCode, str);
}
#endif
// After calling GetLastWin32Error(), it clears the last error field,
// so you must save the HResult and pass it to this method. This method

View File

@@ -1,3 +1,6 @@
#if MONO
#undef FEATURE_PAL
#endif
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
@@ -21,6 +24,7 @@ namespace System.Threading
#endif
using System.Runtime.Versioning;
using System.Runtime.ConstrainedExecution;
using System.Runtime.CompilerServices;
[HostProtection(Synchronization=true, ExternalThreading=true)]
@@ -66,16 +70,28 @@ namespace System.Threading
{
throw new ArgumentException(SR.GetString(SR.Argument_WaitHandleNameTooLong));
}
#if MONO
int errorCode;
var myHandle = new SafeWaitHandle (CreateSemaphore_internal (initialCount, maximumCount, name, out errorCode), true);
#else
SafeWaitHandle myHandle = SafeNativeMethods.CreateSemaphore(null, initialCount, maximumCount, name);
#endif
if (myHandle.IsInvalid)
{
#if !MONO
int errorCode = Marshal.GetLastWin32Error();
#endif
if(null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
throw new WaitHandleCannotBeOpenedException(SR.GetString(SR.WaitHandleCannotBeOpenedException_InvalidHandle,name));
#if MONO
InternalResources.WinIOError(errorCode, "");
#else
InternalResources.WinIOError();
#endif
}
this.SafeWaitHandle = myHandle;
}
@@ -119,6 +135,11 @@ namespace System.Threading
throw new ArgumentException(SR.GetString(SR.Argument_WaitHandleNameTooLong));
}
SafeWaitHandle myHandle;
#if MONO
int errorCode;
myHandle = new SafeWaitHandle (CreateSemaphore_internal (initialCount, maximumCount, name, out errorCode), true);
#else
#if !FEATURE_PAL && !FEATURE_NETCORE
// For ACL's, get the security descriptor from the SemaphoreSecurity.
if (semaphoreSecurity != null) {
@@ -137,12 +158,19 @@ namespace System.Threading
#if !FEATURE_PAL && !FEATURE_NETCORE
}
#endif
int errorCode = Marshal.GetLastWin32Error();
#endif
if (myHandle.IsInvalid)
{
if(null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
throw new WaitHandleCannotBeOpenedException(SR.GetString(SR.WaitHandleCannotBeOpenedException_InvalidHandle,name));
#if MONO
InternalResources.WinIOError(errorCode, "");
#else
InternalResources.WinIOError();
#endif
}
createdNew = errorCode != NativeMethods.ERROR_ALREADY_EXISTS;
this.SafeWaitHandle = myHandle;
@@ -259,7 +287,14 @@ namespace System.Threading
}
result = null;
#if MOBILE
throw new NotSupportedException ();
#else
#if MONO
int errorCode;
var myHandle = new SafeWaitHandle (OpenSemaphore_internal (name, rights, out errorCode), true);
#else
//Pass false to OpenSemaphore to prevent inheritedHandles
#if FEATURE_PAL || FEATURE_NETCORE
const int SYNCHRONIZE = 0x00100000;
@@ -268,11 +303,14 @@ namespace System.Threading
SafeWaitHandle myHandle = SafeNativeMethods.OpenSemaphore(SEMAPHORE_MODIFY_STATE | SYNCHRONIZE, false, name);
#else
SafeWaitHandle myHandle = SafeNativeMethods.OpenSemaphore((int) rights, false, name);
#endif
#endif
if (myHandle.IsInvalid)
{
#if !MONO
int errorCode = Marshal.GetLastWin32Error();
#endif
if (NativeMethods.ERROR_FILE_NOT_FOUND == errorCode || NativeMethods.ERROR_INVALID_NAME == errorCode)
return OpenExistingResult.NameNotFound;
@@ -281,10 +319,15 @@ namespace System.Threading
if (null != name && 0 != name.Length && NativeMethods.ERROR_INVALID_HANDLE == errorCode)
return OpenExistingResult.NameInvalid;
//this is for passed through NativeMethods Errors
#if MONO
InternalResources.WinIOError(errorCode, "");
#else
InternalResources.WinIOError();
#endif
}
result = new Semaphore(myHandle);
return OpenExistingResult.Success;
#endif
}
@@ -318,7 +361,11 @@ namespace System.Threading
// the semaphore's count to exceed the maximum count set when Semaphore was created
//Non-Zero return
#if MONO
if (!ReleaseSemaphore_internal(Handle, releaseCount, out previousCount))
#else
if (!SafeNativeMethods.ReleaseSemaphore(SafeWaitHandle, releaseCount, out previousCount))
#endif
{
throw new SemaphoreFullException();
}
@@ -342,6 +389,19 @@ namespace System.Threading
semaphoreSecurity.Persist(SafeWaitHandle);
}
#endif
#if MONO
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern IntPtr CreateSemaphore_internal (
int initialCount, int maximumCount, string name, out int errorCode);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern bool ReleaseSemaphore_internal (
IntPtr handle, int releaseCount, out int previousCount);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern IntPtr OpenSemaphore_internal (string name, SemaphoreRights rights, out int errorCode);
#endif
}
}

View File

@@ -26,7 +26,9 @@ namespace System.Windows.Markup
/// attached property.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
#if !MOBILE
[TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
#endif
public sealed class ValueSerializerAttribute : Attribute
{
/// <summary>