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

@@ -59,7 +59,7 @@ using System.Runtime.InteropServices;
[assembly: CLSCompliant (true)]
[assembly: AssemblyDelaySign (true)]
#if NET_2_1
#if MOBILE
[assembly: AssemblyKeyFile ("../silverlight.pub")]
#else
[assembly: AssemblyKeyFile ("../ecma.pub")]
@@ -83,6 +83,7 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo ("Xamarin.TVOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#elif MONOTOUCH_WATCH
[assembly: InternalsVisibleTo ("Xamarin.WatchOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo ("System.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
#else
[assembly: InternalsVisibleTo ("monotouch, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo ("Xamarin.iOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
@@ -94,5 +95,4 @@ 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

@@ -39,6 +39,18 @@ namespace System.Security.Cryptography {
{
}
public RNGCryptoServiceProvider (byte[] rgb)
{
}
public RNGCryptoServiceProvider (CspParameters cspParams)
{
}
public RNGCryptoServiceProvider (string str)
{
}
~RNGCryptoServiceProvider ()
{
}

View File

@@ -203,7 +203,7 @@ tzi.exe:System/AndroidPlatform.cs $(wildcard System/TimeZone*.cs) ../../build/co
trap "rm -f $(TMP_FILE1) $(TMP_FILE2)" EXIT INT QUIT TERM && \
sed 's/Environment\.GetResourceString/string.Format/g' ../referencesource/mscorlib/system/timezoneinfo.cs > $(TMP_FILE1) && \
sed 's/StringBuilder\.DefaultCapacity/100/g' ../referencesource/mscorlib/system/text/stringbuildercache.cs > $(TMP_FILE2) && \
$(MCS) /debug+ /out:$@ -unsafe -nowarn:612,618 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS) "/d:SELF_TEST;NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;DISABLE_CAS_USE;MOBILE;MOBILE_DYNAMIC;MONODROID;ANDROID" $^ $(TMP_FILE1) $(TMP_FILE2)
$(MCS) /debug+ /out:$@ -unsafe -nowarn:612,618 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS) "/d:SELF_TEST;NET_1_1;NET_2_0;MOBILE;NET_3_5;NET_4_0;NET_4_5;MONO;DISABLE_CAS_USE;MOBILE;MOBILE_DYNAMIC;MONODROID;ANDROID" $^ $(TMP_FILE1) $(TMP_FILE2)
android-pull-tzdb:
mkdir -p android/tzdb/usr/share/zoneinfo

View File

@@ -30,7 +30,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
#if !MOBILE
using System;
using System.Text;
@@ -67,5 +67,5 @@ namespace Microsoft.Win32 {
}
}
#endif // NET_2_1
#endif // MOBILE

View File

@@ -27,7 +27,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
#if !MOBILE
namespace Microsoft.Win32
{
public enum RegistryKeyPermissionCheck

View File

@@ -37,7 +37,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
#if !MOBILE
using System;
using System.Collections;
@@ -1029,5 +1029,5 @@ namespace Microsoft.Win32 {
}
}
#endif // NET_2_1
#endif // MOBILE

View File

@@ -33,7 +33,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
#if !MOBILE
using System;
using System.Collections;
@@ -241,48 +241,66 @@ namespace Microsoft.Win32
public void SetValue (RegistryKey rkey, string name, object value, RegistryValueKind valueKind)
{
Type type = value.GetType ();
int result;
IntPtr handle = GetHandle (rkey);
if (valueKind == RegistryValueKind.QWord && type == typeof (long)) {
long rawValue = (long)value;
result = RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.QWord, ref rawValue, Int64ByteSize);
} else if (valueKind == RegistryValueKind.DWord && type == typeof (int)) {
int rawValue = (int)value;
result = RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.DWord, ref rawValue, Int32ByteSize);
} else if (valueKind == RegistryValueKind.Binary && type == typeof (byte[])) {
byte[] rawValue = (byte[]) value;
result = RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.Binary, rawValue, rawValue.Length);
} else if (valueKind == RegistryValueKind.MultiString && type == typeof (string[])) {
string[] vals = (string[]) value;
StringBuilder fullStringValue = new StringBuilder ();
foreach (string v in vals)
{
fullStringValue.Append (v);
fullStringValue.Append ('\0');
switch (valueKind) {
case RegistryValueKind.QWord:
try {
long rawValue = Convert.ToInt64 (value);
CheckResult (RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.QWord, ref rawValue, Int64ByteSize));
return;
} catch (OverflowException) {
}
fullStringValue.Append ('\0');
break;
case RegistryValueKind.DWord:
try {
int rawValue = Convert.ToInt32 (value);
CheckResult (RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.DWord, ref rawValue, Int32ByteSize));
return;
} catch (OverflowException) {
}
break;
case RegistryValueKind.Binary:
if (type == typeof (byte[])) {
byte[] rawValue = (byte[]) value;
CheckResult (RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.Binary, rawValue, rawValue.Length));
return;
}
break;
case RegistryValueKind.MultiString:
if (type == typeof (string[])) {
string[] vals = (string[]) value;
StringBuilder fullStringValue = new StringBuilder ();
foreach (string v in vals)
{
fullStringValue.Append (v);
fullStringValue.Append ('\0');
}
fullStringValue.Append ('\0');
byte[] rawValue = Encoding.Unicode.GetBytes (fullStringValue.ToString ());
byte[] rawValue = Encoding.Unicode.GetBytes (fullStringValue.ToString ());
result = RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.MultiString, rawValue, rawValue.Length);
} else if ((valueKind == RegistryValueKind.String || valueKind == RegistryValueKind.ExpandString) &&
type == typeof (string)){
string rawValue = String.Format ("{0}{1}", value, '\0');
result = RegSetValueEx (handle, name, IntPtr.Zero, valueKind, rawValue,
rawValue.Length * NativeBytesPerCharacter);
} else if (type.IsArray) {
throw new ArgumentException ("Only string and byte arrays can written as registry values");
} else {
throw new ArgumentException ("Type does not match the valueKind");
CheckResult (RegSetValueEx (handle, name, IntPtr.Zero, RegistryValueKind.MultiString, rawValue, rawValue.Length));
return;
}
break;
case RegistryValueKind.String:
case RegistryValueKind.ExpandString:
if (type == typeof (string)) {
string rawValue = String.Format ("{0}{1}", value, '\0');
CheckResult (RegSetValueEx (handle, name, IntPtr.Zero, valueKind, rawValue,
rawValue.Length * NativeBytesPerCharacter));
return;
}
break;
default:
if (type.IsArray) {
throw new ArgumentException ("Only string and byte arrays can written as registry values");
}
break;
}
// handle the result codes
if (result != Win32ResultCode.Success)
{
GenerateException (result);
}
throw new ArgumentException ("Type does not match the valueKind");
}
public void SetValue (RegistryKey rkey, string name, object value)
@@ -318,9 +336,6 @@ namespace Microsoft.Win32
rawValue.Length * NativeBytesPerCharacter);
}
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
// handle the result codes
if (result != Win32ResultCode.Success)
{
@@ -356,9 +371,6 @@ namespace Microsoft.Win32
int result = RegEnumKey (handle, index, stringBuffer,
stringBuffer.Capacity);
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
if (result == Win32ResultCode.Success)
continue;
@@ -386,9 +398,6 @@ namespace Microsoft.Win32
IntPtr.Zero, ref type,
IntPtr.Zero, IntPtr.Zero);
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
if (result == Win32ResultCode.Success || result == Win32ResultCode.MoreData)
continue;
@@ -470,9 +479,6 @@ namespace Microsoft.Win32
RegOptionsNonVolatile,
OpenRegKeyRead | OpenRegKeyWrite, IntPtr.Zero, out subKeyHandle, out disposition);
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
if (result != Win32ResultCode.Success) {
GenerateException (result);
}
@@ -490,9 +496,6 @@ namespace Microsoft.Win32
options == RegistryOptions.Volatile ? RegOptionsVolatile : RegOptionsNonVolatile,
OpenRegKeyRead | OpenRegKeyWrite, IntPtr.Zero, out subKeyHandle, out disposition);
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
if (result != Win32ResultCode.Success)
GenerateException (result);
@@ -580,15 +583,19 @@ namespace Microsoft.Win32
if (result == Win32ResultCode.NoMoreEntries)
break;
if (result == Win32ResultCode.MarkedForDeletion)
throw RegistryKey.CreateMarkedForDeletionException ();
GenerateException (result);
}
return values.ToArray ();
}
private void CheckResult (int result)
{
if (result != Win32ResultCode.Success) {
GenerateException (result);
}
}
/// <summary>
/// convert a win32 error code into an appropriate exception.
/// </summary>
@@ -604,6 +611,10 @@ namespace Microsoft.Win32
throw new IOException ("The network path was not found.");
case Win32ResultCode.InvalidHandle:
throw new IOException ("Invalid handle.");
case Win32ResultCode.MarkedForDeletion:
throw RegistryKey.CreateMarkedForDeletionException ();
case Win32ResultCode.ChildMustBeVolatile:
throw new IOException ("Cannot create a stable subkey under a volatile parent key.");
default:
// unidentified system exception
throw new SystemException ();
@@ -626,5 +637,5 @@ namespace Microsoft.Win32
}
}
#endif // NET_2_1
#endif // MOBILE

