Added ArgumentOutOfRangeException exception in RemoveRange if the count is less than 0
authorAndrew Hoefling <andrew@hoeflingsoftware.com>
Tue, 5 Mar 2019 23:14:01 +0000 (18:14 -0500)
committerSantiago Fernandez Madero <safern@microsoft.com>
Fri, 8 Mar 2019 19:20:58 +0000 (11:20 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/5f9e81d1577345c4f3fc4df475b8f3e7f672f0ce

src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs

index 3fb2693..4099682 100644 (file)
@@ -207,6 +207,11 @@ namespace System.Collections.ObjectModel
                 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert);
             }
 
+            if (count < 0)
+            {
+                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_ListInsert);
+            }
+
             int length = items.Count;
             if (index < items.Count - count)
             {