Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -139,7 +139,7 @@ namespace System.Net {
set
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.ControlPolicyPermission.Demand();
#endif
Instance.CredentialPolicy = value;
@@ -205,7 +205,7 @@ namespace System.Net {
/// </devdoc>
public static void Register(IAuthenticationModule authenticationModule)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Register(authenticationModule);
@@ -216,7 +216,7 @@ namespace System.Net {
/// </devdoc>
public static void Unregister(IAuthenticationModule authenticationModule)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Unregister(authenticationModule);
@@ -227,7 +227,7 @@ namespace System.Net {
/// </devdoc>
public static void Unregister(string authenticationScheme)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
Instance.Unregister(authenticationScheme);

View File

@@ -302,7 +302,7 @@ namespace System.Net {
get {
//This check will not allow to use local user credentials at will.
//Hence the username will not be exposed to the network
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
#endif
return SystemNetworkCredential.defaultCredential;
@@ -313,7 +313,7 @@ namespace System.Net {
get {
//This check will not allow to use local user credentials at will.
//Hence the username will not be exposed to the network
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
#endif
return SystemNetworkCredential.defaultCredential;

View File

@@ -183,8 +183,8 @@ namespace System.Net {
// call !
//
SocketException e = null;
long scope = 0;
#if !MONO
long scope = 0;
if(Socket.OSSupportsIPv6)
{
byte[] bytes = new byte[IPv6AddressBytes];

View File

@@ -143,7 +143,7 @@ namespace System.Net {
private static void DemandCallback(object state)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
((CodeAccessPermission) state).Demand();
#endif
}
@@ -309,7 +309,9 @@ namespace System.Net {
private static IPHostEntry GetLocalHost()
{
#if MONO
#pragma warning disable 618
return Dns.GetHostByName (Dns.GetHostName ());
#pragma warning restore
#else
//
// IPv6 Changes: If IPv6 is enabled, we can't simply use the
@@ -953,7 +955,7 @@ namespace System.Net {
// There are threading tricks a malicious app can use to create an ArraySegment with mismatched
// array/offset/count. Copy locally and make sure they're valid before using them.
internal static void ValidateSegment(ArraySegment<byte> segment) {
if (segment == null || segment.Array == null) {
if (/*segment == null ||*/ segment.Array == null) {
throw new ArgumentNullException("segment");
}
// Length zero is explicitly allowed
@@ -966,7 +968,7 @@ namespace System.Net {
internal static class ExceptionHelper
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
internal static readonly KeyContainerPermission KeyContainerPermissionOpen = new KeyContainerPermission(KeyContainerPermissionFlags.Open);
internal static readonly WebPermission WebPermissionUnrestricted = new WebPermission(NetworkAccess.Connect);
internal static readonly SecurityPermission UnmanagedPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);

View File

@@ -26,7 +26,7 @@ namespace System.Net {
/// </devdoc>
public class NetworkCredential : ICredentials,ICredentialsByHost {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
private static volatile EnvironmentPermission m_environmentUserNamePermission;
private static volatile EnvironmentPermission m_environmentDomainNamePermission;
private static readonly object lockingObject = new object();
@@ -91,7 +91,7 @@ namespace System.Net {
}
#endif //!FEATURE_PAL
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
void InitializePart1() {
if (m_environmentUserNamePermission == null) {
lock(lockingObject) {
@@ -111,7 +111,7 @@ namespace System.Net {
/// </devdoc>
public string UserName {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
InitializePart1();
m_environmentUserNamePermission.Demand();
#endif
@@ -133,7 +133,7 @@ namespace System.Net {
/// </devdoc>
public string Password {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
return InternalGetPassword();
@@ -162,7 +162,7 @@ namespace System.Net {
/// </devdoc>
public SecureString SecurePassword {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.UnmanagedPermission.Demand();
#endif
return InternalGetSecurePassword().Copy();
@@ -184,7 +184,7 @@ namespace System.Net {
/// </devdoc>
public string Domain {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
InitializePart1();
m_environmentDomainNamePermission.Demand();
#endif

View File

@@ -16,7 +16,7 @@ namespace System.Net.NetworkInformation
{
#if MONODROID
return new AndroidIPGlobalProperties ();
#elif MONOTOUCH || XAMMAC || MOBILE_STATIC
#elif MONOTOUCH || XAMMAC
return new UnixIPGlobalProperties ();
#elif MONO
switch (Environment.OSVersion.Platform) {
@@ -34,7 +34,11 @@ namespace System.Net.NetworkInformation
}
return new UnixIPGlobalProperties ();
default:
#if WIN_PLATFORM
return new Win32IPGlobalProperties ();
#else
return new UnixIPGlobalProperties ();
#endif
}
#else
(new NetworkInformationPermission(NetworkInformationAccess.Read)).Demand();

View File

@@ -8,7 +8,7 @@ namespace System.Net.NetworkInformation
{
/// Returns objects that describe the network interfaces on the local computer.
public static NetworkInterface[] GetAllNetworkInterfaces(){
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
(new NetworkInformationPermission(NetworkInformationAccess.Read)).Demand();
#endif
return SystemNetworkInterface.GetNetworkInterfaces();

View File

@@ -93,7 +93,7 @@ namespace System.Net {
return m_BindIPEndPointDelegate;
}
set {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.InfrastructurePermission.Demand();
#endif
m_BindIPEndPointDelegate = value;
@@ -460,7 +460,7 @@ namespace System.Net {
throw new NotSupportedException(SR.GetString(SR.net_servicePointAddressNotSupportedInHostMode));
}
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
// Don't let low-trust apps discover the proxy information.
if (m_ProxyServicePoint)
{

View File

@@ -1 +1 @@
c8a3da853476918de06973dfe4cb78058a0e20d4
ee56c48eabc29f3a64539b00758f7abba3abc914

View File

@@ -285,8 +285,13 @@ namespace System.Net.Sockets {
throw new ArgumentNullException("asyncResult");
}
#if MONO
var sar = asyncResult as SocketAsyncResult;
Socket asyncSocket = sar == null ? null : sar.socket;
#else
LazyAsyncResult lazyResult = asyncResult as LazyAsyncResult;
Socket asyncSocket = lazyResult == null ? null : lazyResult.AsyncObject as Socket;
#endif
if (asyncSocket == null)
{
throw new ArgumentException(SR.GetString(SR.net_io_invalidasyncresult), "asyncResult");
@@ -318,8 +323,13 @@ namespace System.Net.Sockets {
throw new ArgumentNullException("asyncResult");
}
#if MONO
var sar = asyncResult as SocketAsyncResult;
Socket asyncSocket = sar == null ? null : sar.socket;
#else
LazyAsyncResult lazyResult = asyncResult as LazyAsyncResult;
Socket asyncSocket = lazyResult == null ? null : lazyResult.AsyncObject as Socket;
#endif
if (asyncSocket == null)
{
throw new ArgumentException(SR.GetString(SR.net_io_invalidasyncresult), "asyncResult");

View File

@@ -365,7 +365,7 @@ namespace System.Net {
throw new ArgumentNullException("creator");
}
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
@@ -622,7 +622,7 @@ namespace System.Net {
return RequestCacheManager.GetBinding(string.Empty).Policy;
}
set {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
// This is a replacement of RequestCachePermission demand since we are not including the latest in the product.
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
@@ -1108,7 +1108,7 @@ namespace System.Net {
{
get
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return InternalDefaultWebProxy;
@@ -1116,7 +1116,7 @@ namespace System.Net {
set
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
InternalDefaultWebProxy = value;
@@ -1128,7 +1128,7 @@ namespace System.Net {
//
public static IWebProxy GetSystemWebProxy()
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return InternalGetSystemWebProxy();
@@ -1209,7 +1209,6 @@ namespace System.Net {
}
}
#if !MONO
//
internal void SetupCacheProtocol(Uri uri)
{
@@ -1224,6 +1223,7 @@ namespace System.Net {
}
}
#if !MONO
delegate void DelEtwFireBeginWRGet(object id, string uri, bool success, bool synchronous);
delegate void DelEtwFireEndWRGet(object id, bool success, bool synchronous);
delegate void DelEtwFireEndWRespGet(object id, bool success, bool synchronous, int statusCode);

View File

@@ -381,7 +381,7 @@ namespace System.Net.Security {
// demand the same permissions, then we should remove our
// demand here.
//
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.KeyContainerPermissionOpen.Demand();
#endif
@@ -437,7 +437,7 @@ namespace System.Net.Security {
// For v 1.1 compat We want to ensure the store is opened under the **process** acount.
//
try {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
using (WindowsIdentity.Impersonate(IntPtr.Zero))
#endif
{
@@ -583,7 +583,7 @@ namespace System.Net.Security {
// Note: We call a user certificate selection delegate under permission
// assert but the signature of the delegate is unique so it's safe
//
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
private bool AcquireClientCredentials(ref byte[] thumbPrint)
@@ -832,7 +832,7 @@ namespace System.Net.Security {
// Note: We call a user certificate selection delegate under permission
// assert but the signature of the delegate is unique so it's safe
//
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
private bool AcquireServerCredentials(ref byte[] thumbPrint)
@@ -919,7 +919,7 @@ namespace System.Net.Security {
//
// For v 1.1 compat We want to ensure the credential are accessed under >>process<< acount.
//
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
using (WindowsIdentity.Impersonate(IntPtr.Zero))
#endif
{
@@ -1298,7 +1298,7 @@ namespace System.Net.Security {
//SECURITY: The scenario is allowed in semitrust StorePermission is asserted for Chain.Build
// A user callback has unique signature so it is safe to call it under permisison assert.
//
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
[StorePermission(SecurityAction.Assert, Unrestricted=true)]
#endif
internal bool VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)

View File

@@ -43,7 +43,7 @@ namespace System.Net {
//
public override int Count {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable.Count;
@@ -108,7 +108,7 @@ namespace System.Net {
//
public override ICollection Keys {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable.Keys;
@@ -118,7 +118,7 @@ namespace System.Net {
public override object SyncRoot {
[HostProtection(Synchronization=true)]
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return m_SyncTable;
@@ -127,7 +127,7 @@ namespace System.Net {
//
public override ICollection Values {
get {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
if (m_ValuesWrapper == null)
@@ -144,7 +144,7 @@ namespace System.Net {
}
//
public override void Clear() {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
m_SyncTable.Clear();
@@ -156,7 +156,7 @@ namespace System.Net {
}
//
public override bool ContainsValue(string value) {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
foreach (SpnToken spnToken in m_SyncTable.Values)
@@ -169,7 +169,7 @@ namespace System.Net {
// We have to unwrap the SpnKey and just expose the Spn
public override void CopyTo(Array array, int index) {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
CheckCopyToArguments(array, index, Count);
@@ -183,7 +183,7 @@ namespace System.Net {
}
//
public override IEnumerator GetEnumerator() {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
@@ -211,7 +211,7 @@ namespace System.Net {
try {
Uri uri = new Uri(key);
key = uri.GetParts(UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped);
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
new WebPermission(NetworkAccess.Connect, new Uri(key)).Demand();
#endif
}

View File

@@ -146,7 +146,9 @@ namespace System.Net {
}
public object OwningObject;
public GeneralAsyncDelegate AsyncCallback;
#if !MONO
public bool Completed;
#endif
public ConnectionPool Pool;
public int CreationTimeout;
}
@@ -811,7 +813,9 @@ namespace System.Net {
/// </devdoc>
sealed internal class InterlockedStack {
private readonly Stack _stack = new Stack();
#if !MONO
private int _count;
#endif
#if DEBUG
private readonly Hashtable doublepush = new Hashtable();
@@ -832,7 +836,9 @@ namespace System.Net {
#if DEBUG
GlobalLog.Assert(_count+1 == _stack.Count, "push count mishandle");
#endif
#if !MONO
_count = _stack.Count;
#endif
}
}
@@ -845,7 +851,9 @@ namespace System.Net {
GlobalLog.Assert(_count-1 == _stack.Count, "pop count mishandle");
doublepush.Remove(pooledStream);
#endif
#if !MONO
_count = _stack.Count;
#endif
}
return pooledStream;
}

View File

@@ -379,7 +379,9 @@ namespace System.Net {
DateTime tempUsed;
CookieCollection lruCc = null;
#if !MONO
string lruDomain = null;
#endif
string tempDomain = null;
PathList pathList;
@@ -415,7 +417,9 @@ namespace System.Net {
// we also find the least used cookie collection in ENTIRE container
// we count the collection as LRU only if it holds 1+ elements
if (cc.Count > 0 && (tempUsed = cc.TimeStamp(CookieCollection.Stamp.Check)) < oldUsed) {
#if !MONO
lruDomain = tempDomain;
#endif
lruCc = cc;
oldUsed = tempUsed;
}

View File

@@ -18,8 +18,10 @@ namespace System.Net {
private static WaitCallback s_GetRequestStreamCallback = new WaitCallback(GetRequestStreamCallback);
private static WaitCallback s_GetResponseCallback = new WaitCallback(GetResponseCallback);
#if !MONO
private static ContextCallback s_WrappedGetRequestStreamCallback = new ContextCallback(GetRequestStreamCallback);
private static ContextCallback s_WrappedResponseCallback = new ContextCallback(GetResponseCallback);
#endif
// fields
@@ -214,7 +216,9 @@ namespace System.Net {
public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state)
{
GlobalLog.Enter("FileWebRequest::BeginGetRequestStream");
#if !MONO
bool success = true;
#endif
try {
if (Aborted)
throw ExceptionHelper.RequestAbortedException;
@@ -242,7 +246,9 @@ namespace System.Net {
m_ReadAResult = new LazyAsyncResult(this, state, callback);
ThreadPool.QueueUserWorkItem(s_GetRequestStreamCallback, m_ReadAResult);
} catch (Exception exception) {
#if !MONO
success = false;
#endif
if(Logging.On)Logging.Exception(Logging.Web, this, "BeginGetRequestStream", exception);
throw;
} finally {
@@ -261,7 +267,9 @@ namespace System.Net {
public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
{
GlobalLog.Enter("FileWebRequest::BeginGetResponse");
#if !MONO
bool success = true;
#endif
try {
if (Aborted)
@@ -278,7 +286,9 @@ namespace System.Net {
m_WriteAResult = new LazyAsyncResult(this,state,callback);
ThreadPool.QueueUserWorkItem(s_GetResponseCallback,m_WriteAResult);
} catch (Exception exception) {
#if !MONO
success = false;
#endif
if(Logging.On)Logging.Exception(Logging.Web, this, "BeginGetResponse", exception);
throw;
} finally {
@@ -302,7 +312,9 @@ namespace System.Net {
GlobalLog.Enter("FileWebRequest::EndGetRequestStream");
Stream stream;
#if !MONO
bool success = false;
#endif
try {
LazyAsyncResult ar = asyncResult as LazyAsyncResult;
if (asyncResult == null || ar == null) {
@@ -317,7 +329,9 @@ namespace System.Net {
}
stream = (Stream) result;
m_writePending = false;
#if !MONO
success = true;
#endif
} catch (Exception exception) {
if(Logging.On)Logging.Exception(Logging.Web, this, "EndGetRequestStream", exception);
throw;
@@ -338,7 +352,9 @@ namespace System.Net {
GlobalLog.Enter("FileWebRequest::EndGetResponse");
WebResponse response;
#if !MONO
bool success = false;
#endif
try {
LazyAsyncResult ar = asyncResult as LazyAsyncResult;
if (asyncResult == null || ar == null) {
@@ -354,7 +370,9 @@ namespace System.Net {
}
response = (WebResponse) result;
m_readPending = false;
#if !MONO
success = true;
#endif
} catch (Exception exception) {
if(Logging.On)Logging.Exception(Logging.Web, this, "EndGetResponse", exception);
throw;

View File

@@ -30,7 +30,7 @@ namespace System.Net.Mime
//used when the length of the header name itself is known (i.e. Subject : )
internal static string EncodeHeaderValue(string value, Encoding encoding, bool base64Encoding, int headerLength) {
StringBuilder newString = new StringBuilder();
// StringBuilder newString = new StringBuilder();
//no need to encode if it's pure ascii
if (IsAscii(value, false)) {

View File

@@ -1 +1 @@
80acb75ad34e7d3d5b2b24817a568c07b451b34f
96cf1c91007b018d4ecf5507a5e221a47f103a1d

View File

@@ -414,7 +414,7 @@ namespace System.Net {
/// </devdoc>
[Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
public static WebProxy GetDefaultProxy() {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return new WebProxy(true);
@@ -437,7 +437,7 @@ namespace System.Net {
if (useRegistry) {
// just make the proxy advanced, don't populate with any settings
// note - this will happen in the context of the user performing the deserialization (their proxy settings get read)
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
UnsafeUpdateFromRegistry();
@@ -513,15 +513,17 @@ namespace System.Net {
var data = AndroidPlatform.GetDefaultProxy ();
if (data != null)
return data;
return new WebProxy (true);
#else
if (Platform.IsMacOS) {
var data = Mono.Net.CFNetwork.GetDefaultProxy ();
if (data != null)
return data;
}
#endif
return new WebProxy (true);
#endif
}
#endif

View File

@@ -166,7 +166,7 @@ namespace System {
//
public static void Register(UriParser uriParser, string schemeName, int defaultPort)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
ExceptionHelper.InfrastructurePermission.Demand();
#endif
if (uriParser == null)