Imported Upstream version 4.4.0.122

Former-commit-id: a99f46acaeba3ab496c7afc02c29b839e30a0d0b
This commit is contained in:
Xamarin Public Jenkins
2016-04-12 13:19:31 -04:00
parent a632333cc7
commit d444f0caa4
118 changed files with 4121 additions and 1632 deletions

View File

@@ -98,4 +98,5 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#endif
[assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
[assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]

View File

@@ -1,74 +0,0 @@
//
// System.Runtime.InteropServices/RuntimeEnvironment.cs
//
// Authors:
// Dominik Fretz (roboto@gmx.net)
// Sebastien Pouliot (sebastien@ximian.com)
//
// (C) 2003 Dominik Fretz
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// 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 System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
namespace System.Runtime.InteropServices
{
[ComVisible (true)]
public class RuntimeEnvironment
{
public RuntimeEnvironment ()
{
}
public static string SystemConfigurationFile {
get {
// GetMachineConfigPath is internal and not protected by CAS
string path = Environment.GetMachineConfigPath ();
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
return path;
}
}
public static bool FromGlobalAccessCache (Assembly a)
{
// yes, this will throw a NullReferenceException (just like MS, reported as ...)
return a.GlobalAssemblyCache;
}
public static string GetRuntimeDirectory ()
{
return Path.GetDirectoryName (typeof (int).Assembly.Location);
}
[SecuritySafeCritical]
public static string GetSystemVersion ()
{
return "v" + Environment.Version.Major + "." + Environment.Version.Minor + "." + Environment.Version.Build;
}
}
}

View File

@@ -0,0 +1,35 @@
//
// INativeCertificateHelper.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2016 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.
namespace System.Security.Cryptography.X509Certificates
{
internal interface INativeCertificateHelper
{
X509CertificateImpl Import (byte[] data, string password, X509KeyStorageFlags flags);
X509CertificateImpl Import (X509Certificate cert);
}
}

View File

@@ -109,17 +109,44 @@ namespace System.Security.Cryptography.X509Certificates {
impl = X509Helper.InitFromHandle (handle);
}
internal X509Certificate (X509CertificateImpl impl)
{
if (impl == null)
throw new ArgumentNullException ("impl");
this.impl = X509Helper.InitFromCertificate (impl);
}
public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert)
{
if (cert == null)
throw new ArgumentNullException ("cert");
X509Helper.ThrowIfContextInvalid (cert.impl);
impl = X509Helper.InitFromCertificate (cert.impl);
impl = X509Helper.InitFromCertificate (cert);
hideDates = false;
}
internal void ImportHandle (X509CertificateImpl impl)
{
Reset ();
this.impl = impl;
}
internal X509CertificateImpl Impl {
get {
X509Helper.ThrowIfContextInvalid (impl);
return impl;
}
}
internal bool IsValid {
get { return X509Helper.IsValid (impl); }
}
internal void ThrowIfContextInvalid ()
{
X509Helper.ThrowIfContextInvalid (impl);
}
// public methods
@@ -161,7 +188,7 @@ namespace System.Security.Cryptography.X509Certificates {
return null;
X509Helper.ThrowIfContextInvalid (impl);
return impl.GetEffectiveDateString ().ToString ();
return impl.GetValidFrom ().ToLocalTime ().ToString ();
}
// strangly there are no DateTime returning function
@@ -171,7 +198,7 @@ namespace System.Security.Cryptography.X509Certificates {
return null;
X509Helper.ThrowIfContextInvalid (impl);
return impl.GetExpirationDateString ().ToString ();
return impl.GetValidUntil ().ToLocalTime ().ToString ();
}
// well maybe someday there'll be support for PGP or SPKI ?

View File

@@ -45,17 +45,15 @@ namespace System.Security.Cryptography.X509Certificates
public abstract X509CertificateImpl Clone ();
public abstract string GetSubjectSummary ();
public abstract string GetIssuerName (bool legacyV1Mode);
public abstract string GetSubjectName (bool legacyV1Mode);
public abstract byte[] GetRawCertData ();
public abstract DateTime GetEffectiveDateString ();
public abstract DateTime GetValidFrom ();
public abstract DateTime GetExpirationDateString ();
public abstract DateTime GetValidUntil ();
byte[] cachedCertificateHash;

View File

