diff options
Diffstat (limited to 'mcs/class/referencesource/mscorlib/system/throwhelper.cs')
-rw-r--r-- | mcs/class/referencesource/mscorlib/system/throwhelper.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/mcs/class/referencesource/mscorlib/system/throwhelper.cs b/mcs/class/referencesource/mscorlib/system/throwhelper.cs index 95a5bb12487..523f467e8ff 100644 --- a/mcs/class/referencesource/mscorlib/system/throwhelper.cs +++ b/mcs/class/referencesource/mscorlib/system/throwhelper.cs @@ -49,6 +49,7 @@ namespace System { using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Diagnostics.Contracts; + using System.Collections.Generic; [Pure] internal static partial class ThrowHelper { @@ -121,6 +122,61 @@ 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 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>. |