Imported Upstream version 5.20.0.180

Former-commit-id: ff953ca879339fe1e1211f7220f563e1342e66cb
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-02-04 20:11:37 +00:00
parent 0e2d47d1c8
commit 0510252385
3360 changed files with 83827 additions and 39243 deletions

View File

@@ -14,15 +14,17 @@ namespace System
// converting an array of bytes to one of the base data
// types, as well as for converting a base data type to an
// array of bytes.
public static class BitConverter
public static partial class BitConverter
{
// This field indicates the "endianess" of the architecture.
// The value is set to true if the architecture is
// little endian; false if it is big endian.
#if !MONO
#if BIGENDIAN
public static readonly bool IsLittleEndian /* = false */;
#else
public static readonly bool IsLittleEndian = true;
#endif
#endif
// Converts a Boolean into an array of bytes with length one.
@@ -380,6 +382,22 @@ namespace System
throw new ArgumentOutOfRangeException(nameof(length), SR.Format(SR.ArgumentOutOfRange_LengthTooLarge, (int.MaxValue / 3)));
}
#if __MonoCS__ //use old impl for mcs
const string HexValues = "0123456789ABCDEF";
int chArrayLength = length * 3;
char[] chArray = new char[chArrayLength];
int i = 0;
int index = startIndex;
for (i = 0; i < chArrayLength; i += 3)
{
byte b = value[index++];
chArray[i] = HexValues[b >> 4];
chArray[i + 1] = HexValues[b & 0xF];
chArray[i + 2] = '-';
}
return new String(chArray, 0, chArray.Length - 1);
#else
return string.Create(length * 3 - 1, (value, startIndex, length), (dst, state) =>
{
const string HexValues = "0123456789ABCDEF";
@@ -401,6 +419,7 @@ namespace System
dst[j++] = HexValues[b & 0xF];
}
});
#endif
}
// Converts an array of bytes into a String.

View File

