Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@@ -472,7 +472,18 @@ namespace System {
// If we ever run on big endian machines, produce two versions where endianness is specified.
Contract.Assert(IsLittleEndian, "This method is implemented assuming little endian with an ambiguous spec.");
return *((double*)&value);
}
}
#if MONO
// Converts a Span into an int
public static int ToInt32(ReadOnlySpan<byte> value)
{
if (value.Length < sizeof(int))
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.value);
return Unsafe.ReadUnaligned<int>(ref value.DangerousGetPinnableReference());
}
#endif
}

View File

@@ -178,7 +178,7 @@ namespace System.Collections.Generic {
get {
// Following trick can reduce the range check by one
if ((uint) index >= (uint)_size) {
ThrowHelper.ThrowArgumentOutOfRangeException();
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
Contract.EndContractBlock();
#if MONO
@@ -190,7 +190,7 @@ namespace System.Collections.Generic {
set {
if ((uint) index >= (uint)_size) {
ThrowHelper.ThrowArgumentOutOfRangeException();
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
Contract.EndContractBlock();
_items[index] = value;
@@ -883,7 +883,7 @@ namespace System.Collections.Generic {
//
public void RemoveAt(int index) {
if ((uint)index >= (uint)_size) {
ThrowHelper.ThrowArgumentOutOfRangeException();
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
Contract.EndContractBlock();
_size--;

View File

@@ -388,5 +388,11 @@ namespace System {
/// }
///#endif // #if GENERICS_WORK
#if MONO
public bool TryFormat(Span<char> destination, out int charsWritten, System.ReadOnlySpan<char> format = default, System.IFormatProvider provider = null)
{
throw new NotImplementedException ();
}
#endif
}
}

View File

@@ -23,7 +23,10 @@ namespace System.Runtime.CompilerServices {
[Serializable]
public sealed class RuntimeWrappedException : Exception
{
private RuntimeWrappedException(Object thrownObject)
#if MONO
public
#endif
RuntimeWrappedException(Object thrownObject)
: base(Environment.GetResourceString("RuntimeWrappedException")) {
SetErrorCode(System.__HResults.COR_E_RUNTIMEWRAPPED);
m_wrappedException = thrownObject;

View File

@@ -1359,6 +1359,16 @@ namespace System.Text
return String.CreateStringFromEncoding(bytes, byteCount, this);
}
#if MONO
public unsafe string GetString(ReadOnlySpan<byte> bytes)
{
fixed (byte* bytesPtr = &bytes.DangerousGetPinnableReference())
{
return GetString(bytesPtr, bytes.Length);
}
}
#endif
// Returns the code page identifier of this encoding. The returned value is
// an integer between 0 and 65535 if the encoding has a code page
// identifier, or -1 if the encoding does not represent a code page.

View File

@@ -49,12 +49,15 @@ namespace System {
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Diagnostics.Contracts;
using System.Collections.Generic;
[Pure]
internal static partial class ThrowHelper {
#if !MONO
internal static void ThrowArgumentOutOfRangeException() {
ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index);
}
#endif
internal static void ThrowWrongKeyTypeArgumentException(object key, Type targetType) {
throw new ArgumentException(Environment.GetResourceString("Arg_WrongType", key, targetType), "key");
@@ -121,6 +124,68 @@ namespace System {
throw new ObjectDisposedException(objectName, Environment.GetResourceString(GetResourceName(resource)));
}
#if MONO
internal static void ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
{
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
}
internal static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
{
throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
}
internal static void ThrowInvalidOperationException_InvalidOperation_EnumNotStarted()
{
throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted);
}
internal static void ThrowInvalidOperationException_InvalidOperation_EnumEnded()
{
throw new InvalidOperationException(SR.InvalidOperation_EnumEnded);
}
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, string resource)
{
return new ArgumentOutOfRangeException(GetArgumentName(argument), resource);
}
internal static void ThrowArgumentOutOfRange_IndexException()
{
throw GetArgumentOutOfRangeException(ExceptionArgument.index,
SR.ArgumentOutOfRange_Index);
}
internal static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
{
throw GetArgumentOutOfRangeException(ExceptionArgument.index,
SR.ArgumentOutOfRange_NeedNonNegNum);
}
internal static void ThrowArgumentException_Argument_InvalidArrayType()
{
throw new ArgumentException(SR.Argument_InvalidArrayType);
}
private static ArgumentException GetAddingDuplicateWithKeyArgumentException(object key)
{
return new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
}
internal static void ThrowAddingDuplicateWithKeyArgumentException(object key)
{
throw GetAddingDuplicateWithKeyArgumentException(key);
}
private static KeyNotFoundException GetKeyNotFoundException(object key)
{
throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString()));
}
internal static void ThrowKeyNotFoundException(object key)
{
throw GetKeyNotFoundException(key);
}
#endif
// Allow nulls for reference types and Nullable<U>, but not for value types.
internal static void IfNullAndNullsAreIllegalThenThrow<T>(object value, ExceptionArgument argName) {
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
@@ -475,6 +540,9 @@ namespace System {
pointer,
ownedMemory,
text,
length,
comparer,
comparable
#endif
}

View File

@@ -1894,6 +1894,8 @@ namespace System {
#if MONO
public virtual bool IsSZArray { get { throw new NotImplementedException (); } }
public virtual bool IsCollectible => true;
#endif
}