@@ -66,12 +66,6 @@ namespace System.Security.Cryptography.X509Certificates
return MX.X501.ToString (x509.GetIssuerName (), true, ", ", true);
}
public override string GetSubjectSummary ()
{
ThrowIfContextInvalid ();
return x509.SubjectName;
}
public override string GetSubjectName (bool legacyV1Mode)
{
ThrowIfContextInvalid ();
@@ -94,16 +88,16 @@ namespace System.Security.Cryptography.X509Certificates
return sha.ComputeHash (x509.RawData);
}
public override DateTime GetEffectiveDateString ()
public override DateTime GetValidFrom ()
{
ThrowIfContextInvalid ();
return x509.ValidFrom.ToLocalTime ();
return x509.ValidFrom;
}
public override DateTime GetExpirationDateString ()
public override DateTime GetValidUntil ()
{
ThrowIfContextInvalid ();
return x509.ValidUntil.ToLocalTime ();
return x509.ValidUntil;
}
public override bool Equals (X509CertificateImpl other, out bool result)
@@ -164,8 +158,8 @@ namespace System.Security.Cryptography.X509Certificates
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("[Subject]{0} {1}{0}{0}", nl, GetSubjectName (false));
sb.AppendFormat ("[Issuer]{0} {1}{0}{0}", nl, GetIssuerName (false));
sb.AppendFormat ("[Not Before]{0} {1}{0}{0}", nl, GetEffectiveDateString ());
sb.AppendFormat ("[Not After]{0} {1}{0}{0}", nl, GetExpirationDateString ());
sb.AppendFormat ("[Not Before]{0} {1}{0}{0}", nl, GetValidFrom ().ToLocalTime ());
sb.AppendFormat ("[Not After]{0} {1}{0}{0}", nl, GetValidUntil ().ToLocalTime ());
sb.AppendFormat ("[Thumbprint]{0} {1}{0}", nl, X509Helper.ToHexString (GetCertHash ()));
sb.Append (nl);
return sb.ToString ();

View File

