-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions
Milestone
Description
Description
ConcurrentStack<T>.PushRange(T[])
throws an ArgumentOutOfRangeException when T[]
is an empty array. The exception message is 'The startIndex argument must be greater than or equal to zero.'.
- This behavior is not documented
- It should do nothing instead of throwing an exception, like
List<T>.AddRange(IEnumerable<T>)
does
Reproduction Steps
new ConcurrentStack<int>().PushRange(Array.Empty<int>());
Expected behavior
It should not throw an exception.
Actual behavior
It throws an ArgumentOutOfRangeException: 'The startIndex argument must be greater than or equal to zero.'
Regression?
No response
Known Workarounds
Check the array for Length > 0
before calling ConcurrentStack<T>.PushRange(T[])
.
Configuration
.NET 6.0.100
Other information
No response
GSPP
Metadata
Metadata
Assignees
Labels
area-System.CollectionsenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions