summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Hoefling <andrew@hoeflingsoftware.com>2019-03-21 22:23:53 -0400
committerStephen Toub <stoub@microsoft.com>2019-03-21 22:23:53 -0400
commit01adae878ded6fe51f6def1370255d816ab42d78 (patch)
tree02fc0ad76ee843ae4b3355d3daada8838552b7c5
parentbadf173369fa09d33893017ec201cbeb39da3b9c (diff)
downloadcoreclr-01adae878ded6fe51f6def1370255d816ab42d78.tar.gz
coreclr-01adae878ded6fe51f6def1370255d816ab42d78.tar.bz2
coreclr-01adae878ded6fe51f6def1370255d816ab42d78.zip
Updated Exception Handling for Collection<T> (#23290)
* Updated Argument Helper param from list->collection since the parameter name is collection * Updated exception message to use an out of range exception that doesn't explicitly reference a list * Simplified if statements that verify if the index is out of range * Updated if logic to be simplified using (uint) * Updated exception handling to throw ThrowHelper.ThrowArgumentOutOfRange_IndexException() when the ExceptionArgument was 'Index'
-rw-r--r--src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
index 5d6c9c9757..4898c0cae2 100644
--- a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
+++ b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs
@@ -49,7 +49,7 @@ namespace System.Collections.ObjectModel
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
- if (index < 0 || index >= items.Count)
+ if ((uint)index >= (uint)items.Count)
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
@@ -108,9 +108,9 @@ namespace System.Collections.ObjectModel
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
- if (index < 0 || index > items.Count)
+ if ((uint)index > (uint)items.Count)
{
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
+ ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
InsertItem(index, item);
@@ -125,12 +125,12 @@ namespace System.Collections.ObjectModel
if (collection == null)
{
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list);
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
}
if ((uint)index > (uint)items.Count)
{
- ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
+ ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}
InsertItemsRange(index, collection);
@@ -198,7 +198,7 @@ namespace System.Collections.ObjectModel
if (collection == null)
{
- ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list);
+ ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
}
ReplaceItemsRange(index, count, collection);
@@ -211,7 +211,7 @@ namespace System.Collections.ObjectModel
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
}
- if (index < 0 || index >= items.Count)
+ if ((uint)index >= (uint)items.Count)
{
ThrowHelper.ThrowArgumentOutOfRange_IndexException();
}