Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,7 @@ internal void Compress(int bitCount, int[] input, int startInputIndex, DeltaDelt
{
throw new ArgumentNullException(StrokeCollectionSerializer.ISFDebugMessage("input or compressed data was null in Compress"));
}
if (bitCount < 0)
{
throw new ArgumentOutOfRangeException("bitCount");
}
ArgumentOutOfRangeException.ThrowIfNegative(bitCount);

if (bitCount == 0)
{
Expand Down Expand Up @@ -428,14 +425,8 @@ internal void Compress(int bitCount, BitStreamReader reader, GorillaEncodingType
{
throw new ArgumentNullException(StrokeCollectionSerializer.ISFDebugMessage("reader or compressedData was null in compress"));
}
if (bitCount < 0)
{
throw new ArgumentOutOfRangeException("bitCount");
}
if (unitsToEncode < 0)
{
throw new ArgumentOutOfRangeException("unitsToEncode");
}
ArgumentOutOfRangeException.ThrowIfNegative(bitCount);
ArgumentOutOfRangeException.ThrowIfNegative(unitsToEncode);

if (bitCount == 0)
{
Expand Down Expand Up @@ -518,20 +509,11 @@ private int GetDataFromReader(BitStreamReader reader, GorillaEncodingType type)
internal uint Uncompress(int bitCount, byte[] input, int inputIndex, DeltaDelta dtxf, int[] outputBuffer, int outputBufferIndex)
{
ArgumentNullException.ThrowIfNull(input);
if (inputIndex >= input.Length)
{
throw new ArgumentOutOfRangeException("inputIndex");
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(inputIndex, input.Length);
ArgumentNullException.ThrowIfNull(outputBuffer);
if (outputBufferIndex >= outputBuffer.Length)
{
throw new ArgumentOutOfRangeException("outputBufferIndex");
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(outputBufferIndex, outputBuffer.Length);

if (bitCount < 0)
{
throw new ArgumentOutOfRangeException("bitCount");
}
ArgumentOutOfRangeException.ThrowIfNegative(bitCount);

// Adjust bit count if 0 passed in
if (bitCount == 0)
Expand Down Expand Up @@ -603,14 +585,8 @@ internal uint Uncompress(int bitCount, byte[] input, int inputIndex, DeltaDelta
internal byte[] Uncompress(int bitCount, BitStreamReader reader, GorillaEncodingType encodingType, int unitsToDecode)
{
ArgumentNullException.ThrowIfNull(reader);
if (bitCount < 0)
{
throw new ArgumentOutOfRangeException("bitCount");
}
if (unitsToDecode < 0)
{
throw new ArgumentOutOfRangeException("unitsToDecode");
}
ArgumentOutOfRangeException.ThrowIfNegative(bitCount);
ArgumentOutOfRangeException.ThrowIfNegative(unitsToDecode);

int bitsToWrite = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ internal uint Decode(byte[] input, int inputIndex, ref uint data)
internal uint SignDecode(byte[] input, int inputIndex, ref int data)
{
Debug.Assert(input != null); //already validated at the AlgoModule level
if (inputIndex >= input.Length)
{
throw new ArgumentOutOfRangeException("inputIndex");
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(inputIndex, input.Length);
uint xfData = 0;
uint cb = Decode(input, inputIndex, ref xfData);
data = (0 != (0x01 & xfData)) ? -(int)(xfData >> 1) : (int)(xfData >> 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ public void CopyTo(T[] array, int arrayIndex)
"array");
}

if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);

if (arrayIndex >= array.Length)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ internal FontFace CreateFontFace(Uri filePathUri, uint faceIndex, FontSimulation
&hr
))
{
if (faceIndex >= numberOfFaces)
{
throw new ArgumentOutOfRangeException("faceIndex");
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(faceIndex, numberOfFaces);

byte dwriteFontSimulationsFlags = DWriteTypeConverter.Convert(fontSimulationFlags);
IDWriteFontFace* dwriteFontFace = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ public void CopyTo(double[] array, int arrayIndex)
"array");
}

if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);

if (arrayIndex >= array.Length)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ public void CopyTo(Point[] array, int arrayIndex)
"array");
}

if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);

if (arrayIndex >= array.Length)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public void CopyTo(KeyValuePair<int, CharacterMetrics>[] array, int index)
{
ArgumentNullException.ThrowIfNull(array);

if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);

if (index >= array.Length)
throw new ArgumentException(SR.Format(SR.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength, "index", "array"));
Expand Down Expand Up @@ -191,8 +190,7 @@ void SC.ICollection.CopyTo(Array array, int index)
{
ArgumentNullException.ThrowIfNull(array);

if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);

if (index >= array.Length)
throw new ArgumentException(SR.Format(SR.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength, "index", "array"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public void CopyTo(KeyValuePair<XmlLanguage, string>[] array, int index)
{
ArgumentNullException.ThrowIfNull(array);

if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);

if (index >= array.Length)
throw new ArgumentException(SR.Format(SR.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength, "index", "array"));
Expand Down Expand Up @@ -157,8 +156,7 @@ void SC.ICollection.CopyTo(Array array, int index)
{
ArgumentNullException.ThrowIfNull(array);

if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);

if (index >= array.Length)
throw new ArgumentException(SR.Format(SR.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength, "index", "array"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,18 +794,9 @@ public void RemoveRange(int index, int count)
VerifyAPIReadWrite();

// Do we really need this extra check index >= _size.
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
if (count < 0)
{
throw new ArgumentOutOfRangeException(nameof(count));
}
if (_size - index < count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
ArgumentOutOfRangeException.ThrowIfNegative(index);
ArgumentOutOfRangeException.ThrowIfNegative(count);
ArgumentOutOfRangeException.ThrowIfGreaterThan(count, _size - index);

if (count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ public override bool PassesFilter(object item)
public override object GetItemAt(int index)
{
// only check lower bound because Count could be expensive
if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);
return EnumerableWrapper[index];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ public override int IndexOf(object item)
/// </exception>
public override object GetItemAt(int index)
{
if (index < 0)
throw new ArgumentOutOfRangeException("index");
ArgumentOutOfRangeException.ThrowIfNegative(index);

int positionX, positionY;
object item = GetItem(index, out positionX, out positionY);
Expand Down Expand Up @@ -313,8 +312,7 @@ public override bool MoveCurrentToPrevious()
/// </exception>
public override bool MoveCurrentToPosition(int position)
{
if (position < -1)
throw new ArgumentOutOfRangeException("position");
ArgumentOutOfRangeException.ThrowIfLessThan(position, -1);

int newPositionX, newPositionY;
object item = GetItem(position, out newPositionX, out newPositionY);
Expand All @@ -325,10 +323,7 @@ public override bool MoveCurrentToPosition(int position)
{
item = null;
// check upper-bound only after GetItem() to avoid unnecessary pre-counting
if (position > Count)
{
throw new ArgumentOutOfRangeException("position");
}
ArgumentOutOfRangeException.ThrowIfGreaterThan(position, Count);
}

if (OKToChangeCurrent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ internal object this[int index]
return value;
}

if (index < 0)
{
#pragma warning suppress 6503 // "Property get methods should not throw exceptions."
throw new ArgumentOutOfRangeException("index"); // validating the index argument
}
ArgumentOutOfRangeException.ThrowIfNegative(index);

int moveBy = (index - _cachedIndex);
if (moveBy < 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ public bool Contains(T item)
public void CopyTo(T[] array, int arrayIndex)
{
ArgumentNullException.ThrowIfNull(array);
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException("arrayIndex");
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);
if (arrayIndex + Count > array.Length)
throw new ArgumentException(SR.Argument_InvalidOffLen);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ public bool Contains(KeyValuePair<TKey, TValue> item)

public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);
ArgumentNullException.ThrowIfNull(array);

int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ public bool Contains(T item)

public void CopyTo(T[] array, int arrayIndex)
{
if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);
ArgumentNullException.ThrowIfNull(array);

int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public int Count

private T Indexer_Get(int index)
{
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index));
ArgumentOutOfRangeException.ThrowIfNegative(index);

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,7 @@ public void SetScale(double scale)
{
if (!DoubleUtil.AreClose(scale, Scale))
{
if (scale <= 0.0)
{
throw new ArgumentOutOfRangeException("scale");
}
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(scale, 0.0);

if (!Helper.IsDoubleValid(scale))
{
Expand All @@ -448,10 +445,7 @@ public void SetScale(double scale)
/// <param name="columns"></param>
public void SetColumns(int columns)
{
if (columns < 1)
{
throw new ArgumentOutOfRangeException("columns");
}
ArgumentOutOfRangeException.ThrowIfLessThan(columns, 1);

//Perf Tracing - Mark Layout Change Start
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXPS, EventTrace.Event.WClientDRXLayoutBegin);
Expand All @@ -465,10 +459,7 @@ public void SetColumns(int columns)
/// <param name="columns"></param>
public void FitColumns(int columns)
{
if (columns < 1)
{
throw new ArgumentOutOfRangeException("columns");
}
ArgumentOutOfRangeException.ThrowIfLessThan(columns, 1);

//Perf Tracing - Mark Layout Change Start
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXPS, EventTrace.Event.WClientDRXLayoutBegin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,8 @@ private object GetPageCompletedDelegate(object parameter)
/// <param name="count"></param>
private void ValidatePaginationArgs(int start, int count)
{
if (start < 0)
{
throw new ArgumentOutOfRangeException("start");
}

if (count <= 0)
{
throw new ArgumentOutOfRangeException("count");
}
ArgumentOutOfRangeException.ThrowIfNegative(start);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(count);
}

/// <summary>
Expand Down Expand Up @@ -762,15 +755,8 @@ private void FirePageCacheChangedEvent(List<PageCacheChange> changes)
private PageCacheChange AddRange(int start, int count)
{
//Make sure we're in range.
if (start < 0)
{
throw new ArgumentOutOfRangeException("start");
}

if (count < 1)
{
throw new ArgumentOutOfRangeException("count");
}
ArgumentOutOfRangeException.ThrowIfNegative(start);
ArgumentOutOfRangeException.ThrowIfLessThan(count, 1);

Invariant.Assert(_defaultPageSize != Size.Empty, "Default Page Size is Empty.");

Expand Down Expand Up @@ -833,10 +819,7 @@ private PageCacheChange UpdateEntry(int index, PageCacheEntry newEntry)
private PageCacheChange DirtyRange(int start, int count)
{
//Make sure we're in range.
if (start >= _cache.Count)
{
throw new ArgumentOutOfRangeException("start");
}
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(start, _cache.Count);

if (start + count > _cache.Count || count < 1)
{
Expand Down
Loading