Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@@ -228,5 +228,13 @@ namespace System.Security.Cryptography {
{
throw new NotSupportedException(SR.GetString(SR.NotSupported_SubclassOverride));
}
#if MONO
public virtual byte[] ExportECPrivateKey () => throw new PlatformNotSupportedException ();
public virtual bool TryExportECPrivateKey (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
public virtual void ImportECPrivateKey (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
#endif
}
}

View File

@@ -6,6 +6,9 @@
using System;
using System.IO;
#if MONO
using System.Buffers;
#endif
namespace System.Security.Cryptography {
/// <summary>
@@ -217,5 +220,101 @@ namespace System.Security.Cryptography {
internal static Exception HashAlgorithmNameNullOrEmpty() {
return new ArgumentException(SR.GetString(SR.Cryptography_HashAlgorithmNameNullOrEmpty), "hashAlgorithm");
}
#if MONO // these methods were copied from CoreFX for NS2.1 support
protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
{
byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
try
{
data.CopyTo(array);
byte[] hash = HashData(array, 0, data.Length, hashAlgorithm);
if (hash.Length <= destination.Length)
{
new ReadOnlySpan<byte>(hash).CopyTo(destination);
bytesWritten = hash.Length;
return true;
}
else
{
bytesWritten = 0;
return false;
}
}
finally
{
Array.Clear(array, 0, data.Length);
ArrayPool<byte>.Shared.Return(array);
}
}
public virtual bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten)
{
byte[] result = SignHash(hash.ToArray());
if (result.Length <= destination.Length)
{
new ReadOnlySpan<byte>(result).CopyTo(destination);
bytesWritten = result.Length;
return true;
}
else
{
bytesWritten = 0;
return false;
}
}
public virtual bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
VerifyHash(hash.ToArray(), signature.ToArray());
public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
{
if (string.IsNullOrEmpty(hashAlgorithm.Name))
{
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
}
if (TryHashData(data, destination, hashAlgorithm, out int hashLength) &&
TrySignHash(destination.Slice(0, hashLength), destination, out bytesWritten))
{
return true;
}
bytesWritten = 0;
return false;
}
public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm)
{
if (string.IsNullOrEmpty(hashAlgorithm.Name))
{
throw new ArgumentException(SR.Cryptography_HashAlgorithmNameNullOrEmpty, nameof(hashAlgorithm));
}
for (int i = 256; ; i = checked(i * 2))
{
int hashLength = 0;
byte[] hash = ArrayPool<byte>.Shared.Rent(i);
try
{
if (TryHashData(data, hash, hashAlgorithm, out hashLength))
{
return VerifyHash(new ReadOnlySpan<byte>(hash, 0, hashLength), signature);
}
}
finally
{
Array.Clear(hash, 0, hashLength);
ArrayPool<byte>.Shared.Return(hash);
}
}
}
public virtual byte[] ExportECPrivateKey () => throw new PlatformNotSupportedException ();
public virtual bool TryExportECPrivateKey (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
public virtual void ImportECPrivateKey (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
#endif
}
}

View File

@@ -1 +1 @@
b0f2bbade55e116bef408ce649ffa6eb9685faa0
def972128a60cc12b0f366998a44678553996fcc

View File

@@ -233,7 +233,11 @@ namespace System.Data.Linq.SqlClient {
this.parameterizer.annotations.Add(
node,
new SqlServerCompatibilityAnnotation(
#if (MONO)
Strings.MaxSizeNotSupported(node.SourceExpression), SqlProvider.ProviderMode.Sql2000));
#else
SqlClient.Strings.MaxSizeNotSupported(node.SourceExpression), SqlProvider.ProviderMode.Sql2000));
#endif
return false;
}

View File

