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

@@ -45,7 +45,9 @@ using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
#if !DISABLE_REMOTING
using System.Runtime.Remoting.Channels;
#endif
using System.Runtime.Remoting.Messaging;
using System.Security;
using System.Security.Permissions;
@@ -72,8 +74,10 @@ namespace System {
#endif
#pragma warning disable 169
#region Sync with object-internals.h
#region Sync with LinkerDescriptor/mscorlib.xml
IntPtr _mono_app_domain;
#endregion
#endregion
#pragma warning restore 169
static string _process_guid;
@@ -194,6 +198,7 @@ namespace System {
}
}
#if !DISABLE_SECURITY
public Evidence Evidence {
get {
#if MONOTOUCH
@@ -239,6 +244,7 @@ namespace System {
return (IPrincipal)_principal;
}
}
#endif
// for AppDomain there is only an allowed (i.e. granted) set
// http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondetermininggrantedpermissions.asp
@@ -269,7 +275,11 @@ namespace System {
if (rd == CurrentDomain)
default_domain = rd;
else
#if DISABLE_REMOTING
throw new PlatformNotSupportedException ();
#else
default_domain = (AppDomain) RemotingServices.GetDomainProxy (rd);
#endif
}
return default_domain;
}
@@ -1043,6 +1053,7 @@ namespace System {
info.SerializeNonPrimitives ();
AppDomain ad = (AppDomain) RemotingServices.GetDomainProxy (createDomain (friendlyName, info));
#if !DISABLE_SECURITY
if (securityInfo == null) {
// get default domain's Evidence (unless we're are the default!)
if (def == null)
@@ -1052,6 +1063,7 @@ namespace System {
}
else
ad._evidence = new Evidence (securityInfo); // copy
#endif
#if !MOBILE
if (info.AppDomainInitializer != null) {
@@ -1338,19 +1350,20 @@ namespace System {
}
}
internal Assembly DoTypeResolve (Object name_or_tb)
#if MONO_FEATURE_SRE
internal Assembly DoTypeBuilderResolve (TypeBuilder tb)
{
if (TypeResolve == null)
return null;
string name;
#if MONO_FEATURE_SRE
if (name_or_tb is TypeBuilder)
name = ((TypeBuilder) name_or_tb).FullName;
else
return DoTypeResolve (tb.FullName);
}
#endif
name = (string) name_or_tb;
internal Assembly DoTypeResolve (string name)
{
if (TypeResolve == null)
return null;
/* Prevent infinite recursion */
var ht = type_resolve_in_progress;
@@ -1408,6 +1421,7 @@ namespace System {
UnhandledException (this, args);
}
#if !DISABLE_REMOTING
internal byte[] GetMarshalledDomainObjRef ()
{
ObjRef oref = RemotingServices.Marshal (AppDomain.CurrentDomain, null, typeof (AppDomain));
@@ -1433,6 +1447,7 @@ namespace System {
else
arrResponse = null;
}
#endif
#pragma warning restore 169

View File

@@ -91,6 +91,10 @@ namespace System
byte [] serialized_non_primitives;
string manager_assembly;
string manager_type;
string [] partial_visible_assemblies;
public AppDomainSetup ()
{
}
@@ -118,6 +122,9 @@ namespace System
domain_initializer_args = setup.domain_initializer_args;
disallow_appbase_probe = setup.disallow_appbase_probe;
configuration_bytes = setup.configuration_bytes;
manager_assembly = setup.manager_assembly;
manager_type = setup.manager_type;
partial_visible_assemblies = setup.partial_visible_assemblies;
}
public AppDomainSetup (ActivationArguments activationArguments)
@@ -257,6 +264,31 @@ namespace System
}
}
// AppDomainManagerAssembly, ManagerType, and PartialTrustVisibleAssemblies
// don't really do anything within Mono, but will help with refsrc compat.
public string AppDomainManagerAssembly {
get { return manager_assembly; }
set { manager_assembly = value; }
}
public string AppDomainManagerType {
get { return manager_type; }
set { manager_type = value; }
}
public string [] PartialTrustVisibleAssemblies {
get { return partial_visible_assemblies; }
set {
if (value != null) {
partial_visible_assemblies = (string [])value.Clone();
Array.Sort<string> (partial_visible_assemblies, StringComparer.OrdinalIgnoreCase);
}
else {
partial_visible_assemblies = null;
}
}
}
public string PrivateBinPath {
get {
return private_bin_path;

View File

@@ -58,6 +58,8 @@ namespace System
sig = IntPtr.Zero;
args = IntPtr.Zero;
next_arg = num_args = 0;
if (arglist.args == IntPtr.Zero)
throw new PlatformNotSupportedException ();
Setup (arglist.args, IntPtr.Zero);
}
@@ -67,6 +69,8 @@ namespace System
sig = IntPtr.Zero;
args = IntPtr.Zero;
next_arg = num_args = 0;
if (arglist.args == IntPtr.Zero)
throw new PlatformNotSupportedException ();
Setup (arglist.args, (IntPtr) ptr);
}

View File

@@ -36,11 +36,6 @@
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NETCORE
using Internal.Runtime.CompilerServices;
#endif
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.ConstrainedExecution;

View File

@@ -623,7 +623,7 @@ namespace System
internal bool IsTransparentProxy ()
{
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
return false;
#else
return RemotingServices.IsTransparentProxy (m_target);

View File

@@ -77,7 +77,7 @@ namespace System
Type dt = dasm.GetType (type);
if (realTarget != null) {
#if !DISABLE_REMOTING
#if FEATURE_REMOTING
if (RemotingServices.IsTransparentProxy (realTarget)) {
// The call to IsInstanceOfType will force the proxy
// to load the real type of the remote object. This is

View File

@@ -563,10 +563,12 @@ namespace System {
string dir = null;
#pragma warning disable 162
if (Environment.IsRunningOnWindows)
dir = GetWindowsFolderPath ((int) folder);
else
dir = UnixGetFolderPath (folder, option);
#pragma warning restore 162
#if MONO_FEATURE_CAS
if ((dir != null) && (dir.Length > 0) && SecurityManager.SecurityEnabled) {
@@ -957,7 +959,7 @@ namespace System {
}
// private methods
#if (MONOTOUCH || MONODROID || XAMMAC) && !MOBILE_DESKTOP_HOST
#if (MONOTOUCH || MONODROID || XAMMAC || WASM) && !MOBILE_DESKTOP_HOST
internal const bool IsRunningOnWindows = false;
#else
internal static bool IsRunningOnWindows {

View File

@@ -1,25 +0,0 @@
#if MONOTOUCH && FULL_AOT_RUNTIME
using Crimson.CommonCrypto;
namespace System
{
partial struct Guid
{
public static Guid NewGuid ()
{
byte[] b = new byte [16];
Cryptor.GetRandom (b);
Guid res = new Guid (b);
// Mask in Variant 1-0 in Bit[7..6]
res._d = (byte) ((res._d & 0x3fu) | 0x80u);
// Mask in Version 4 (random based Guid) in Bits[15..13]
res._c = (short) ((res._c & 0x0fffu) | 0x4000u);
return res;
}
}
}
#endif

View File

@@ -38,44 +38,13 @@ namespace System
{
partial struct Guid
{
private static object _rngAccess = new object ();
private static RandomNumberGenerator _rng;
private static RandomNumberGenerator _fastRng;
public static Guid NewGuid ()
{
byte[] b = new byte [16];
// thread-safe access to the prng
lock (_rngAccess) {
if (_rng == null)
_rng = RandomNumberGenerator.Create ();
_rng.GetBytes (b);
}
Guid res = new Guid (b);
// Mask in Variant 1-0 in Bit[7..6]
res._d = (byte) ((res._d & 0x3fu) | 0x80u);
// Mask in Version 4 (random based Guid) in Bits[15..13]
res._c = (short) ((res._c & 0x0fffu) | 0x4000u);
return res;
}
// used in ModuleBuilder so mcs doesn't need to invoke
// CryptoConfig for simple assemblies.
internal static byte[] FastNewGuidArray ()
internal static unsafe byte[] FastNewGuidArray ()
{
byte[] guid = new byte [16];
// thread-safe access to the prng
lock (_rngAccess) {
// if known, use preferred RNG
if (_rng != null)
_fastRng = _rng;
// else use hardcoded default RNG (bypassing CryptoConfig)
if (_fastRng == null)
_fastRng = new RNGCryptoServiceProvider ();
_fastRng.GetBytes (guid);
fixed (byte *ptr = guid) {
Interop.GetRandomBytes(ptr, 16);
}
// Mask in Variant 1-0 in Bit[7..6]

View File

@@ -51,9 +51,9 @@ namespace System
{
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public unsafe struct IntPtr : ISerializable, IEquatable<IntPtr>
public unsafe readonly struct IntPtr : ISerializable, IEquatable<IntPtr>
{
private void *m_value;
private readonly void* m_value;
public static readonly IntPtr Zero;

View File

@@ -42,7 +42,7 @@ namespace System
public abstract class MarshalByRefObject
{
[NonSerialized]
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
private object _identity; //Keep layout equal to avoid runtime issues
#else
private ServerIdentity _identity; // Holds marshalling iformation of the object
@@ -52,7 +52,7 @@ namespace System
{
}
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
internal ServerIdentity ObjectIdentity {
get { throw new NotSupportedException (); }
set { throw new NotSupportedException (); }
@@ -84,7 +84,7 @@ namespace System
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
public virtual ObjRef CreateObjRef (Type requestedType)
{
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
throw new NotSupportedException ();
#else
// This method can only be called when this object has been marshalled
@@ -99,7 +99,7 @@ namespace System
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
public object GetLifetimeService ()
{
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
throw new NotSupportedException ();
#else
if (_identity == null)
@@ -111,7 +111,7 @@ namespace System
[SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
public virtual object InitializeLifetimeService ()
{
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
throw new NotSupportedException ();
#else
if (_identity != null && _identity.Lease != null)
@@ -123,7 +123,7 @@ namespace System
protected MarshalByRefObject MemberwiseClone (bool cloneIdentity)
{
#if DISABLE_REMOTING
#if !FEATURE_REMOTING
throw new NotSupportedException ();
#else
MarshalByRefObject mbr = (MarshalByRefObject) MemberwiseClone ();

View File

@@ -61,7 +61,7 @@ namespace System
get {
if (value == IntPtr.Zero)
throw new ArgumentNullException (String.Empty, "Invalid handle");
return Module.GetMDStreamVersion (value);
return RuntimeModule.GetMDStreamVersion (value);
}
}
@@ -69,7 +69,7 @@ namespace System
{
if (value == IntPtr.Zero)
throw new ArgumentNullException (String.Empty, "Invalid handle");
Module.GetPEKind (value, out peKind, out machine);
RuntimeModule.GetPEKind (value, out peKind, out machine);
}
public RuntimeFieldHandle ResolveFieldHandle (int fieldToken)
@@ -104,7 +104,7 @@ namespace System
ResolveTokenError error;
if (value == IntPtr.Zero)
throw new ArgumentNullException (String.Empty, "Invalid handle");
IntPtr res = Module.ResolveTypeToken (value, typeToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
IntPtr res = RuntimeModule.ResolveTypeToken (value, typeToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
if (res == IntPtr.Zero)
throw new TypeLoadException (String.Format ("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, value.ToInt64 ()));
else
@@ -117,7 +117,7 @@ namespace System
ResolveTokenError error;
if (value == IntPtr.Zero)
throw new ArgumentNullException (String.Empty, "Invalid handle");
IntPtr res = Module.ResolveMethodToken (value, methodToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
IntPtr res = RuntimeModule.ResolveMethodToken (value, methodToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
if (res == IntPtr.Zero)
throw new Exception (String.Format ("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, value.ToInt64 ()));
else
@@ -130,7 +130,7 @@ namespace System
ResolveTokenError error;
if (value == IntPtr.Zero)
throw new ArgumentNullException (String.Empty, "Invalid handle");
IntPtr res = Module.ResolveFieldToken (value, fieldToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
IntPtr res = RuntimeModule.ResolveFieldToken (value, fieldToken, ptrs_from_handles (typeInstantiationContext), ptrs_from_handles (methodInstantiationContext), out error);
if (res == IntPtr.Zero)
throw new Exception (String.Format ("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, value.ToInt64 ()));
else

View File

@@ -54,7 +54,7 @@ namespace System
{
Type type = obj as Type;
#if !FULL_AOT_RUNTIME
if ((type is RuntimeType) || (type is TypeBuilder))
if ((type is RuntimeType) || (RuntimeFeature.IsDynamicCodeSupported && type is TypeBuilder))
#else
if (type is RuntimeType)
#endif
@@ -88,7 +88,7 @@ namespace System
return pseudoAttrs;
else
return new object [] { pseudoAttrs [i] };
return EmptyArray<object>.Value;
return Array.Empty<object> ();
}
return pseudoAttrs;
@@ -121,6 +121,7 @@ namespace System
internal static object[] GetCustomAttributesBase (ICustomAttributeProvider obj, Type attributeType, bool inheritedOnly)
{
object[] attrs;
if (IsUserCattrProvider (obj))
attrs = obj.GetCustomAttributes (attributeType, true);
else
@@ -146,13 +147,18 @@ namespace System
internal static object[] GetCustomAttributes (ICustomAttributeProvider obj, Type attributeType, bool inherit)
{
if (obj == null)
throw new ArgumentNullException ("obj");
throw new ArgumentNullException (nameof (obj));
if (attributeType == null)
throw new ArgumentNullException ("attributeType");
throw new ArgumentNullException (nameof (attributeType));
if (attributeType == typeof (MonoCustomAttrs))
attributeType = null;
#if NETCORE
if (attributeType == typeof (Attribute))
attributeType = null;
#endif
object[] r;
object[] res = GetCustomAttributesBase (obj, attributeType, false);
// shortcut
@@ -613,7 +619,16 @@ namespace System
return GetBaseEventDefinition ((RuntimeEventInfo)obj);
else if (obj is RuntimeMethodInfo)
method = (MethodInfo) obj;
if (obj is RuntimeParameterInfo parinfo) {
var member = parinfo.Member;
if (member is MethodInfo) {
method = (MethodInfo)member;
MethodInfo bmethod = ((RuntimeMethodInfo)method).GetBaseMethod ();
if (bmethod == method)
return null;
return bmethod.GetParameters ()[parinfo.Position];
}
}
/**
* ParameterInfo -> null
* Assembly -> null

View File

@@ -286,5 +286,12 @@ namespace System
return !d1.Equals (d2);
}
#if NETCORE
internal override object GetTarget()
{
return delegates?.Length > 0 ? delegates [delegates.Length - 1].GetTarget () : base.GetTarget ();
}
#endif
}
}

View File

@@ -67,6 +67,11 @@ namespace System
}
}
internal bool IsNullHandle ()
{
return value == IntPtr.Zero;
}
public void GetObjectData (SerializationInfo info, StreamingContext context)
{
if (info == null)
@@ -116,12 +121,11 @@ namespace System
SetValueInternal (field, obj, value);
}
unsafe internal static Object GetValueDirect (RuntimeFieldInfo field, RuntimeType fieldType, void *pTypedRef, RuntimeType contextType)
{
throw new NotImplementedException ("GetValueDirect");
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static unsafe extern internal Object GetValueDirect (RuntimeFieldInfo field, RuntimeType fieldType, void *pTypedRef, RuntimeType contextType);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static unsafe extern internal void SetValueDirect (RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, Object value, RuntimeType contextType);
}
}

View File

@@ -156,37 +156,64 @@ namespace System
return GetGenericTypeDefinition_impl (type);
}
internal static bool HasElementType (RuntimeType type)
{
return IsArray (type) || IsByRef (type) || IsPointer (type);
}
internal static bool HasProxyAttribute (RuntimeType type)
{
throw new NotImplementedException ("HasProxyAttribute");
}
internal static bool IsPrimitive (RuntimeType type)
{
CorElementType corElemType = GetCorElementType (type);
return (corElemType >= CorElementType.ELEMENT_TYPE_BOOLEAN && corElemType <= CorElementType.ELEMENT_TYPE_R8) ||
corElemType == CorElementType.ELEMENT_TYPE_I ||
corElemType == CorElementType.ELEMENT_TYPE_U;
}
internal static bool IsByRef (RuntimeType type)
{
CorElementType corElemType = GetCorElementType (type);
return corElemType == CorElementType.ELEMENT_TYPE_BYREF;
}
internal static bool IsPointer (RuntimeType type)
{
CorElementType corElemType = GetCorElementType (type);
return corElemType == CorElementType.ELEMENT_TYPE_PTR;
}
internal static bool IsArray (RuntimeType type)
{
CorElementType corElemType = GetCorElementType (type);
return corElemType == CorElementType.ELEMENT_TYPE_ARRAY || corElemType == CorElementType.ELEMENT_TYPE_SZARRAY;
}
internal static bool IsSzArray (RuntimeType type)
{
CorElementType corElemType = GetCorElementType (type);
return corElemType == CorElementType.ELEMENT_TYPE_SZARRAY;
}
internal static bool HasElementType (RuntimeType type)
{
CorElementType corElemType = GetCorElementType(type);
return ((corElemType == CorElementType.ELEMENT_TYPE_ARRAY || corElemType == CorElementType.ELEMENT_TYPE_SZARRAY) // IsArray
|| (corElemType == CorElementType.ELEMENT_TYPE_PTR) // IsPointer
|| (corElemType == CorElementType.ELEMENT_TYPE_BYREF)); // IsByRef
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern CorElementType GetCorElementType (RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool HasInstantiation (RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsArray(RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsByRef (RuntimeType type);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static bool IsComObject (RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsInstanceOfType (RuntimeType type, Object o);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsPointer (RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsPrimitive (RuntimeType type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool HasReferences (RuntimeType type);
@@ -210,12 +237,6 @@ namespace System
return false;
}
internal static bool IsSzArray(RuntimeType type)
{
// TODO: Better check
return IsArray (type) && type.GetArrayRank () == 1;
}
internal static bool IsInterface (RuntimeType type)
{
return (type.Attributes & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface;
@@ -323,5 +344,19 @@ namespace System
throw new TypeLoadException ("Error loading '" + typeName + "'");
return t;
}
internal static IntPtr[] CopyRuntimeTypeHandles (RuntimeTypeHandle[] inHandles, out int length)
{
if (inHandles == null || inHandles.Length == 0) {
length = 0;
return null;
}
IntPtr[] outHandles = new IntPtr [inHandles.Length];
for (int i = 0; i < inHandles.Length; i++)
outHandles [i] = inHandles [i].Value;
length = outHandles.Length;
return outHandles;
}
}
}

View File

@@ -44,10 +44,13 @@ namespace System {
public partial class TimeZoneInfo {
[DllImport ("__Internal")]
extern static string xamarin_timezone_get_local_name ();
static TimeZoneInfo CreateLocal ()
{
using (Stream stream = GetMonoTouchData (null)) {
return BuildFromStream ("Local", stream);
return BuildFromStream (xamarin_timezone_get_local_name (), stream);
}
}
@@ -68,7 +71,7 @@ namespace System {
}
}
}
[DllImport ("__Internal")]
extern static IntPtr xamarin_timezone_get_names (ref int count);

View File

@@ -338,8 +338,17 @@ namespace System
// EnumDynamicTimeZoneInformation() might not be available.
}
if (result.Count == 0)
if (result.Count == 0) {
result.Add (Local);
result.Add (Utc);
}
result.Sort ((x, y) =>
{
int comparison = x.BaseUtcOffset.CompareTo(y.BaseUtcOffset);
return comparison == 0 ? string.CompareOrdinal(x.DisplayName, y.DisplayName) : comparison;
});
return result;
}
}

View File

@@ -919,8 +919,9 @@ namespace System
DateTime DST_end = TransitionPoint (rule.DaylightTransitionEnd, year + ((rule.DaylightTransitionStart.Month < rule.DaylightTransitionEnd.Month) ? 0 : 1));
if (dateTime.Kind == DateTimeKind.Utc) {
DST_start -= BaseUtcOffset;
DST_end -= (BaseUtcOffset + rule.DaylightDelta);
DST_end -= BaseUtcOffset;
}
DST_end -= rule.DaylightDelta;
return (dateTime >= DST_start && dateTime < DST_end);
}

View File

@@ -142,7 +142,7 @@ namespace System {
if (nested != null)
return nested;
else
return EmptyArray<TypeName>.Value;
return Array.Empty<TypeName> ();
}
}
@@ -151,7 +151,7 @@ namespace System {
if (modifier_spec != null)
return modifier_spec;
else
return EmptyArray<ModifierSpec>.Value;
return Array.Empty<ModifierSpec> ();
}
}

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