@@ -2,11 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
namespace System.ComponentModel
{
@@ -23,6 +20,9 @@ namespace System.ComponentModel
/// </devdoc>
private object _value;
// Delegate ad hoc created 'TypeDescriptor.ConvertFromInvariantString' reflection object cache
static object s_convertFromInvariantString;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='System.ComponentModel.DefaultValueAttribute'/> class, converting the
/// specified value to the
@@ -36,7 +36,24 @@ namespace System.ComponentModel
// load an otherwise normal class.
try
{
if (type.IsSubclassOf(typeof(Enum)))
#if __MonoCS__
// lazy init reflection objects
if (s_convertFromInvariantString == null)
{
Type typeDescriptorType = Type.GetType("System.ComponentModel.TypeDescriptor, System.ComponentModel.TypeConverter", throwOnError: false);
Volatile.Write(ref s_convertFromInvariantString, typeDescriptorType == null ? new object() : Delegate.CreateDelegate(typeof(Func<Type, string, object>), typeDescriptorType, "ConvertFromInvariantString", ignoreCase: false));
}
if (s_convertFromInvariantString is Func<Type, string, object> convertFromInvariantString)
{
_value = convertFromInvariantString(type, value);
}
#else
if (TryConvertFromInvariantString(type, value, out object convertedValue))
{
_value = convertedValue;
}
#endif
else if (type.IsSubclassOf(typeof(Enum)))
{
_value = Enum.Parse(type, value, true);
}
@@ -48,6 +65,29 @@ namespace System.ComponentModel
{
_value = Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
}
return;
#if !__MonoCS__
// Looking for ad hoc created TypeDescriptor.ConvertFromInvariantString(Type, string)
bool TryConvertFromInvariantString(Type typeToConvert, string stringValue, out object conversionResult)
{
conversionResult = null;
// lazy init reflection objects
if (s_convertFromInvariantString == null)
{
Type typeDescriptorType = Type.GetType("System.ComponentModel.TypeDescriptor, System.ComponentModel.TypeConverter", throwOnError: false);
Volatile.Write(ref s_convertFromInvariantString, typeDescriptorType == null ? new object() : Delegate.CreateDelegate(typeof(Func<Type, string, object>), typeDescriptorType, "ConvertFromInvariantString", ignoreCase: false));
}
if (!(s_convertFromInvariantString is Func<Type, string, object> convertFromInvariantString))
return false;
conversionResult = convertFromInvariantString(typeToConvert, stringValue);
return true;
}
#endif
}
catch
{

View File

@@ -26,6 +26,9 @@ using System.Runtime.Versioning;
namespace System
{
#if MONO
[Serializable]
#endif
[Obsolete("System.CurrentSystemTimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo.Local instead.")]
internal partial class CurrentSystemTimeZone : TimeZone
{

View File

@@ -52,7 +52,9 @@ namespace System
//
[StructLayout(LayoutKind.Auto)]
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public readonly partial struct DateTime : IComparable, IFormattable, IConvertible, IComparable<DateTime>, IEquatable<DateTime>, ISerializable, ISpanFormattable
{
// Number of 100ns ticks per time unit

View File

@@ -30,7 +30,9 @@ namespace System
[StructLayout(LayoutKind.Auto)]
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public struct DateTimeOffset : IComparable, IFormattable, IComparable<DateTimeOffset>, IEquatable<DateTimeOffset>, ISerializable, IDeserializationCallback, ISpanFormattable
{
// Constants

View File

@@ -461,7 +461,7 @@ namespace System
}
// This is a flag to indicate if we are format the dates using Hebrew calendar.
bool isHebrewCalendar = (cal.ID == CalendarId.HEBREW);
bool isHebrewCalendar = ((CalendarId)cal.ID == CalendarId.HEBREW);
// This is a flag to indicate if we are formating hour/minute/second only.
bool bTimeOnly = true;
@@ -657,7 +657,7 @@ namespace System
{
FormatDigits(result, year, tokenLen <= 2 ? tokenLen : 2);
}
else if (cal.ID == CalendarId.HEBREW)
else if ((CalendarId)cal.ID == CalendarId.HEBREW)
{
HebrewFormatDigits(result, year);
}
@@ -1085,7 +1085,7 @@ namespace System
// thrown when we try to get the Japanese year for Gregorian year 0001.
// Therefore, the workaround allows them to call ToString() for time of day from a DateTime by
// formatting as ISO 8601 format.
switch (dtfi.Calendar.ID)
switch ((CalendarId)dtfi.Calendar.ID)
{
case CalendarId.JAPAN:
case CalendarId.TAIWAN:

View File

@@ -1 +1 @@
edec75ac85bbf13b7caaceabd789b69a9d4aadf5
69bc2d672d3fa08d33dac7ed1dd7328169f5d16d

View File

@@ -1 +1 @@
970d1765bb32a4d94bf196a4494ce22b095e4f1c
840ef7d4d277306043f86562f9cd7df1ea63583b

View File

@@ -7,7 +7,9 @@ using System.Runtime.Serialization;
namespace System.IO
{
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public partial class FileLoadException : IOException
{
public FileLoadException()

View File

@@ -8,7 +8,9 @@ using System.Runtime.Serialization;
namespace System.IO
{
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class IOException : SystemException
{
public IOException()

View File

@@ -18,6 +18,9 @@ namespace System.IO
// from an unsigned byte array, or you can create an empty one. Empty
// memory streams are resizable, while ones created with a byte array provide
// a stream "view" of the data.
#if MONO
[Serializable]
#endif
public class MemoryStream : Stream
{
private byte[] _buffer; // Either allocated internally or externally.
@@ -32,6 +35,9 @@ namespace System.IO
private bool _exposable; // Whether the array can be returned to the user.
private bool _isOpen; // Is this stream open or closed?
#if MONO
[NonSerialized]
#endif
private Task<int> _lastReadTask; // The last successful task returned from ReadAsync
private const int MemStreamMaxLength = int.MaxValue;
@@ -165,10 +171,18 @@ namespace System.IO
// We want to expand the array up to Array.MaxByteArrayLength
// And we want to give the user the value that they asked for
#if MONO //in Mono we don't want to add additional fields to Array
if ((uint)(_capacity * 2) > Array_ReferenceSources.MaxByteArrayLength)
{
newCapacity = value > Array_ReferenceSources.MaxByteArrayLength ? value : Array_ReferenceSources.MaxByteArrayLength;
}
#else
if ((uint)(_capacity * 2) > Array.MaxByteArrayLength)
{
newCapacity = value > Array.MaxByteArrayLength ? value : Array.MaxByteArrayLength;
}
#endif
Capacity = newCapacity;
return true;
@@ -223,6 +237,14 @@ namespace System.IO
{
return _buffer;
}
#if MONO // Mono's ResourceWriter from referencesource still uses this method
internal void InternalGetOriginAndLength(out int origin, out int length)
{
if (!_isOpen) __Error.StreamIsClosed();
origin = _origin;
length = _length;
}
#endif
// PERF: True cursor position, we don't need _origin for direct access
internal int InternalGetPosition()

View File

@@ -1018,7 +1018,11 @@ namespace System.IO
CheckAsyncTaskInProgress();
#if !__MonoCS__
Task<int> task = ReadAsyncInternal(new Memory<char>(buffer, index, count), default).AsTask();
#else
Task<int> task = ReadAsyncInternal(new Memory<char>(buffer, index, count), default);
#endif
_asyncReadTask = task;
return task;
@@ -1044,10 +1048,18 @@ namespace System.IO
return new ValueTask<int>(Task.FromCanceled<int>(cancellationToken));
}
#if !__MonoCS__
return ReadAsyncInternal(buffer, cancellationToken);
#else
return new ValueTask<int>(ReadAsyncInternal(buffer, cancellationToken));
#endif
}
#if !__MonoCS__
internal override async ValueTask<int> ReadAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#else
internal override async Task<int> ReadAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#endif
{
if (_charPos == _charLen && (await ReadBufferAsync().ConfigureAwait(false)) == 0)
{
@@ -1276,7 +1288,11 @@ namespace System.IO
return new ValueTask<int>(Task.FromCanceled<int>(cancellationToken));
}
#if !__MonoCS__
ValueTask<int> vt = ReadBlockAsyncInternal(buffer, cancellationToken);
#else
ValueTask<int> vt = new ValueTask<int> (ReadBlockAsyncInternal(buffer, cancellationToken));
#endif
if (vt.IsCompletedSuccessfully)
{
return vt;
@@ -1419,5 +1435,15 @@ namespace System.IO
return 0;
}
}
#if MONO
//
// Used internally by our console, as it previously depended on Peek() being a
// routine that would not block.
//
internal bool DataAvailable ()
{
return _charPos < _charLen;
}
#endif
}
}

View File

@@ -249,7 +249,11 @@ namespace System.IO
throw new ArgumentException(SR.Argument_InvalidOffLen);
}
#if !__MonoCS__
return ReadAsyncInternal(new Memory<char>(buffer, index, count), default).AsTask();
#else
return ReadAsyncInternal(new Memory<char>(buffer, index, count), default);
#endif
}
public virtual ValueTask<int> ReadAsync(Memory<char> buffer, CancellationToken cancellationToken = default(CancellationToken)) =>
@@ -261,15 +265,29 @@ namespace System.IO
return t.Item1.Read(t.Item2.Span);
}, Tuple.Create(this, buffer), cancellationToken, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default));
#if !__MonoCS__
internal virtual ValueTask<int> ReadAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#else
internal virtual Task<int> ReadAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#endif
{
var tuple = new Tuple<TextReader, Memory<char>>(this, buffer);
#if !__MonoCS__
return new ValueTask<int>(Task<int>.Factory.StartNew(state =>
{
var t = (Tuple<TextReader, Memory<char>>)state;
return t.Item1.Read(t.Item2.Span);
},
tuple, cancellationToken, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default));
#else
return Task<int>.Factory.StartNew(state =>
{
var t = (Tuple<TextReader, Memory<char>>)state;
return t.Item1.Read(t.Item2.Span);
},
tuple, cancellationToken, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
#endif
}
public virtual Task<int> ReadBlockAsync(char[] buffer, int index, int count)
@@ -287,7 +305,11 @@ namespace System.IO
throw new ArgumentException(SR.Argument_InvalidOffLen);
}
#if !__MonoCS__
return ReadBlockAsyncInternal(new Memory<char>(buffer, index, count), default).AsTask();
#else
return ReadBlockAsyncInternal(new Memory<char>(buffer, index, count), default);
#endif
}
public virtual ValueTask<int> ReadBlockAsync(Memory<char> buffer, CancellationToken cancellationToken = default(CancellationToken)) =>
@@ -299,7 +321,11 @@ namespace System.IO
return t.Item1.ReadBlock(t.Item2.Span);
}, Tuple.Create(this, buffer), cancellationToken, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default));
#if !__MonoCS__
internal async ValueTask<int> ReadBlockAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#else
internal async Task<int> ReadBlockAsyncInternal(Memory<char> buffer, CancellationToken cancellationToken)
#endif
{
int n = 0, i;
do

View File

@@ -46,7 +46,11 @@ namespace System.IO
private long _position;
private long _offset;
private FileAccess _access;
#if MONO // Mono's HGlobalUnmanagedMemoryStream class uses this field
internal bool _isOpen;
#else
private bool _isOpen;
#endif
private Task<Int32> _lastReadTask; // The last successful task returned from ReadAsync
/// <summary>

View File

@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
namespace System
{
[Serializable]
#if MONO
#if MONO && MOBILE
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Core, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e")]
#else
[System.Runtime.CompilerServices.TypeForwardedFrom("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]

View File

@@ -644,6 +644,7 @@ namespace System
return decimal.Round(d, decimals, mode);
}
#if !MONO
[Intrinsic]
public static double Round(double a)
{
@@ -672,6 +673,10 @@ namespace System
return copysign(flrTempVal, a);
}
#else
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern double Round(double a);
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Round(double value, int digits)

View File

@@ -7,6 +7,9 @@ using System.Globalization;
namespace System.Reflection
{
#if MONO
[Serializable]
#endif
public abstract partial class ConstructorInfo : MethodBase
{
protected ConstructorInfo() { }
@@ -15,7 +18,11 @@ namespace System.Reflection
[DebuggerHidden]
[DebuggerStepThrough]
#if MONO
public object Invoke(object[] parameters) => Invoke(BindingFlags.CreateInstance, binder: null, parameters: parameters, culture: null);
#else
public object Invoke(object[] parameters) => Invoke(BindingFlags.Default, binder: null, parameters: parameters, culture: null);
#endif
public abstract object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture);
public override bool Equals(object obj) => base.Equals(obj);

View File

@@ -10,7 +10,7 @@ using EventRegistrationToken = System.Runtime.InteropServices.WindowsRuntime.Eve
namespace System.Reflection
{
public abstract class EventInfo : MemberInfo
public abstract partial class EventInfo : MemberInfo
{
protected EventInfo() { }
@@ -49,7 +49,12 @@ namespace System.Reflection
get
{
MethodInfo m = GetAddMethod(true);
#if MONO
ParameterInfo[] p = m.GetParametersInternal ();
#else
ParameterInfo[] p = m.GetParametersNoCopy();
#endif
Type del = typeof(Delegate);
for (int i = 0; i < p.Length; i++)
{
@@ -61,6 +66,7 @@ namespace System.Reflection
}
}
#if !MONO
[DebuggerHidden]
[DebuggerStepThrough]
public virtual void AddEventHandler(object target, Delegate handler)
@@ -77,6 +83,7 @@ namespace System.Reflection
addMethod.Invoke(target, new object[] { handler });
}
#endif
[DebuggerHidden]
[DebuggerStepThrough]

View File

@@ -7,7 +7,7 @@ using System.Runtime.Serialization;
namespace System.Reflection
{
public abstract class Module : ICustomAttributeProvider, ISerializable
public abstract partial class Module : ICustomAttributeProvider, ISerializable
{
protected Module() { }

View File

@@ -4,9 +4,16 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
#if MONO
using System.Runtime.InteropServices;
#endif
namespace System.Reflection
{
#if MONO
[Serializable]
[StructLayout (LayoutKind.Sequential)]
#endif
public class ParameterInfo : ICustomAttributeProvider, IObjectReference
{
protected ParameterInfo() { }

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