From 4b11dc566a5bbfa1378d6266525c281b028abcc8 Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Fri, 10 Feb 2017 20:35:12 +0900 Subject: Imported Upstream version 1.0.0.9910 --- src/mscorlib/src/System/ThrowHelper.cs | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'src/mscorlib/src/System/ThrowHelper.cs') diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs index a534dec818..1ed8317633 100644 --- a/src/mscorlib/src/System/ThrowHelper.cs +++ b/src/mscorlib/src/System/ThrowHelper.cs @@ -39,12 +39,10 @@ namespace System { using Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.Serialization; - using System.Diagnostics; using System.Diagnostics.Contracts; [Pure] internal static class ThrowHelper { -#if FEATURE_SPAN_OF_T internal static void ThrowArrayTypeMismatchException() { throw new ArrayTypeMismatchException(); } @@ -72,7 +70,6 @@ namespace System { internal static void ThrowNotSupportedException_CannotCallGetHashCodeOnSpan() { throw new NotSupportedException(Environment.GetResourceString("NotSupported_CannotCallGetHashCodeOnSpan")); } -#endif internal static void ThrowArgumentOutOfRange_IndexException() { throw GetArgumentOutOfRangeException(ExceptionArgument.index, @@ -127,8 +124,12 @@ namespace System { throw GetArgumentException(resource, argument); } + private static ArgumentNullException GetArgumentNullException(ExceptionArgument argument) { + return new ArgumentNullException(GetArgumentName(argument)); + } + internal static void ThrowArgumentNullException(ExceptionArgument argument) { - throw new ArgumentNullException(GetArgumentName(argument)); + throw GetArgumentNullException(argument); } internal static void ThrowArgumentNullException(ExceptionResource resource) { @@ -211,11 +212,27 @@ namespace System { throw GetInvalidOperationException(ExceptionResource.InvalidOperation_EnumOpCantHappen); } + internal static void ThrowArraySegmentCtorValidationFailedExceptions(Array array, int offset, int count) { + throw GetArraySegmentCtorValidationFailedException(array, offset, count); + } + + private static Exception GetArraySegmentCtorValidationFailedException(Array array, int offset, int count) { + if (array == null) + return GetArgumentNullException(ExceptionArgument.array); + if (offset < 0) + return GetArgumentOutOfRangeException(ExceptionArgument.offset, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); + if (count < 0) + return GetArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); + + Debug.Assert(array.Length - offset < count); + return GetArgumentException(ExceptionResource.Argument_InvalidOffLen); + } + private static ArgumentException GetArgumentException(ExceptionResource resource) { return new ArgumentException(GetResourceString(resource)); } - private static InvalidOperationException GetInvalidOperationException(ExceptionResource resource) { + internal static InvalidOperationException GetInvalidOperationException(ExceptionResource resource) { return new InvalidOperationException(GetResourceString(resource)); } @@ -227,7 +244,7 @@ namespace System { return new ArgumentException(Environment.GetResourceString("Arg_WrongType", value, targetType), nameof(value)); } - private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) { + internal static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) { return new ArgumentOutOfRangeException(GetArgumentName(argument), GetResourceString(resource)); } @@ -363,7 +380,8 @@ namespace System { updateValueFactory, concurrencyLevel, text, - + callBack, + type, } // @@ -453,7 +471,6 @@ namespace System { Task_ContinueWith_NotOnAnything, Task_ContinueWith_ESandLR, TaskT_TransitionToFinal_AlreadyCompleted, - TaskT_ctor_SelfReplicating, TaskCompletionSourceT_TrySetException_NullException, TaskCompletionSourceT_TrySetException_NoExceptions, InvalidOperation_WrongAsyncResultOrEndCalledMultiple, @@ -468,7 +485,8 @@ namespace System { ConcurrentDictionary_ArrayNotLargeEnough, ConcurrentDictionary_ArrayIncorrectType, ConcurrentCollection_SyncRoot_NotSupported, - + ArgumentOutOfRange_Enum, + InvalidOperation_HandleIsNotInitialized, } } -- cgit v1.2.3