mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Revert a few change to not use 'ArgumentNullException.ThrowIfNull' (#19151)
This commit is contained in:
@@ -1733,11 +1733,6 @@ namespace System.Management.Automation.Internal
|
||||
/// </summary>
|
||||
internal static class Requires
|
||||
{
|
||||
internal static void NotNull(object value, string paramName)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value, paramName);
|
||||
}
|
||||
|
||||
internal static void NotNullOrEmpty(string value, string paramName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
@@ -1748,9 +1743,7 @@ namespace System.Management.Automation.Internal
|
||||
|
||||
internal static void NotNullOrEmpty(ICollection value, string paramName)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value, paramName);
|
||||
|
||||
if (value.Count == 0)
|
||||
if (value is null || value.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
|
||||
@@ -1138,9 +1138,10 @@ namespace System.Management.Automation
|
||||
/// <param name="command">The command you're calling this from (i.e. instance of PSCmdlet or value of $PSCmdlet variable).</param>
|
||||
public void Begin(InternalCommand command)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
ArgumentNullException.ThrowIfNull(command.MyInvocation, nameof(command));
|
||||
if (command is null || command.MyInvocation is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(command));
|
||||
}
|
||||
|
||||
Begin(command.MyInvocation.ExpectingInput, command.commandRuntime);
|
||||
}
|
||||
|
||||
@@ -530,10 +530,11 @@ namespace System.Management.Automation.Language
|
||||
// Get the value of the index and value and call the compiler
|
||||
var index = indexExpressionAst.Index.Accept(this);
|
||||
var target = indexExpressionAst.Target.Accept(this);
|
||||
|
||||
ArgumentNullException.ThrowIfNull(index, nameof(indexExpressionAst));
|
||||
|
||||
ArgumentNullException.ThrowIfNull(target, nameof(indexExpressionAst));
|
||||
if (index is null || target is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(indexExpressionAst));
|
||||
}
|
||||
|
||||
return GetIndexedValueFromTarget(target, index);
|
||||
}
|
||||
|
||||
@@ -7969,6 +7969,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
|
||||
using (SafeHandle handle = WinOpenReparsePoint(path, FileAccess.Write))
|
||||
{
|
||||
byte[] mountPointBytes = Encoding.Unicode.GetBytes(NonInterpretedPathPrefix + Path.GetFullPath(target));
|
||||
|
||||
@@ -129,9 +129,7 @@ namespace System.Management.Automation
|
||||
/// <param name="errors">The collection of error messages.</param>
|
||||
public ParseException(ParseError[] errors)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(errors);
|
||||
|
||||
if (errors.Length == 0)
|
||||
if (errors is null || errors.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(errors));
|
||||
}
|
||||
|
||||
@@ -108,9 +108,7 @@ namespace System.Management.Automation.PerformanceData
|
||||
CounterSetInstType = counterSetInstType;
|
||||
CounterSetName = counterSetName;
|
||||
|
||||
ArgumentNullException.ThrowIfNull(counterInfoArray);
|
||||
|
||||
if (counterInfoArray.Length == 0)
|
||||
if (counterInfoArray is null || counterInfoArray.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(counterInfoArray));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user