mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix use of ThrowIf where the arguments were reversed (#20052)
This commit is contained in:
@@ -277,7 +277,7 @@ namespace Microsoft.Management.UI.Internal
|
||||
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));
|
||||
}
|
||||
@@ -318,7 +318,7 @@ namespace Microsoft.Management.UI.Internal
|
||||
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;
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ namespace Microsoft.PowerShell.Cim
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -379,8 +379,8 @@ namespace System.Management.Automation
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user