Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -36,7 +36,7 @@
using System.Globalization;
using System.IO;
using System.Reflection;
#if !FULL_AOT_RUNTIME
#if MONO_FEATURE_SRE
using System.Reflection.Emit;
#endif
using System.Threading;
@@ -505,7 +505,7 @@ namespace System {
return (oh != null) ? oh.Unwrap () : null;
}
#if !FULL_AOT_RUNTIME
#if MONO_FEATURE_SRE
public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
{
return DefineDynamicAssembly (name, access, null, null, null, null, null, false);
@@ -707,25 +707,26 @@ namespace System {
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly);
internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly, ref StackCrawlMark stackMark);
public Assembly Load (AssemblyName assemblyRef)
{
return Load (assemblyRef, null);
}
internal Assembly LoadSatellite (AssemblyName assemblyRef, bool throwOnError)
internal Assembly LoadSatellite (AssemblyName assemblyRef, bool throwOnError, ref StackCrawlMark stackMark)
{
if (assemblyRef == null)
throw new ArgumentNullException ("assemblyRef");
Assembly result = LoadAssembly (assemblyRef.FullName, null, false);
Assembly result = LoadAssembly (assemblyRef.FullName, null, false, ref stackMark);
if (result == null && throwOnError)
throw new FileNotFoundException (null, assemblyRef.Name);
return result;
}
[Obsolete ("Use an overload that does not take an Evidence parameter")]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
{
if (assemblyRef == null)
@@ -738,7 +739,8 @@ namespace System {
throw new ArgumentException (Locale.GetText ("assemblyRef.Name cannot be empty."), "assemblyRef");
}
Assembly assembly = LoadAssembly (assemblyRef.FullName, assemblySecurity, false);
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
Assembly assembly = LoadAssembly (assemblyRef.FullName, assemblySecurity, false, ref stackMark);
if (assembly != null)
return assembly;
@@ -777,18 +779,22 @@ namespace System {
return assembly;
}
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load (string assemblyString)
{
return Load (assemblyString, null, false);
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return Load (assemblyString, null, false, ref stackMark);
}
[Obsolete ("Use an overload that does not take an Evidence parameter")]
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
public Assembly Load (string assemblyString, Evidence assemblySecurity)
{
return Load (assemblyString, assemblySecurity, false);
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return Load (assemblyString, assemblySecurity, false, ref stackMark);
}
internal Assembly Load (string assemblyString, Evidence assemblySecurity, bool refonly)
internal Assembly Load (string assemblyString, Evidence assemblySecurity, bool refonly, ref StackCrawlMark stackMark)
{
if (assemblyString == null)
throw new ArgumentNullException ("assemblyString");
@@ -796,7 +802,7 @@ namespace System {
if (assemblyString.Length == 0)
throw new ArgumentException ("assemblyString cannot have zero length");
Assembly assembly = LoadAssembly (assemblyString, assemblySecurity, refonly);
Assembly assembly = LoadAssembly (assemblyString, assemblySecurity, refonly, ref stackMark);
if (assembly == null)
throw new FileNotFoundException (null, assemblyString);
return assembly;
@@ -941,7 +947,7 @@ namespace System {
InternalPushDomainRef (domain);
pushed = true;
InternalSetDomain (domain);
object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
object o = ((RuntimeMethodInfo) method).InternalInvoke (obj, args, out exc);
if (exc != null)
throw exc;
return o;
@@ -963,7 +969,7 @@ namespace System {
InternalPushDomainRefByID (domain_id);
pushed = true;
InternalSetDomainByID (domain_id);
object o = ((MonoMethod) method).InternalInvoke (obj, args, out exc);
object o = ((RuntimeMethodInfo) method).InternalInvoke (obj, args, out exc);
if (exc != null)
throw exc;
return o;
@@ -1339,7 +1345,7 @@ namespace System {
string name;
#if !FULL_AOT_RUNTIME
#if MONO_FEATURE_SRE
if (name_or_tb is TypeBuilder)
name = ((TypeBuilder) name_or_tb).FullName;
else

View File

@@ -37,7 +37,11 @@ using System.Runtime.InteropServices;
namespace System
{
[StructLayout (LayoutKind.Auto)]
public struct ArgIterator
public
#if NETCORE
ref
#endif
struct ArgIterator
{
#pragma warning disable 169, 414
IntPtr sig;
@@ -73,7 +77,7 @@ namespace System
public override bool Equals (object o)
{
throw new NotSupportedException (Locale.GetText ("ArgIterator does not support Equals."));
throw new NotSupportedException ("ArgIterator does not support Equals.");
}
public override int GetHashCode ()
@@ -85,28 +89,36 @@ namespace System
public TypedReference GetNextArg ()
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg ();
throw new InvalidOperationException ("Invalid iterator position.");
TypedReference result = new TypedReference ();
unsafe {
IntGetNextArg (&result);
}
return result;
}
[MethodImpl (MethodImplOptions.InternalCall)]
extern TypedReference IntGetNextArg ();
extern unsafe void IntGetNextArg (void *res);
[CLSCompliant (false)]
public TypedReference GetNextArg (RuntimeTypeHandle rth)
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
return IntGetNextArg (rth.Value);
throw new InvalidOperationException ("Invalid iterator position.");
TypedReference result = new TypedReference ();
unsafe {
IntGetNextArgWithType (&result, rth.Value);
}
return result;
}
[MethodImpl (MethodImplOptions.InternalCall)]
extern TypedReference IntGetNextArg (IntPtr rth);
extern unsafe void IntGetNextArgWithType (void *res, IntPtr rth);
public RuntimeTypeHandle GetNextArgType ()
{
if (num_args == next_arg)
throw new InvalidOperationException (Locale.GetText ("Invalid iterator position."));
throw new InvalidOperationException ("Invalid iterator position.");
return new RuntimeTypeHandle (IntGetNextArgType ());
}

View File

@@ -37,6 +37,10 @@ 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;
@@ -106,7 +110,7 @@ namespace System
internal bool InternalArray__ICollection_Contains<T> (T item)
{
if (this.Rank > 1)
throw new RankException (Locale.GetText ("Only single dimension arrays are supported."));
throw new RankException ("Only single dimension arrays are supported.");
int length = this.Length;
for (int i = 0; i < length; i++) {
@@ -161,7 +165,7 @@ namespace System
internal int InternalArray__IndexOf<T> (T item)
{
if (this.Rank > 1)
throw new RankException (Locale.GetText ("Only single dimension arrays are supported."));
throw new RankException ("Only single dimension arrays are supported.");
int length = this.Length;
for (int i = 0; i < length; i++) {
@@ -364,8 +368,7 @@ namespace System
var lb = GetLowerBound (0);
if (index < lb || index > GetUpperBound (0))
throw new IndexOutOfRangeException (Locale.GetText (
"Index has to be between upper and lower bound of the array."));
throw new IndexOutOfRangeException ("Index has to be between upper and lower bound of the array.");
if (GetType ().GetElementType ().IsPointer)
throw new NotSupportedException ("Type is not supported.");
@@ -392,8 +395,7 @@ namespace System
var lb = GetLowerBound (0);
if (index < lb || index > GetUpperBound (0))
throw new IndexOutOfRangeException (Locale.GetText (
"Index has to be >= lower bound and <= upper bound of the array."));
throw new IndexOutOfRangeException ("Index has to be >= lower bound and <= upper bound of the array.");
if (GetType ().GetElementType ().IsPointer)
throw new NotSupportedException ("Type is not supported.");
@@ -490,18 +492,16 @@ namespace System
throw new NotSupportedException ("Array type can not be an open generic type");
if (lengths.Length < 1)
throw new ArgumentException (Locale.GetText ("Arrays must contain >= 1 elements."));
throw new ArgumentException ("Arrays must contain >= 1 elements.");
if (lengths.Length != lowerBounds.Length)
throw new ArgumentException (Locale.GetText ("Arrays must be of same size."));
throw new ArgumentException ("Arrays must be of same size.");
for (int j = 0; j < lowerBounds.Length; j ++) {
if (lengths [j] < 0)
throw new ArgumentOutOfRangeException ("lengths", Locale.GetText (
"Each value has to be >= 0."));
throw new ArgumentOutOfRangeException ("lengths", "Each value has to be >= 0.");
if ((long)lowerBounds [j] + (long)lengths [j] > (long)Int32.MaxValue)
throw new ArgumentOutOfRangeException ("lengths", Locale.GetText (
"Length + bound must not exceed Int32.MaxValue."));
throw new ArgumentOutOfRangeException ("lengths", "Length + bound must not exceed Int32.MaxValue.");
}
if (lengths.Length > 255)
@@ -558,19 +558,16 @@ namespace System
throw new ArgumentNullException ("destinationArray");
if (length < 0)
throw new ArgumentOutOfRangeException ("length", Locale.GetText (
"Value has to be >= 0."));;
throw new ArgumentOutOfRangeException ("length", "Value has to be >= 0.");
if (sourceArray.Rank != destinationArray.Rank)
throw new RankException(SR.Rank_MultiDimNotSupported);
if (sourceIndex < 0)
throw new ArgumentOutOfRangeException ("sourceIndex", Locale.GetText (
"Value has to be >= 0."));;
throw new ArgumentOutOfRangeException ("sourceIndex", "Value has to be >= 0.");
if (destinationIndex < 0)
throw new ArgumentOutOfRangeException ("destinationIndex", Locale.GetText (
"Value has to be >= 0."));;
throw new ArgumentOutOfRangeException ("destinationIndex", "Value has to be >= 0.");
if (FastCopy (sourceArray, sourceIndex, destinationArray, destinationIndex, length))
return;
@@ -670,12 +667,20 @@ namespace System
static int IndexOfImpl<T>(T[] array, T value, int startIndex, int count)
{
#if NETCORE
throw new NotImplementedException ();
#else
return EqualityComparer<T>.Default.IndexOf (array, value, startIndex, count);
#endif
}
static int LastIndexOfImpl<T>(T[] array, T value, int startIndex, int count)
{
#if NETCORE
throw new NotImplementedException ();
#else
return EqualityComparer<T>.Default.LastIndexOf (array, value, startIndex, count);
#endif
}
static void SortImpl (Array keys, Array items, int index, int length, IComparer comparer)

View File

@@ -46,7 +46,11 @@ namespace System {
public override void Flush ()
{
string s = sb.ToString ();
string s;
lock (sb) {
s = sb.ToString ();
sb.Length = 0;
}
try {
xamarin_log (s);
}
@@ -56,14 +60,14 @@ namespace System {
direct_write_to_stdout (Environment.NewLine);
} catch (Exception){}
}
sb.Length = 0;
}
// minimum to override - see http://msdn.microsoft.com/en-us/library/system.io.textwriter.aspx
public override void Write (char value)
{
try {
sb.Append (value);
lock (sb)
sb.Append (value);
}
catch (Exception) {
}
@@ -73,9 +77,11 @@ namespace System {
public override void Write (string value)
{
try {
sb.Append (value);
if (value != null && value.Length >= CoreNewLine.Length && EndsWithNewLine (value))
Flush ();
lock (sb) {
sb.Append (value);
if (EndsWithNewLine (sb))
Flush ();
}
}
catch (Exception) {
}
@@ -84,26 +90,21 @@ namespace System {
/* Called from TextWriter:WriteLine(string) */
public override void Write(char[] buffer, int index, int count) {
try {
sb.Append (buffer);
if (buffer != null && buffer.Length >= CoreNewLine.Length && EndsWithNewLine (buffer))
Flush ();
lock (sb) {
sb.Append (buffer, index, count);
if (EndsWithNewLine (sb))
Flush ();
}
}
catch (Exception) {
}
}
bool EndsWithNewLine (string value)
bool EndsWithNewLine (StringBuilder value)
{
for (int i = 0, v = value.Length - CoreNewLine.Length; i < CoreNewLine.Length; ++i, ++v) {
if (value [v] != CoreNewLine [i])
return false;
}
return true;
}
if (value.Length < CoreNewLine.Length)
return false;
bool EndsWithNewLine (char[] value)
{
for (int i = 0, v = value.Length - CoreNewLine.Length; i < CoreNewLine.Length; ++i, ++v) {
if (value [v] != CoreNewLine [i])
return false;

View File

@@ -47,8 +47,6 @@ namespace System
public bool curried_first_arg;
}
[ClassInterface (ClassInterfaceType.AutoDual)]
[System.Runtime.InteropServices.ComVisible (true)]
[Serializable]
[StructLayout (LayoutKind.Sequential)]
public abstract class Delegate : ICloneable, ISerializable
@@ -352,7 +350,7 @@ namespace System
for (Type targetType = target; targetType != null; targetType = targetType.BaseType) {
MethodInfo mi = targetType.GetMethod (method, flags,
null, delargtypes, EmptyArray<ParameterModifier>.Value);
null, delargtypes, Array.Empty<ParameterModifier>());
if (mi != null && return_type_match (invoke.ReturnType, mi.ReturnType)) {
info = mi;
break;
@@ -515,7 +513,7 @@ namespace System
} else {
if (method != IntPtr.Zero) {
if (!method_is_virtual)
method_info = (MethodInfo)MethodBase.GetMethodFromHandleNoGenericCheck (new RuntimeMethodHandle (method));
method_info = (MethodInfo)RuntimeMethodInfo.GetMethodFromHandleNoGenericCheck (new RuntimeMethodHandle (method));
else
method_info = GetVirtualMethod_internal ();
}
@@ -547,7 +545,7 @@ namespace System
return a;
if (a.GetType () != b.GetType ())
throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types. First is {0} second is {1}.", a.GetType ().FullName, b.GetType ().FullName));
throw new ArgumentException (string.Format ("Incompatible Delegate Types. First is {0} second is {1}.", a.GetType ().FullName, b.GetType ().FullName));
return a.CombineImpl (b);
}
@@ -584,7 +582,7 @@ namespace System
return source;
if (source.GetType () != value.GetType ())
throw new ArgumentException (Locale.GetText ("Incompatible Delegate Types. First is {0} second is {1}.", source.GetType ().FullName, value.GetType ().FullName));
throw new ArgumentException (string.Format ("Incompatible Delegate Types. First is {0} second is {1}.", source.GetType ().FullName, value.GetType ().FullName));
return source.RemoveImpl (value);
}

View File

@@ -151,10 +151,10 @@ namespace System {
public static string CurrentDirectory
{
get {
return Directory.GetCurrentDirectory ();
return Directory.InsecureGetCurrentDirectory ();
}
set {
Directory.SetCurrentDirectory (value);
Directory.InsecureSetCurrentDirectory (value);
}
}
@@ -904,7 +904,16 @@ namespace System {
}
#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern void InternalSetEnvironmentVariable (string variable, string value);
internal unsafe static extern void InternalSetEnvironmentVariable (char *variable, int variable_length,
char *value, int value_length);
internal unsafe static void InternalSetEnvironmentVariable (string variable, string value)
{
fixed (char *fixed_variable = variable)
fixed (char *fixed_value = value)
InternalSetEnvironmentVariable (fixed_variable, variable?.Length ?? 0,
fixed_value, value?.Length ?? 0);
}
[SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode=true)]
public static void FailFast (string message)
@@ -977,7 +986,7 @@ namespace System {
internal extern static string internalGetGacPath ();
#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static string [] GetLogicalDrivesInternal ();
internal extern static string [] GetLogicalDrivesInternal ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static string [] GetEnvironmentVariableNames ();

View File

@@ -51,7 +51,7 @@ namespace System
{
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public unsafe struct IntPtr : ISerializable
public unsafe struct IntPtr : ISerializable, IEquatable<IntPtr>
{
private void *m_value;
@@ -232,5 +232,10 @@ namespace System
{
return m_value == null;
}
bool IEquatable<IntPtr>.Equals(IntPtr other)
{
return m_value == other.m_value;
}
}
}

View File

@@ -72,11 +72,11 @@ namespace System
internal static object[] GetPseudoCustomAttributes (ICustomAttributeProvider obj, Type attributeType) {
object[] pseudoAttrs = null;
/* FIXME: Add other types */
if (obj is MonoMethod monoMethod)
if (obj is RuntimeMethodInfo monoMethod)
pseudoAttrs = monoMethod.GetPseudoCustomAttributes ();
else if (obj is FieldInfo fieldInfo)
else if (obj is RuntimeFieldInfo fieldInfo)
pseudoAttrs = fieldInfo.GetPseudoCustomAttributes ();
else if (obj is MonoParameterInfo monoParamInfo)
else if (obj is RuntimeParameterInfo monoParamInfo)
pseudoAttrs = monoParamInfo.GetPseudoCustomAttributes ();
else if (obj is Type t)
pseudoAttrs = GetPseudoCustomAttributes (t);
@@ -292,6 +292,9 @@ namespace System
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
[PreserveDependency(".ctor(System.Reflection.ConstructorInfo,System.Reflection.Assembly,System.IntPtr,System.UInt32)", "System.Reflection.CustomAttributeData")]
[PreserveDependency(".ctor(System.Reflection.MemberInfo,System.Object)", "System.Reflection.CustomAttributeNamedArgument")]
[PreserveDependency(".ctor(System.Type,System.Object)", "System.Reflection.CustomAttributeTypedArgument")]
static extern CustomAttributeData [] GetCustomAttributesDataInternal (ICustomAttributeProvider obj);
internal static IList<CustomAttributeData> GetCustomAttributesData (ICustomAttributeProvider obj, bool inherit = false)
@@ -460,11 +463,11 @@ namespace System
CustomAttributeData[] pseudoAttrsData = null;
/* FIXME: Add other types */
if (obj is MonoMethod monoMethod)
if (obj is RuntimeMethodInfo monoMethod)
pseudoAttrsData = monoMethod.GetPseudoCustomAttributesData ();
else if (obj is FieldInfo fieldInfo)
else if (obj is RuntimeFieldInfo fieldInfo)
pseudoAttrsData = fieldInfo.GetPseudoCustomAttributesData ();
else if (obj is MonoParameterInfo monoParamInfo)
else if (obj is RuntimeParameterInfo monoParamInfo)
pseudoAttrsData = monoParamInfo.GetPseudoCustomAttributesData ();
else if (obj is Type t)
pseudoAttrsData = GetPseudoCustomAttributesData (t);
@@ -547,7 +550,7 @@ namespace System
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern bool IsDefinedInternal (ICustomAttributeProvider obj, Type AttributeType);
static PropertyInfo GetBasePropertyDefinition (MonoProperty property)
static PropertyInfo GetBasePropertyDefinition (RuntimePropertyInfo property)
{
MethodInfo method = property.GetGetMethod (true);
if (method == null || !method.IsVirtual)
@@ -555,7 +558,7 @@ namespace System
if (method == null || !method.IsVirtual)
return null;
MethodInfo baseMethod = method.GetBaseMethod ();
MethodInfo baseMethod = ((RuntimeMethodInfo)method).GetBaseMethod ();
if (baseMethod != null && baseMethod != method) {
ParameterInfo[] parameters = property.GetIndexParameters ();
if (parameters != null && parameters.Length > 0) {
@@ -572,7 +575,7 @@ namespace System
}
static EventInfo GetBaseEventDefinition (MonoEvent evt)
static EventInfo GetBaseEventDefinition (RuntimeEventInfo evt)
{
MethodInfo method = evt.GetAddMethod (true);
if (method == null || !method.IsVirtual)
@@ -582,7 +585,7 @@ namespace System
if (method == null || !method.IsVirtual)
return null;
MethodInfo baseMethod = method.GetBaseMethod ();
MethodInfo baseMethod = ((RuntimeMethodInfo)method).GetBaseMethod ();
if (baseMethod != null && baseMethod != method) {
BindingFlags flags = method.IsPublic ? BindingFlags.Public : BindingFlags.NonPublic;
flags |= method.IsStatic ? BindingFlags.Static : BindingFlags.Instance;
@@ -592,8 +595,8 @@ namespace System
return null;
}
// Handles Type, MonoProperty and MonoMethod.
// The runtime has also cases for MonoEvent, MonoField, Assembly and ParameterInfo,
// Handles Type, RuntimePropertyInfo and RuntimeMethodInfo.
// The runtime has also cases for RuntimeEventInfo, RuntimeFieldInfo, Assembly and ParameterInfo,
// but for those we return null here.
static ICustomAttributeProvider GetBase (ICustomAttributeProvider obj)
{
@@ -604,23 +607,23 @@ namespace System
return ((Type) obj).BaseType;
MethodInfo method = null;
if (obj is MonoProperty)
return GetBasePropertyDefinition ((MonoProperty) obj);
else if (obj is MonoEvent)
return GetBaseEventDefinition ((MonoEvent)obj);
else if (obj is MonoMethod)
if (obj is RuntimePropertyInfo)
return GetBasePropertyDefinition ((RuntimePropertyInfo) obj);
else if (obj is RuntimeEventInfo)
return GetBaseEventDefinition ((RuntimeEventInfo)obj);
else if (obj is RuntimeMethodInfo)
method = (MethodInfo) obj;
/**
* ParameterInfo -> null
* Assembly -> null
* MonoEvent -> null
* MonoField -> null
* RuntimeEventInfo -> null
* RuntimeFieldInfo -> null
*/
if (method == null || !method.IsVirtual)
return null;
MethodInfo baseMethod = method.GetBaseMethod ();
MethodInfo baseMethod = ((RuntimeMethodInfo)method).GetBaseMethod ();
if (baseMethod == method)
return null;

View File

@@ -31,13 +31,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Runtime.InteropServices;
namespace System
{
[ComVisible (true)]
public struct RuntimeArgumentHandle
public ref struct RuntimeArgumentHandle
{
#pragma warning disable 649
internal IntPtr args;

View File

@@ -55,10 +55,10 @@ namespace System
if (info == null)
throw new ArgumentNullException ("info");
MonoField mf = ((MonoField) info.GetValue ("FieldObj", typeof (MonoField)));
RuntimeFieldInfo mf = ((RuntimeFieldInfo) info.GetValue ("FieldObj", typeof (RuntimeFieldInfo)));
value = mf.FieldHandle.Value;
if (value == IntPtr.Zero)
throw new SerializationException (Locale.GetText ("Insufficient state."));
throw new SerializationException ("Insufficient state.");
}
public IntPtr Value {
@@ -75,7 +75,7 @@ namespace System
if (value == IntPtr.Zero)
throw new SerializationException ("Object fields may not be properly initialized");
info.AddValue ("FieldObj", (MonoField) FieldInfo.GetFieldFromHandle (this), typeof (MonoField));
info.AddValue ("FieldObj", (RuntimeFieldInfo) FieldInfo.GetFieldFromHandle (this), typeof (RuntimeFieldInfo));
}
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
@@ -111,17 +111,17 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern void SetValueInternal (FieldInfo fi, object obj, object value);
internal static void SetValue (RtFieldInfo field, Object obj, Object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized)
internal static void SetValue (RuntimeFieldInfo field, Object obj, Object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized)
{
SetValueInternal (field, obj, value);
}
unsafe internal static Object GetValueDirect (RtFieldInfo field, RuntimeType fieldType, void *pTypedRef, RuntimeType contextType)
unsafe internal static Object GetValueDirect (RuntimeFieldInfo field, RuntimeType fieldType, void *pTypedRef, RuntimeType contextType)
{
throw new NotImplementedException ("GetValueDirect");
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static unsafe extern internal void SetValueDirect (RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, Object value, RuntimeType contextType);
static unsafe extern internal void SetValueDirect (RuntimeFieldInfo field, RuntimeType fieldType, void* pTypedRef, Object value, RuntimeType contextType);
}
}

View File

@@ -32,7 +32,6 @@ using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Runtime.ConstrainedExecution;
using System.Text;
@@ -54,10 +53,10 @@ namespace System
if (info == null)
throw new ArgumentNullException ("info");
MonoMethod mm = ((MonoMethod) info.GetValue ("MethodObj", typeof (MonoMethod)));
RuntimeMethodInfo mm = ((RuntimeMethodInfo) info.GetValue ("MethodObj", typeof (RuntimeMethodInfo)));
value = mm.MethodHandle.Value;
if (value == IntPtr.Zero)
throw new SerializationException (Locale.GetText ("Insufficient state."));
throw new SerializationException ("Insufficient state.");
}
public IntPtr Value {
@@ -75,13 +74,12 @@ namespace System
if (value == IntPtr.Zero)
throw new SerializationException ("Object fields may not be properly initialized");
info.AddValue ("MethodObj", (MonoMethod) MethodBase.GetMethodFromHandle (this), typeof (MonoMethod));
info.AddValue ("MethodObj", (RuntimeMethodInfo) MethodBase.GetMethodFromHandle (this), typeof (RuntimeMethodInfo));
}
[MethodImpl (MethodImplOptions.InternalCall)]
static extern IntPtr GetFunctionPointer (IntPtr m);
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public IntPtr GetFunctionPointer ()
{
return GetFunctionPointer (value);

View File

@@ -37,7 +37,6 @@ using System.Runtime.ConstrainedExecution;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Diagnostics.Contracts;
namespace System
{
@@ -65,7 +64,7 @@ namespace System
RuntimeType mt = ((RuntimeType) info.GetValue ("TypeObj", typeof (RuntimeType)));
value = mt.TypeHandle.Value;
if (value == IntPtr.Zero)
throw new SerializationException (Locale.GetText ("Insufficient state."));
throw new SerializationException ("Insufficient state.");
}
public IntPtr Value {
@@ -198,7 +197,11 @@ namespace System
internal static bool IsContextful (RuntimeType type)
{
#if NETCORE
return false;
#else
return typeof (ContextBoundObject).IsAssignableFrom (type);
#endif
}
internal static bool IsEquivalentTo (RuntimeType rtType1, RuntimeType rtType2)
@@ -258,5 +261,67 @@ namespace System
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool is_subclass_of (IntPtr childType, IntPtr baseType);
[PreserveDependency (".ctor()", "System.Runtime.CompilerServices.IsByRefLikeAttribute")]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal extern static bool IsByRefLike (RuntimeType type);
internal static bool IsTypeDefinition (RuntimeType type)
{
// That's how it has been done on CoreFX but we have no GetCorElementType method implementation
// see https://github.com/dotnet/coreclr/pull/11355
// CorElementType corElemType = GetCorElementType (type);
// if (!((corElemType >= CorElementType.Void && corElemType < CorElementType.Ptr) ||
// corElemType == CorElementType.ValueType ||
// corElemType == CorElementType.Class ||
// corElemType == CorElementType.TypedByRef ||
// corElemType == CorElementType.I ||
// corElemType == CorElementType.U ||
// corElemType == CorElementType.Object))
// return false;
// if (HasInstantiation (type) && !IsGenericTypeDefinition (type))
// return false;
// return true;
// It's like a workaround mentioned in https://github.com/dotnet/corefx/issues/17345
return !type.HasElementType && !type.IsConstructedGenericType && !type.IsGenericParameter;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern RuntimeType internal_from_name (string name, ref StackCrawlMark stackMark, Assembly callerAssembly, bool throwOnError, bool ignoreCase, bool reflectionOnly);
internal static RuntimeType GetTypeByName(string typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref StackCrawlMark stackMark,
bool loadTypeFromPartialName)
{
if (typeName == null)
throw new ArgumentNullException ("typeName");
if (typeName == String.Empty)
if (throwOnError)
throw new TypeLoadException ("A null or zero length string does not represent a valid Type.");
else
return null;
if (reflectionOnly) {
int idx = typeName.IndexOf (',');
if (idx < 0 || idx == 0 || idx == typeName.Length - 1)
throw new ArgumentException ("Assembly qualifed type name is required", "typeName");
string an = typeName.Substring (idx + 1);
Assembly a;
try {
a = Assembly.ReflectionOnlyLoad (an);
} catch {
if (throwOnError)
throw;
return null;
}
return (RuntimeType)a.GetType (typeName.Substring (0, idx), throwOnError, ignoreCase);
}
var t = internal_from_name (typeName, ref stackMark, null, throwOnError, ignoreCase, false);
if (throwOnError && t == null)
throw new TypeLoadException ("Error loading '" + typeName + "'");
return t;
}
}
}

View File

@@ -1,214 +0,0 @@
//
// System.TimeZone.cs
//
// Authors:
// Duncan Mak (duncan@ximian.com)
// Ajay Kumar Dwivedi (adwiv@yahoo.com)
// Martin Baulig (martin@gnome.org)
//
// (C) Ximian, Inc.
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
// Copyright 2011 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.
//
//
// TODO:
//
// Rewrite ToLocalTime to use GetLocalTimeDiff(DateTime,TimeSpan),
// this should only leave the validation at the beginning (for MaxValue)
// and then call the helper function. This would remove all the
// ifdefs in that code, and replace it with only one, for the construction
// of the object.
//
// Rewrite ToUniversalTime to use a similar setup to that
//
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
namespace System
{
[Serializable]
[ComVisible (true)]
public abstract class TimeZone
{
// Fields
static TimeZone currentTimeZone;
[NonSerialized]
static object tz_lock = new object ();
[NonSerialized]
static long timezone_check;
// Constructor
protected TimeZone ()
{
}
// Properties
public static TimeZone CurrentTimeZone {
get {
long now = DateTime.UtcNow.Ticks;
TimeZone tz = currentTimeZone;
lock (tz_lock) {
if (tz == null || Math.Abs (now - timezone_check) > TimeSpan.TicksPerMinute) {
tz = new CurrentSystemTimeZone ();
timezone_check = now;
currentTimeZone = tz;
}
}
return tz;
}
}
public abstract string DaylightName {
get;
}
public abstract string StandardName {
get;
}
// Methods
public abstract DaylightTime GetDaylightChanges (int year);
public abstract TimeSpan GetUtcOffset (DateTime time);
public virtual bool IsDaylightSavingTime (DateTime time)
{
return IsDaylightSavingTime (time, GetDaylightChanges (time.Year));
}
public static bool IsDaylightSavingTime (DateTime time, DaylightTime daylightTimes)
{
if (daylightTimes == null)
throw new ArgumentNullException ("daylightTimes");
// If Start == End, then DST is off
if (daylightTimes.Start.Ticks == daylightTimes.End.Ticks)
return false;
//We are in the northern hemisphere.
if (daylightTimes.Start.Ticks < daylightTimes.End.Ticks) {
if (daylightTimes.Start.Ticks < time.Ticks && daylightTimes.End.Ticks > time.Ticks)
return true; // time lies between Start and End
}
else { // We are in the southern hemisphere.
if (time.Year == daylightTimes.Start.Year && time.Year == daylightTimes.End.Year)
if (time.Ticks < daylightTimes.End.Ticks || time.Ticks > daylightTimes.Start.Ticks)
return true; // time is less than End OR more than Start
}
return false;
}
public virtual DateTime ToLocalTime (DateTime time)
{
if (time.Kind == DateTimeKind.Local)
return time;
TimeSpan utcOffset = GetUtcOffset (new DateTime (time.Ticks));
if (utcOffset.Ticks > 0) {
if (DateTime.MaxValue - utcOffset < time)
return DateTime.SpecifyKind (DateTime.MaxValue, DateTimeKind.Local);
} else if (utcOffset.Ticks < 0) {
if (time.Ticks + utcOffset.Ticks < DateTime.MinValue.Ticks)
return DateTime.SpecifyKind (DateTime.MinValue, DateTimeKind.Local);
}
return DateTime.SpecifyKind (time.Add (utcOffset), DateTimeKind.Local);
}
public virtual DateTime ToUniversalTime (DateTime time)
{
if (time.Kind == DateTimeKind.Utc)
return time;
TimeSpan offset = GetUtcOffset (time);
if (offset.Ticks < 0) {
if (DateTime.MaxValue + offset < time)
return DateTime.SpecifyKind (DateTime.MaxValue, DateTimeKind.Utc);
} else if (offset.Ticks > 0) {
if (DateTime.MinValue + offset > time)
return DateTime.SpecifyKind (DateTime.MinValue, DateTimeKind.Utc);
}
return DateTime.SpecifyKind (new DateTime (time.Ticks - offset.Ticks), DateTimeKind.Utc);
}
internal static void ClearCachedData ()
{
currentTimeZone = null;
}
}
[Serializable]
internal class CurrentSystemTimeZone : TimeZone {
readonly TimeZoneInfo LocalTimeZone;
// Constructor
internal CurrentSystemTimeZone ()
{
LocalTimeZone = TimeZoneInfo.Local;
}
public override string DaylightName {
get {
return LocalTimeZone.DaylightName;
}
}
public override string StandardName {
get {
return LocalTimeZone.StandardName;
}
}
public override System.Globalization.DaylightTime GetDaylightChanges (int year)
{
return LocalTimeZone.GetDaylightChanges (year);
}
public override TimeSpan GetUtcOffset (DateTime dateTime)
{
if (dateTime.Kind == DateTimeKind.Utc)
return TimeSpan.Zero;
return LocalTimeZone.GetUtcOffset (dateTime);
}
public override bool IsDaylightSavingTime (DateTime dateTime)
{
if (dateTime.Kind == DateTimeKind.Utc)
return false;
return LocalTimeZone.IsDaylightSavingTime (dateTime);
}
}
}

View File

@@ -0,0 +1,30 @@
#if WASM
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.InteropServices;
namespace System {
public partial class TimeZoneInfo {
static TimeZoneInfo CreateLocal ()
{
return TimeZoneInfo.Utc;
}
static TimeZoneInfo FindSystemTimeZoneByIdCore (string id)
{
throw new NotImplementedException ();
}
static void GetSystemTimeZonesCore (List<TimeZoneInfo> systemTimeZones)
{
}
}
}
#endif

View File

@@ -149,7 +149,7 @@ namespace System
return true;
}
#if !MONODROID && !MONOTOUCH && !XAMMAC
#if !MONODROID && !MONOTOUCH && !XAMMAC && !WASM
static TimeZoneInfo CreateLocal ()
{
#if WIN_PLATFORM
@@ -245,7 +245,7 @@ namespace System
throw new NotImplementedException ("This method is not implemented for this platform");
#endif
}
#endif // !MONODROID && !MONOTOUCH && !XAMMAC
#endif // !MONODROID && !MONOTOUCH && !XAMMAC && !WASM
string standardDisplayName;
public string StandardName {

View File

@@ -30,6 +30,7 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading;
namespace System {
internal interface ModifierSpec {
@@ -295,11 +296,11 @@ namespace System {
return false;
}
internal Type Resolve (Func<AssemblyName,Assembly> assemblyResolver, Func<Assembly,string,bool,Type> typeResolver, bool throwOnError, bool ignoreCase)
internal Type Resolve (Func<AssemblyName,Assembly> assemblyResolver, Func<Assembly,string,bool,Type> typeResolver, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark)
{
Assembly asm = null;
if (assemblyResolver == null && typeResolver == null)
return Type.GetType (DisplayFullName, throwOnError, ignoreCase);
return RuntimeType.GetType (DisplayFullName, throwOnError, ignoreCase, false, ref stackMark);
if (assembly_name != null) {
if (assemblyResolver != null)
@@ -340,7 +341,7 @@ namespace System {
if (generic_params != null) {
Type[] args = new Type [generic_params.Count];
for (int i = 0; i < args.Length; ++i) {
var tmp = generic_params [i].Resolve (assemblyResolver, typeResolver, throwOnError, ignoreCase);
var tmp = generic_params [i].Resolve (assemblyResolver, typeResolver, throwOnError, ignoreCase, ref stackMark);
if (tmp == null) {
if (throwOnError)
throw new TypeLoadException ("Could not resolve type '" + generic_params [i].name + "'");

View File

@@ -46,7 +46,7 @@ namespace System
[Serializable]
[CLSCompliant (false)]
[System.Runtime.InteropServices.ComVisible (true)]
public unsafe struct UIntPtr : ISerializable
public unsafe struct UIntPtr : ISerializable, IEquatable<UIntPtr>
{
public static readonly UIntPtr Zero = new UIntPtr (0u);
private void* _pointer;
@@ -181,5 +181,10 @@ namespace System
{
return (UIntPtr) (unchecked (((byte *) pointer) - offset));
}
bool IEquatable<UIntPtr>.Equals(UIntPtr other)
{
return _pointer == other._pointer;
}
}
}