@@ -30,6 +30,7 @@
//
using System;
using System.Text;
using System.Threading;
using System.Runtime.InteropServices;
#if !NET_2_1
using System.Security.Permissions;
@@ -40,6 +41,14 @@ namespace System.Security.Cryptography.X509Certificates
{
static partial class X509Helper
{
static INativeCertificateHelper nativeHelper;
internal static void InstallNativeHelper (INativeCertificateHelper helper)
{
if (nativeHelper == null)
Interlocked.CompareExchange (ref nativeHelper, helper, null);
}
#if !NET_2_1
// typedef struct _CERT_CONTEXT {
// DWORD dwCertEncodingType;
@@ -77,6 +86,14 @@ namespace System.Security.Cryptography.X509Certificates
}
#endif
public static X509CertificateImpl InitFromCertificate (X509Certificate cert)
{
if (nativeHelper != null)
return nativeHelper.Import (cert);
return InitFromCertificate (cert.Impl);
}
public static X509CertificateImpl InitFromCertificate (X509CertificateImpl impl)
{
ThrowIfContextInvalid (impl);
@@ -134,6 +151,9 @@ namespace System.Security.Cryptography.X509Certificates
#if !MONOTOUCH && !XAMMAC
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
if (nativeHelper != null)
return nativeHelper.Import (rawData, password, keyStorageFlags);
MX.X509Certificate x509;
if (password == null) {
try {

View File

@@ -96,11 +96,6 @@ namespace System
static Console ()
{
#if NET_2_1
Encoding inputEncoding;
Encoding outputEncoding;
#endif
if (Environment.IsRunningOnWindows) {
//
// On Windows, follow the Windows tradition
@@ -540,7 +535,6 @@ namespace System
#endif
#if !NET_2_1
// FIXME: Console should use these encodings when changed
static Encoding inputEncoding;
static Encoding outputEncoding;
@@ -561,6 +555,7 @@ namespace System
}
}
#if !NET_2_1
public static ConsoleColor BackgroundColor {
get { return ConsoleDriver.BackgroundColor; }
set { ConsoleDriver.BackgroundColor = value; }

View File

@@ -218,7 +218,7 @@ namespace System {
if (typeName == null)
throw new ArgumentNullException ("typeName");
TypeSpec res = Parse (typeName, ref pos, false, false);
TypeSpec res = Parse (typeName, ref pos, false, true);
if (pos < typeName.Length)
throw new ArgumentException ("Count not parse the whole type name", "typeName");
return res;
@@ -287,7 +287,7 @@ namespace System {
{
Assembly asm = null;
if (assemblyResolver == null && typeResolver == null)
return Type.GetType (name.DisplayName, throwOnError, ignoreCase);
return Type.GetType (DisplayFullName, throwOnError, ignoreCase);
if (assembly_name != null) {
if (assemblyResolver != null)
@@ -376,6 +376,12 @@ namespace System {
pos = p;
}
static void BoundCheck (int idx, string s)
{
if (idx >= s.Length)
throw new ArgumentException ("Invalid generic arguments spec", "typeName");
}
static TypeIdentifier ParsedTypeIdentifier (string displayName)
{
return TypeIdentifiers.FromDisplay(displayName);
@@ -383,6 +389,17 @@ namespace System {
static TypeSpec Parse (string name, ref int p, bool is_recurse, bool allow_aqn)
{
// Invariants:
// - On exit p, is updated to pos the current unconsumed character.
//
// - The callee peeks at but does not consume delimiters following
// recurisve parse (so for a recursive call like the args of "Foo[P,Q]"
// we'll return with p either on ',' or on ']'. If the name was aqn'd
// "Foo[[P,assmblystuff],Q]" on return p with be on the ']' just
// after the "assmblystuff")
//
// - If allow_aqn is True, assembly qualification is optional.
// If allow_aqn is False, assembly qualification is prohibited.
int pos = p;
int name_start;
bool in_modifiers = false;
@@ -450,18 +467,24 @@ namespace System {
data.AddModifier (new PointerSpec(pointer_level));
break;
case ',':
if (is_recurse) {
if (is_recurse && allow_aqn) {
int end = pos;
while (end < name.Length && name [end] != ']')
++end;
if (end >= name.Length)
throw new ArgumentException ("Unmatched ']' while parsing generic argument assembly name");
data.assembly_name = name.Substring (pos + 1, end - pos - 1).Trim ();
p = end + 1;
p = end;
return data;
}
data.assembly_name = name.Substring (pos + 1).Trim ();
pos = name.Length;
if (is_recurse) {
p = pos;
return data;
}
if (allow_aqn) {
data.assembly_name = name.Substring (pos + 1).Trim ();
pos = name.Length;
}
break;
case '[':
if (data.is_byref)
@@ -482,11 +505,17 @@ namespace System {
if (aqn)
++pos; //skip '[' to the start of the type
args.Add (Parse (name, ref pos, true, aqn));
if (pos >= name.Length)
throw new ArgumentException ("Invalid generic arguments spec", "typeName");
BoundCheck (pos, name);
if (aqn) {
if (name [pos] == ']')
++pos;
else
throw new ArgumentException ("Unclosed assembly-qualified type name at " + name[pos], "typeName");
BoundCheck (pos, name);
}
if (name [pos] == ']')
break;
break;
if (name [pos] == ',')
++pos; // skip ',' to the start of the next arg
else
@@ -523,7 +552,7 @@ namespace System {
break;
case ']':
if (is_recurse) {
p = pos + 1;
p = pos;
return data;
}
throw new ArgumentException ("Unmatched ']'", "typeName");

View File

@@ -35,6 +35,7 @@ using System.Diagnostics;
namespace MonoTests.System.Runtime.ExceptionServices
{
[TestFixture]
[Category ("BitcodeNotWorking")]
public class ExceptionDispatchInfoTest
{
[Test]

View File

@@ -1 +1 @@
19dbff4804c0ea37f0033f0911c3674f4bf65b90
541acb6afb71ee34f37b1aa52431ed984f0cbca2

View File

@@ -403,7 +403,6 @@ System.Runtime.InteropServices/RegistrationConnectionType.cs
System.Runtime.InteropServices/SEHException.cs
System.Runtime.InteropServices/STATSTG.cs
System.Runtime.InteropServices/RegistrationServices.cs
System.Runtime.InteropServices/RuntimeEnvironment.cs
System.Runtime.InteropServices/SafeArrayRankMismatchException.cs
System.Runtime.InteropServices/SafeArrayTypeMismatchException.cs
System.Runtime.InteropServices/SafeBuffer.cs
@@ -733,6 +732,7 @@ System.Security.Cryptography/RSAPKCS1SignatureDeformatter.cs
System.Security.Cryptography/RSAPKCS1SignatureFormatter.cs
System.Security.Cryptography/SHA1CryptoServiceProvider.cs
System.Security.Cryptography/TripleDESCryptoServiceProvider.cs
System.Security.Cryptography.X509Certificates/INativeCertificateHelper.cs
System.Security.Cryptography.X509Certificates/X509Certificate.cs
System.Security.Cryptography.X509Certificates/X509Certificate20.cs
System.Security.Cryptography.X509Certificates/X509CertificateImpl.cs
@@ -1280,6 +1280,7 @@ ReferenceSources/SecurityContext.cs
../../../external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs
../../../external/referencesource/mscorlib/system/runtime/interopservices/attributes.cs
../../../external/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs
../../../external/referencesource/mscorlib/system/runtime/interopservices/safehandle.cs
../../../external/referencesource/mscorlib/system/runtime/interopservices/ucomienumconnections.cs