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 @@ -277,7 +277,7 @@ private static void MoveSpanToPosition(ref int currentSpanIndex, ref TextSpan? c
private void AddHighlight(int start, int length)
{
ArgumentOutOfRangeException.ThrowIfNegative(start);
ArgumentOutOfRangeException.ThrowIfGreaterThan(this.textBuilder.Length, start + length, nameof(length));
ArgumentOutOfRangeException.ThrowIfGreaterThan(start + length, this.textBuilder.Length, nameof(length));

this.highlightedSpans.Add(new TextSpan(start, length));
}
Expand Down Expand Up @@ -318,7 +318,7 @@ internal struct TextSpan
internal TextSpan(int start, int length)
{
ArgumentOutOfRangeException.ThrowIfNegative(start);
ArgumentOutOfRangeException.ThrowIfLessThan(1, length);
ArgumentOutOfRangeException.ThrowIfLessThan(length, 1);

this.start = start;
this.end = start + length - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ internal SensitiveString(int numberOfCharacters)
private unsafe void Copy(char* source, int offset, int charsToCopy)
{
ArgumentOutOfRangeException.ThrowIfNegative(offset);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(_string.Length, offset);
ArgumentOutOfRangeException.ThrowIfGreaterThan(_string.Length, offset + charsToCopy, nameof(charsToCopy));
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(offset, _string.Length);
ArgumentOutOfRangeException.ThrowIfGreaterThan(offset + charsToCopy, _string.Length, nameof(charsToCopy));

fixed (char* target = _string)
{
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/ProgressRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ internal static int GetPercentageComplete(DateTime startTime, TimeSpan expectedD
startTime.Kind == DateTimeKind.Utc,
"DateTime arithmetic should always be done in utc mode [to avoid problems when some operands are calculated right before and right after switching to /from a daylight saving time");

ArgumentOutOfRangeException.ThrowIfGreaterThan(now, startTime);
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(TimeSpan.Zero, expectedDuration);
ArgumentOutOfRangeException.ThrowIfGreaterThan(startTime, now);
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(expectedDuration, TimeSpan.Zero);

/*
* According to the spec of Checkpoint-Computer
Expand Down