@@ -7,7 +7,9 @@
/*
*/
#if MONO
namespace System.Data.Linq
#else
#if Microsoft_NAMESPACE
namespace System.Windows.Forms
#elif DRAWING_NAMESPACE
@@ -23,6 +25,7 @@
#else
namespace System.Windows.Forms
#endif
#endif
{
using System;
using System.Reflection;

View File

@@ -35,9 +35,11 @@ namespace System.Data.Common {
private static DataTable _providerTable;
private static object _lockobj = new object();
static public DbProviderFactory GetFactory(string providerInvariantName) {
ADP.CheckArgumentLength(providerInvariantName, "providerInvariantName");
static public DbProviderFactory GetFactory(string providerInvariantName) => GetFactory(providerInvariantName, true);
static public DbProviderFactory GetFactory(string providerInvariantName, bool throwOnError) {
if (throwOnError)
ADP.CheckArgumentLength(providerInvariantName, "providerInvariantName");
// NOTES: Include the Framework Providers and any other Providers listed in the config file.
DataTable providerTable = GetProviderTable();
if (null != providerTable) {
@@ -54,7 +56,10 @@ namespace System.Data.Common {
return DbProviderFactories.GetFactory(providerRow);
}
}
throw ADP.ConfigProviderNotFound();
if (throwOnError)
throw ADP.ConfigProviderNotFound();
return null;
}
static public DbProviderFactory GetFactory(DataRow providerRow) {
@@ -258,6 +263,12 @@ namespace System.Data.Common {
}
#if MONO
public static bool TryGetFactory(string providerInvariantName, out DbProviderFactory factory)
{
factory = GetFactory(providerInvariantName, throwOnError: false);
return factory != null;
}
public static IEnumerable<string> GetProviderInvariantNames()
{
return _registeredFactories.Keys.ToList();

View File

@@ -20,7 +20,7 @@ namespace System.Data {
/// </para>
/// </devdoc>
[AttributeUsage(AttributeTargets.All)]
[ Obsolete("DataSysDescriptionAttribute has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202", false) ]
[Obsolete("DataSysDescriptionAttribute has been deprecated. https://go.microsoft.com/fwlink/?linkid=14202", false) ]
public class DataSysDescriptionAttribute : DescriptionAttribute {
private bool replaced = false;

View File

@@ -16,7 +16,7 @@ using System.Security.Permissions;
namespace System.Xml
{
[PermissionSetAttribute( SecurityAction.InheritanceDemand, Name = "FullTrust" )]
[Obsolete("Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete("Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public class XmlValidatingReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver {
//
// Member fields

View File

@@ -24,7 +24,7 @@ namespace System.Xml.Schema {
/// The Validate method then uses this internal representation for
/// efficient runtime validation of any given subtree.</para>
/// </devdoc>
[Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete("Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. https://go.microsoft.com/fwlink/?linkid=14202")]
public sealed class XmlSchemaCollection: ICollection {
private Hashtable collection;
private XmlNameTable nameTable;

View File

@@ -13,7 +13,7 @@ namespace System.Xml.Serialization {
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false)]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
public class XmlAnyAttributeAttribute : System.Attribute {
/// <include file='doc\XmlAnyAttributeAttribute.uex' path='docs/doc[@for="XmlAnyAttributeAttribute.XmlAnyAttributeAttribute"]/*' />

View File

@@ -13,7 +13,7 @@ namespace System.Xml.Serialization {
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false)]
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
public class XmlNamespaceDeclarationsAttribute : System.Attribute {
/// <include file='doc\XmlNamespaceDeclarationsAttribute.uex' path='docs/doc[@for="XmlNamespaceDeclarationsAttribute.XmlNamespaceDeclarationsAttribute"]/*' />

View File

@@ -20,17 +20,22 @@ namespace System.Diagnostics {
public Guid ActivityId {
get {
#if !DISABLE_REMOTING
Object id = CallContext.LogicalGetData(activityIdSlotName);
if (id != null)
return (Guid) id;
else
#endif
return Guid.Empty;
}
set {
#if !DISABLE_REMOTING
CallContext.LogicalSetData(activityIdSlotName, value);
#endif
}
}
#if !DISABLE_REMOTING
public Stack LogicalOperationStack {
get {
return GetLogicalOperationStack();
@@ -63,6 +68,11 @@ namespace System.Diagnostics {
return idStack;
}
#else
public Stack LogicalOperationStack => throw new PlatformNotSupportedException ();
public void StartLogicalOperation (object operationId) => throw new PlatformNotSupportedException ();
public void StartLogicalOperation () => throw new PlatformNotSupportedException ();
public void StopLogicalOperation () => throw new PlatformNotSupportedException ();
#endif
}
}

View File

@@ -40,7 +40,11 @@ namespace System.Diagnostics {
public Stack LogicalOperationStack {
get {
#if DISABLE_REMOTING
throw new PlatformNotSupportedException ();
#else
return Trace.CorrelationManager.LogicalOperationStack;
#endif
}
}

View File

@@ -6,7 +6,7 @@
namespace System.Net
{
[Obsolete("This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202")]
[Obsolete("This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. https://go.microsoft.com/fwlink/?linkid=14202")]
public class GlobalProxySelection
{
// This just wraps WebRequest.DefaultWebProxy and modifies it to be compatible with Everett.

View File

@@ -160,10 +160,14 @@ namespace System.Net {
}
} else {
// IPv4 Address serialization
#if MONO
ipAddress.TryWriteBytes(m_Buffer.AsSpan(4), out int bytesWritten);
#else
m_Buffer[4] = unchecked((byte)(ipAddress.m_Address));
m_Buffer[5] = unchecked((byte)(ipAddress.m_Address >> 8));
m_Buffer[6] = unchecked((byte)(ipAddress.m_Address >> 16));
m_Buffer[7] = unchecked((byte)(ipAddress.m_Address >> 24));
#endif
}
}
@@ -177,7 +181,11 @@ namespace System.Net {
if (Family == AddressFamily.InterNetworkV6) {
Contract.Assert(Size >= IPv6AddressSize);
#if MONO
byte[] address = new byte[IPAddressParserStatics.IPv6AddressBytes];
#else
byte[] address = new byte[IPAddress.IPv6AddressBytes];
#endif
for (int i = 0; i < address.Length; i++) {
address[i] = m_Buffer[i + 8];
}

View File

@@ -488,7 +488,7 @@ namespace System.Net.Sockets {
// if the user really wants complete control over Broadcast addresses he needs to
// inherit from UdpClient and gain control over the Socket and do whatever is appropriate.
//
if (Client!=null && !m_IsBroadcast && ipAddress.IsBroadcast) {
if (Client!=null && !m_IsBroadcast && IsBroadcast(ipAddress)) {
//
// we need to set the Broadcast socket option.
// note that, once we set the option on the Socket, we never reset it.
@@ -498,6 +498,18 @@ namespace System.Net.Sockets {
}
}
private static bool IsBroadcast(IPAddress address)
{
if (address.AddressFamily == AddressFamily.InterNetworkV6)
{
// No such thing as a broadcast address for IPv6.
return false;
}
else
{
return address.Equals(IPAddress.Broadcast);
}
}
/// <devdoc>

View File

@@ -1047,13 +1047,6 @@ namespace System.Net {
}
#endif // !FEATURE_PAL
/// <summary>
/// <para>Provides an abstract way of having Async code callback into the request (saves a delegate)</para>
/// </summary>
internal virtual void RequestCallback(object obj) {
throw ExceptionHelper.MethodNotImplementedException;
}
//
// Default Web Proxy implementation.
//

View File

@@ -6,7 +6,7 @@
// Relevant cookie specs:
//
// PERSISTENT<EFBFBD>CLIENT<EFBFBD>STATE HTTP COOKIES (1996)
// PERSISTENT CLIENT STATE HTTP COOKIES (1996)
// From <http://web.archive.org/web/20020803110822/http://wp.netscape.com/newsref/std/cookie_spec.html>
//
// RFC2109 HTTP State Management Mechanism (February 1997)
@@ -119,11 +119,13 @@ namespace System.Net {
/// <para>[To be supplied.]</para>
/// </devdoc>
public CookieContainer() {
#if !WASM
string domain = IPGlobalProperties.InternalGetIPGlobalProperties().DomainName;
if (domain != null && domain.Length > 1)
{
m_fqdnMyDomain = '.' + domain;
}
#endif
//Otherwise it will remain string.Empty
}

View File

@@ -1 +1 @@
30f72959631456d53fff3fedde6449799f9c3e7c
e1527546950d4297d8578925461d4b22d6a48737

View File

@@ -8,7 +8,7 @@ namespace System.Diagnostics.CodeAnalysis
/// enclosed methods and properties from code coverage collection.
/// </summary>
[AttributeUsage(
AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event,
AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Struct,
Inherited = false,
AllowMultiple = false
)]

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