View File

@@ -30,7 +30,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_2_1
#if !MOBILE
using System;
using System.Runtime.InteropServices;
@@ -58,8 +58,9 @@ namespace Microsoft.Win32
public const int NetworkPathNotFound = 53;
public const int NoMoreEntries = 259;
public const int MarkedForDeletion = 1018;
public const int ChildMustBeVolatile = 1021;
}
}
#endif // NET_2_1
#endif // MOBILE

View File

@@ -1015,7 +1015,7 @@ namespace Mono.Security {
}
// 5 path
pos = uriString.IndexOfAny (new char[] {'/'});
pos = uriString.IndexOfAny (new char[] {'/', '\\'});
if (unixAbsPath)
pos = -1;
if (pos == -1) {
@@ -1042,6 +1042,8 @@ namespace Mono.Security {
pos = uriString.LastIndexOf (":");
if (unixAbsPath)
pos = -1;
if (pos == 1 && scheme == Uri.UriSchemeFile && Char.IsLetter (uriString [0]))
pos = -1;
if (pos != -1 && pos != (uriString.Length - 1)) {
string portStr = uriString.Remove (0, pos + 1);
if (portStr.Length > 1 && portStr [portStr.Length - 1] != ']') {

View File

@@ -31,7 +31,7 @@ using System.Runtime.CompilerServices;
namespace Mono {
#if MOBILE
#if MOBILE || XAMMAC_4_5
public
#endif
static class Runtime
@@ -40,16 +40,31 @@ namespace Mono {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern void mono_runtime_install_handlers ();
static internal void InstallSignalHandlers ()
#if MOBILE || XAMMAC_4_5
public
#else
internal
#endif
static void InstallSignalHandlers ()
{
mono_runtime_install_handlers ();
}
#if MOBILE || XAMMAC_4_5
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void mono_runtime_cleanup_handlers ();
public static void RemoveSignalHandlers ()
{
mono_runtime_cleanup_handlers ();
}
#endif
// Should not be removed intended for external use
// Safe to be called using reflection
// Format is undefined only for use as a string for reporting
[MethodImplAttribute (MethodImplOptions.InternalCall)]
#if MOBILE
#if MOBILE || XAMMAC_4_5
public
#else
internal

View File

@@ -0,0 +1,274 @@
//
// Wrapper handles for Mono Runtime internal structs
//
// Authors:
// Aleksey Kliger <aleksey@xamarin.com>
// Rodrigo Kumpera <kumpera@xamarin.com>
//
// Copyright 2016 Dot net foundation.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Mono {
internal struct RuntimeClassHandle {
unsafe RuntimeStructs.MonoClass* value;
internal unsafe RuntimeClassHandle (RuntimeStructs.MonoClass* value) {
this.value = value;
}
internal unsafe RuntimeClassHandle (IntPtr ptr) {
this.value = (RuntimeStructs.MonoClass*) ptr;
}
internal unsafe RuntimeStructs.MonoClass* Value {
get { return value; }
}
public override bool Equals (object obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
unsafe { return value == ((RuntimeClassHandle)obj).Value; }
}
public override int GetHashCode ()
{
unsafe { return ((IntPtr)value).GetHashCode (); }
}
public bool Equals (RuntimeClassHandle handle)
{
unsafe { return value == handle.Value; }
}
public static bool operator == (RuntimeClassHandle left, Object right)
{
return (right != null) && (right is RuntimeClassHandle) && left.Equals ((RuntimeClassHandle)right);
}
public static bool operator != (RuntimeClassHandle left, Object right)
{
return (right == null) || !(right is RuntimeClassHandle) || !left.Equals ((RuntimeClassHandle)right);
}
public static bool operator == (Object left, RuntimeClassHandle right)
{
return (left != null) && (left is RuntimeClassHandle) && ((RuntimeClassHandle)left).Equals (right);
}
public static bool operator != (Object left, RuntimeClassHandle right)
{
return (left == null) || !(left is RuntimeClassHandle) || !((RuntimeClassHandle)left).Equals (right);
}
[MethodImpl(MethodImplOptions.InternalCall)]
internal unsafe extern static IntPtr GetTypeFromClass (RuntimeStructs.MonoClass *klass);
internal RuntimeTypeHandle GetTypeHandle ()
{
unsafe { return new RuntimeTypeHandle (GetTypeFromClass (value)); }
}
}
internal struct RuntimeRemoteClassHandle {
unsafe RuntimeStructs.RemoteClass* value;
internal unsafe RuntimeRemoteClassHandle (RuntimeStructs.RemoteClass* value)
{
this.value = value;
}
internal RuntimeClassHandle ProxyClass {
get {
unsafe {
return new RuntimeClassHandle (value->proxy_class);
}
}
}
}
internal struct RuntimeGenericParamInfoHandle {
unsafe RuntimeStructs.GenericParamInfo* value;
internal unsafe RuntimeGenericParamInfoHandle (RuntimeStructs.GenericParamInfo* value)
{
this.value = value;
}
internal unsafe RuntimeGenericParamInfoHandle (IntPtr ptr)
{
this.value = (RuntimeStructs.GenericParamInfo*) ptr;
}
internal Type[] Constraints { get { return GetConstraints (); } }
internal GenericParameterAttributes Attributes {
get {
unsafe {
return (GenericParameterAttributes) value->flags;
}
}
}
Type[] GetConstraints () {
int n = GetConstraintsCount ();
var a = new Type[n];
for (int i = 0; i < n; i++) {
unsafe {
RuntimeClassHandle c = new RuntimeClassHandle (value->constraints[i]);
a[i] = Type.GetTypeFromHandle (c.GetTypeHandle ());
}
}
return a;
}
int GetConstraintsCount () {
int i = 0;
unsafe {
RuntimeStructs.MonoClass** p = value->constraints;
while (p != null && *p != null) {
p++; i++;
}
}
return i;
}
}
internal struct RuntimeEventHandle {
IntPtr value;
internal RuntimeEventHandle (IntPtr v)
{
value = v;
}
public IntPtr Value {
get {
return value;
}
}
public override bool Equals (object obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimeEventHandle)obj).Value;
}
public bool Equals (RuntimeEventHandle handle)
{
return value == handle.Value;
}
public override int GetHashCode ()
{
return value.GetHashCode ();
}
public static bool operator == (RuntimeEventHandle left, RuntimeEventHandle right)
{
return left.Equals (right);
}
public static bool operator != (RuntimeEventHandle left, RuntimeEventHandle right)
{
return !left.Equals (right);
}
}
internal struct RuntimePropertyHandle {
IntPtr value;
internal RuntimePropertyHandle (IntPtr v)
{
value = v;
}
public IntPtr Value {
get {
return value;
}
}
public override bool Equals (object obj)
{
if (obj == null || GetType () != obj.GetType ())
return false;
return value == ((RuntimePropertyHandle)obj).Value;
}
public bool Equals (RuntimePropertyHandle handle)
{
return value == handle.Value;
}
public override int GetHashCode ()
{
return value.GetHashCode ();
}
public static bool operator == (RuntimePropertyHandle left, RuntimePropertyHandle right)
{
return left.Equals (right);
}
public static bool operator != (RuntimePropertyHandle left, RuntimePropertyHandle right)
{
return !left.Equals (right);
}
}
internal struct RuntimeGPtrArrayHandle {
unsafe RuntimeStructs.GPtrArray* value;
internal unsafe RuntimeGPtrArrayHandle (RuntimeStructs.GPtrArray* value)
{
this.value = value;
}
internal unsafe RuntimeGPtrArrayHandle (IntPtr ptr)
{
this.value = (RuntimeStructs.GPtrArray*) ptr;
}
internal int Length {
get {
unsafe {
return value->len;
}
}
}
internal IntPtr this[int i] => Lookup (i);
internal IntPtr Lookup (int i)
{
if (i >= 0 && i < Length) {
unsafe {
return value->data[i];
}
} else
throw new IndexOutOfRangeException ();
}
[MethodImpl(MethodImplOptions.InternalCall)]
unsafe extern static void GPtrArrayFree (RuntimeStructs.GPtrArray* value);
internal static void DestroyAndFree (ref RuntimeGPtrArrayHandle h) {
unsafe {
GPtrArrayFree (h.value);
h.value = null;
}
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace Mono {
internal static class RuntimeMarshal {
internal static string PtrToUtf8String (IntPtr ptr)
{
unsafe {
return new String ((sbyte*)ptr);
}
}
internal static SafeStringMarshal MarshalString (string str)
{
return new SafeStringMarshal (str);
}
static int DecodeBlobSize (IntPtr in_ptr, out IntPtr out_ptr)
{
uint size;
unsafe {
byte *ptr = (byte*)in_ptr;
if ((*ptr & 0x80) == 0) {
size = (uint)(ptr [0] & 0x7f);
ptr++;
} else if ((*ptr & 0x40) == 0){
size = (uint)(((ptr [0] & 0x3f) << 8) + ptr [1]);
ptr += 2;
} else {
size = (uint)(((ptr [0] & 0x1f) << 24) +
(ptr [1] << 16) +
(ptr [2] << 8) +
ptr [3]);
ptr += 4;
}
out_ptr = (IntPtr)ptr;
}
return (int)size;
}
internal static byte[] DecodeBlobArray (IntPtr ptr)
{
IntPtr out_ptr;
int size = DecodeBlobSize (ptr, out out_ptr);
byte[] res = new byte [size];
Marshal.Copy (out_ptr, res, 0, size);
return res;
}
internal static int AsciHexDigitValue (int c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
return c - 'A' + 10;
}
[MethodImpl (MethodImplOptions.InternalCall)]
internal static extern void FreeAssemblyName (ref MonoAssemblyName name);
}
}

View File

@@ -0,0 +1,83 @@
//
// Mono runtime native structs surfaced to managed code.
//
// Authors:
// Aleksey Kliger <aleksey@xamarin.com>
// Rodrigo Kumpera <kumpera@xamarin.com>
//
// Copyright 2016 Dot net foundation.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.InteropServices;
#pragma warning disable 169
namespace Mono {
//
// Managed representations of mono runtime types
//
internal static class RuntimeStructs {
// class-internals.h MonoRemoteClass
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct RemoteClass {
internal IntPtr default_vtable;
internal IntPtr xdomain_vtable;
internal MonoClass* proxy_class;
internal IntPtr proxy_class_name;
internal uint interface_count;
// FIXME: How to represent variable-length array struct member?
// MonoClass* interfaces [];
}
internal struct MonoClass {
}
// class-internals.h MonoGenericParamInfo
internal unsafe struct GenericParamInfo {
internal MonoClass* pklass;
internal IntPtr name;
internal ushort flags;
internal uint token;
internal MonoClass** constraints; /* NULL terminated */
}
// glib.h GPtrArray
internal unsafe struct GPtrArray {
internal IntPtr* data;
internal int len;
}
// handle.h HandleStackMark
struct HandleStackMark {
int size;
IntPtr chunk;
}
// mono-error.h MonoError
struct MonoError {
ushort error_code;
ushort hidden_0;
IntPtr hidden_1, hidden_2, hidden_3, hidden_4, hidden_5, hidden_6, hidden_7, hidden_8;
IntPtr hidden_11, hidden_12, hidden_13, hidden_14, hidden_15, hidden_16, hidden_17, hidden_18;
}
}
//Maps to metadata-internals.h:: MonoAssemblyName
internal unsafe struct MonoAssemblyName
{
const int MONO_PUBLIC_KEY_TOKEN_LENGTH = 17;
internal IntPtr name;
internal IntPtr culture;
internal IntPtr hash_value;
internal IntPtr public_key;
internal fixed byte public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
internal uint hash_alg;
internal uint hash_len;
internal uint flags;
internal ushort major, minor, build, revision;
internal ushort arch;
}
}

View File

@@ -0,0 +1,38 @@
//
// Safe handle class for Mono.RuntimeGPtrArrayHandle
//
// Authors:
// Aleksey Kliger <aleksey@xamarin.com>
// Rodrigo Kumpera <kumpera@xamarin.com>
//
// Copyright 2016 Dot net foundation.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.CompilerServices;
namespace Mono {
internal struct SafeGPtrArrayHandle : IDisposable {
RuntimeGPtrArrayHandle handle;
internal SafeGPtrArrayHandle (IntPtr ptr)
{
handle = new RuntimeGPtrArrayHandle (ptr);
}
public void Dispose () {
RuntimeGPtrArrayHandle.DestroyAndFree (ref handle);
}
internal int Length {
get {
return handle.Length;
}
}
internal IntPtr this[int i] => handle[i];
}
}

View File

@@ -0,0 +1,46 @@
//
// Safe wrapper for a string and its UTF8 encoding
//
// Authors:
// Aleksey Kliger <aleksey@xamarin.com>
// Rodrigo Kumpera <kumpera@xamarin.com>
//
// Copyright 2016 Dot net foundation.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.CompilerServices;
namespace Mono {
internal struct SafeStringMarshal : IDisposable {
readonly string str;
IntPtr marshaled_string;
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr StringToUtf8 (string str);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void GFree (IntPtr ptr);
public SafeStringMarshal (string str) {
this.str = str;
this.marshaled_string = IntPtr.Zero;
}
public IntPtr Value {
get {
if (marshaled_string == IntPtr.Zero && str != null)
marshaled_string = StringToUtf8 (str);
return marshaled_string;
}
}
public void Dispose () {
if (marshaled_string != IntPtr.Zero) {
GFree (marshaled_string);
marshaled_string = IntPtr.Zero;
}
}
}
}

View File

@@ -1,5 +1,7 @@
namespace System {
static class AppContextSwitches {
public const bool ThrowExceptionIfDisposedCancellationTokenSource = true;
public static readonly bool ThrowExceptionIfDisposedCancellationTokenSource = true;
public static readonly bool SetActorAsReferenceWhenCopyingClaimsIdentity = false;
public static readonly bool NoAsyncCurrentCulture = false;
}
}

View File

@@ -46,7 +46,12 @@ namespace System.Reflection
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle)
{
return GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
return GetMethodFromHandleInternalType_native (handle.Value, IntPtr.Zero, false);
}
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle, RuntimeTypeHandle reflectedType)
{
return GetMethodFromHandleInternalType_native (handle.Value, reflectedType.Value, false);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -57,7 +62,12 @@ namespace System.Reflection
return GetMethodBodyInternal (handle);
}
static MethodBase GetMethodFromHandleInternalType (IntPtr method_handle, IntPtr type_handle) {
return GetMethodFromHandleInternalType_native (method_handle, type_handle, true);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern static MethodBase GetMethodFromHandleInternalType (IntPtr method_handle, IntPtr type_handle);
internal extern static MethodBase GetMethodFromHandleInternalType_native (IntPtr method_handle, IntPtr type_handle, bool genericCheck);
}
}
}

View File

@@ -0,0 +1,10 @@
namespace System.IO
{
static class PathInternal
{
public static bool IsPartiallyQualified (string path)
{
return false;
}
}
}

View File

@@ -452,7 +452,8 @@ namespace System
throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
Contract.EndContractBlock();
Type[] constraints = GetGenericParameterConstraints_impl ();
var paramInfo = new Mono.RuntimeGenericParamInfoHandle (RuntimeTypeHandle.GetGenericParameterInfo (this));
Type[] constraints = paramInfo.Constraints;
if (constraints == null)
constraints = EmptyArray<Type>.Value;
@@ -471,13 +472,57 @@ namespace System
static extern Type MakeGenericType (Type gt, Type [] types);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern RuntimeMethodInfo[] GetMethodsByName (string name, BindingFlags bindingAttr, bool ignoreCase, Type reflected_type);
internal extern IntPtr GetMethodsByName_native (IntPtr namePtr, BindingFlags bindingAttr, bool ignoreCase);
internal RuntimeMethodInfo[] GetMethodsByName (string name, BindingFlags bindingAttr, bool ignoreCase, RuntimeType reflectedType)
{
var refh = new RuntimeTypeHandle (reflectedType);
using (var namePtr = new Mono.SafeStringMarshal (name))
using (var h = new Mono.SafeGPtrArrayHandle (GetMethodsByName_native (namePtr.Value, bindingAttr, ignoreCase))) {
var n = h.Length;
var a = new RuntimeMethodInfo [n];
for (int i = 0; i < n; i++) {
var mh = new RuntimeMethodHandle (h[i]);
a[i] = (RuntimeMethodInfo) MethodBase.GetMethodFromHandleNoGenericCheck (mh, refh);
}
return a;
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern RuntimePropertyInfo[] GetPropertiesByName (string name, BindingFlags bindingAttr, bool icase, Type reflected_type);
extern IntPtr GetPropertiesByName_native (IntPtr name, BindingFlags bindingAttr, bool icase);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern RuntimeConstructorInfo[] GetConstructors_internal (BindingFlags bindingAttr, Type reflected_type);
extern IntPtr GetConstructors_native (BindingFlags bindingAttr);
RuntimeConstructorInfo[] GetConstructors_internal (BindingFlags bindingAttr, RuntimeType reflectedType)
{
var refh = new RuntimeTypeHandle (reflectedType);
using (var h = new Mono.SafeGPtrArrayHandle (GetConstructors_native (bindingAttr))) {
var n = h.Length;
var a = new RuntimeConstructorInfo [n];
for (int i = 0; i < n; i++) {
var mh = new RuntimeMethodHandle (h[i]);
a[i] = (RuntimeConstructorInfo) MethodBase.GetMethodFromHandleNoGenericCheck (mh, refh);
}
return a;
}
}
RuntimePropertyInfo[] GetPropertiesByName (string name, BindingFlags bindingAttr, bool icase, RuntimeType reflectedType)
{
var refh = new RuntimeTypeHandle (reflectedType);
using (var namePtr = new Mono.SafeStringMarshal (name))
using (var h = new Mono.SafeGPtrArrayHandle (GetPropertiesByName_native (namePtr.Value, bindingAttr, icase))) {
var n = h.Length;
var a = new RuntimePropertyInfo [n];
for (int i = 0; i < n; i++) {
var ph = new Mono.RuntimePropertyHandle (h[i]);
a[i] = (RuntimePropertyInfo) PropertyInfo.GetPropertyFromHandle (ph, refh);
}
return a;
}
}
public override InterfaceMapping GetInterfaceMap (Type ifaceType)
{
@@ -618,26 +663,71 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern Type[] GetGenericArgumentsInternal (bool runtimeArray);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern GenericParameterAttributes GetGenericParameterAttributes ();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern Type[] GetGenericParameterConstraints_impl ();
GenericParameterAttributes GetGenericParameterAttributes () {
return (new Mono.RuntimeGenericParamInfoHandle (RuntimeTypeHandle.GetGenericParameterInfo (this))).Attributes;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern int GetGenericParameterPosition ();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern RuntimeEventInfo[] GetEvents_internal (string name, BindingFlags bindingAttr, Type reflected_type);
extern IntPtr GetEvents_native (IntPtr name, BindingFlags bindingAttr);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern RuntimeFieldInfo[] GetFields_internal (string name, BindingFlags bindingAttr, Type reflected_type);
extern IntPtr GetFields_native (IntPtr name, BindingFlags bindingAttr);
RuntimeFieldInfo[] GetFields_internal (string name, BindingFlags bindingAttr, RuntimeType reflectedType)
{
var refh = new RuntimeTypeHandle (reflectedType);
using (var namePtr = new Mono.SafeStringMarshal (name))
using (var h = new Mono.SafeGPtrArrayHandle (GetFields_native (namePtr.Value, bindingAttr))) {
int n = h.Length;
var a = new RuntimeFieldInfo[n];
for (int i = 0; i < n; i++) {
var fh = new RuntimeFieldHandle (h[i]);
a[i] = (RuntimeFieldInfo) FieldInfo.GetFieldFromHandle (fh, refh);
}
return a;
}
}
RuntimeEventInfo[] GetEvents_internal (string name, BindingFlags bindingAttr, RuntimeType reflectedType)
{
var refh = new RuntimeTypeHandle (reflectedType);
using (var namePtr = new Mono.SafeStringMarshal (name))
using (var h = new Mono.SafeGPtrArrayHandle (GetEvents_native (namePtr.Value, bindingAttr))) {
int n = h.Length;
var a = new RuntimeEventInfo[n];
for (int i = 0; i < n; i++) {
var eh = new Mono.RuntimeEventHandle (h[i]);
a[i] = (RuntimeEventInfo) EventInfo.GetEventFromHandle (eh, refh);
}
return a;
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern override Type[] GetInterfaces();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
extern RuntimeType[] GetNestedTypes_internal (string name, BindingFlags bindingAttr);
extern IntPtr GetNestedTypes_native (IntPtr name, BindingFlags bindingAttr);
RuntimeType[] GetNestedTypes_internal (string displayName, BindingFlags bindingAttr)
{
string internalName = null;
if (displayName != null)
internalName = TypeIdentifiers.FromDisplay (displayName).InternalName;
using (var namePtr = new Mono.SafeStringMarshal (internalName))
using (var h = new Mono.SafeGPtrArrayHandle (GetNestedTypes_native (namePtr.Value, bindingAttr))) {
int n = h.Length;
var a = new RuntimeType [n];
for (int i = 0; i < n; i++) {
var th = new RuntimeTypeHandle (h[i]);
a[i] = (RuntimeType) Type.GetTypeFromHandle (th);
}
return a;
}
}
public override string AssemblyQualifiedName {
get {

View File

@@ -1,22 +0,0 @@
using System.Threading;
using StringMaker = System.Security.Util.Tokenizer.StringMaker;
namespace System
{
static class SharedStatics
{
static StringMaker shared;
static public StringMaker GetSharedStringMaker ()
{
if (shared == null)
Interlocked.CompareExchange (ref shared, new StringMaker (), null);
return shared;
}
static public void ReleaseSharedStringMaker (ref StringMaker maker)
{
}
}
}

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