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

@@ -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
}