Skip to content

Commit

Permalink
Use ThrowHelper in Queue<T> (dotnet#103424)
Browse files Browse the repository at this point in the history
* Use ThrowHelper in Queue<T>

* Don't use ThrowHelper in ThrowHelper

* Remove empty line
  • Loading branch information
lilinus authored Jun 14, 2024
1 parent d901213 commit 069c156
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ public void CopyTo(T[] array, int arrayIndex)

if (arrayIndex < 0 || arrayIndex > array.Length)
{
throw new ArgumentOutOfRangeException(nameof(arrayIndex), arrayIndex, SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.arrayIndex, ExceptionResource.ArgumentOutOfRange_IndexMustBeLessOrEqual);
}

if (array.Length - arrayIndex < _size)
{
throw new ArgumentException(SR.Argument_InvalidOffLen);
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
}

int numToCopy = _size;
Expand All @@ -124,23 +124,23 @@ void ICollection.CopyTo(Array array, int index)

if (array.Rank != 1)
{
throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported, ExceptionArgument.array);
}

if (array.GetLowerBound(0) != 0)
{
throw new ArgumentException(SR.Arg_NonZeroLowerBound, nameof(array));
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_NonZeroLowerBound, ExceptionArgument.array);
}

int arrayLen = array.Length;
if (index < 0 || index > arrayLen)
{
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_IndexMustBeLessOrEqual);
ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException();
}

if (arrayLen - index < _size)
{
throw new ArgumentException(SR.Argument_InvalidOffLen);
ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen);
}

int numToCopy = _size;
Expand All @@ -159,7 +159,7 @@ void ICollection.CopyTo(Array array, int index)
}
catch (ArrayTypeMismatchException)
{
throw new ArgumentException(SR.Argument_IncompatibleArrayType, nameof(array));
ThrowHelper.ThrowArgumentException_Argument_IncompatibleArrayType();
}
}

Expand Down Expand Up @@ -442,7 +442,7 @@ public void Dispose()

public bool MoveNext()
{
if (_version != _q._version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
if (_version != _q._version) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();

if (_index == -2)
return false;
Expand Down Expand Up @@ -503,7 +503,7 @@ private void ThrowEnumerationNotStartedOrEnded()

void IEnumerator.Reset()
{
if (_version != _q._version) throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
if (_version != _q._version) ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion();
_index = -1;
_currentElement = default;
}
Expand Down

0 comments on commit 069c156

Please sign in to comment.