InsertItemsRange API now checks if the underlying items.IsReadOnly first then collect...
authorAndrew Hoefling <andrew@hoeflingsoftware.com>
Wed, 6 Mar 2019 17:57:09 +0000 (12:57 -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/44e05888b328699d3a0ca4b76544d7c357b49b47

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

index 8aa387b..f6d7f98 100644 (file)
@@ -172,14 +172,14 @@ namespace System.Collections.ObjectModel
 
         protected virtual void InsertItemsRange(int index, IEnumerable<T> collection)
         {
-            if (collection == null)
+            if (items.IsReadOnly)
             {
-                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list);
+                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
             }
 
-            if (items.IsReadOnly)
+            if (collection == null)
             {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.list);
             }
 
             if ((uint)index > (uint)items.Count)