diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs index fb6b638b9df..f40db9c8155 100644 --- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs +++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs @@ -84,7 +84,7 @@ protected TSession[] Session { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(); } _session = value; diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs index 23aa621266d..cf7d0d5213e 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs @@ -1090,7 +1090,7 @@ public class NewPSDriveCommand : CoreCommandWithCredentialsBase public string Name { get => _name; - set => _name = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value)); + set => _name = value ?? throw PSTraceSource.NewArgumentNullException(); } /// @@ -1100,7 +1100,7 @@ public string Name public string PSProvider { get => _provider; - set => _provider = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value)); + set => _provider = value ?? throw PSTraceSource.NewArgumentNullException(); } /// @@ -1112,7 +1112,7 @@ public string PSProvider public string Root { get => _root; - set => _root = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value)); + set => _root = value ?? throw PSTraceSource.NewArgumentNullException(); } /// @@ -1122,7 +1122,7 @@ public string Root public string Description { get => _description; - set => _description = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value)); + set => _description = value ?? throw PSTraceSource.NewArgumentNullException(); } /// diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs index 6271e6f57b6..291361bf724 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs @@ -1285,7 +1285,7 @@ public string[] Include { // null check is not needed (because of ValidateNotNullOrEmpty), // but we have to include it to silence OACR - _includeStrings = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value)); + _includeStrings = value ?? throw PSTraceSource.NewArgumentNullException(); _include = new WildcardPattern[_includeStrings.Length]; for (int i = 0; i < _includeStrings.Length; i++) @@ -1312,7 +1312,7 @@ public string[] Exclude { // null check is not needed (because of ValidateNotNullOrEmpty), // but we have to include it to silence OACR - _excludeStrings = value ?? throw PSTraceSource.NewArgumentNullException("value"); + _excludeStrings = value ?? throw PSTraceSource.NewArgumentNullException(); _exclude = new WildcardPattern[_excludeStrings.Length]; for (int i = 0; i < _excludeStrings.Length; i++) @@ -1384,7 +1384,7 @@ public Encoding Encoding { // null check is not needed (because of ValidateNotNullOrEmpty), // but we have to include it to silence OACR - _context = value ?? throw PSTraceSource.NewArgumentNullException("value"); + _context = value ?? throw PSTraceSource.NewArgumentNullException(); if (_context.Length == 1) { diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs index bca63be834b..9a2f4ad2238 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs @@ -831,7 +831,7 @@ public override string WindowTitle } else { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } } } diff --git a/src/System.Management.Automation/engine/GetCommandCommand.cs b/src/System.Management.Automation/engine/GetCommandCommand.cs index 50c8bd965da..be99919332f 100644 --- a/src/System.Management.Automation/engine/GetCommandCommand.cs +++ b/src/System.Management.Automation/engine/GetCommandCommand.cs @@ -289,7 +289,7 @@ public string[] ParameterName { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(); } _parameterNames = value; @@ -319,7 +319,7 @@ public PSTypeName[] ParameterType { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(); } // if '...CimInstance#Win32_Process' is specified, then exclude '...CimInstance' diff --git a/src/System.Management.Automation/engine/PseudoParameters.cs b/src/System.Management.Automation/engine/PseudoParameters.cs index 97b1d60e8ad..1f05ec6ce28 100644 --- a/src/System.Management.Automation/engine/PseudoParameters.cs +++ b/src/System.Management.Automation/engine/PseudoParameters.cs @@ -116,7 +116,7 @@ public Type ParameterType { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } _parameterType = value; diff --git a/src/System.Management.Automation/engine/hostifaces/ChoiceDescription.cs b/src/System.Management.Automation/engine/hostifaces/ChoiceDescription.cs index 1b55485afdc..9c44ed88d60 100644 --- a/src/System.Management.Automation/engine/hostifaces/ChoiceDescription.cs +++ b/src/System.Management.Automation/engine/hostifaces/ChoiceDescription.cs @@ -126,7 +126,7 @@ class ChoiceDescription { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } this.helpMessage = value; diff --git a/src/System.Management.Automation/engine/hostifaces/FieldDescription.cs b/src/System.Management.Automation/engine/hostifaces/FieldDescription.cs index 75987cc463a..57e60c35295 100644 --- a/src/System.Management.Automation/engine/hostifaces/FieldDescription.cs +++ b/src/System.Management.Automation/engine/hostifaces/FieldDescription.cs @@ -198,7 +198,7 @@ public string Name { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } label = value; @@ -230,7 +230,7 @@ public string Name { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } helpMessage = value; diff --git a/src/System.Management.Automation/engine/lang/scriptblock.cs b/src/System.Management.Automation/engine/lang/scriptblock.cs index 0c6c1d5dff1..f6ffd01bf35 100644 --- a/src/System.Management.Automation/engine/lang/scriptblock.cs +++ b/src/System.Management.Automation/engine/lang/scriptblock.cs @@ -716,7 +716,7 @@ internal SessionState SessionState { if (value == null) { - throw PSTraceSource.NewArgumentNullException(nameof(value)); + throw PSTraceSource.NewArgumentNullException(); } SessionStateInternal = value.Internal; diff --git a/src/System.Management.Automation/engine/remoting/client/Job2.cs b/src/System.Management.Automation/engine/remoting/client/Job2.cs index b89c9433697..60620c36c78 100644 --- a/src/System.Management.Automation/engine/remoting/client/Job2.cs +++ b/src/System.Management.Automation/engine/remoting/client/Job2.cs @@ -105,7 +105,7 @@ public List StartParameters { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } lock (_syncobject) diff --git a/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs b/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs index 0ffcab271bc..6ba7c9ed6f7 100644 --- a/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs +++ b/src/System.Management.Automation/engine/remoting/client/JobSourceAdapter.cs @@ -188,7 +188,7 @@ public string Name set { if (value == null) - throw new PSArgumentNullException("value"); + throw new PSArgumentNullException(); _name = value; } } diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index 04ce777964e..55f603fb788 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -168,7 +168,7 @@ public CultureInfo Culture { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(); } _culture = value; @@ -191,7 +191,7 @@ public CultureInfo UICulture { if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(); } _uiCulture = value; @@ -403,7 +403,7 @@ public Uri ConnectionUri { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } UpdateUri(value); @@ -610,7 +610,7 @@ public override string CertificateThumbprint { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } _thumbPrint = value; diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index 2d8c35c7fc9..059d7da044d 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -139,7 +139,7 @@ internal CmdletProviderContext Context { if (value == null) { - throw PSTraceSource.NewArgumentNullException("value"); + throw PSTraceSource.NewArgumentNullException(); } // Check that the provider supports the use of credentials diff --git a/src/System.Management.Automation/namespaces/SessionStateProviderBase.cs b/src/System.Management.Automation/namespaces/SessionStateProviderBase.cs index 3f0f52c942e..84953c681c6 100644 --- a/src/System.Management.Automation/namespaces/SessionStateProviderBase.cs +++ b/src/System.Management.Automation/namespaces/SessionStateProviderBase.cs @@ -694,7 +694,7 @@ protected override void NewItem(string path, string type, object newItem) if (newItem == null) { ArgumentNullException argException = - PSTraceSource.NewArgumentNullException("value"); + PSTraceSource.NewArgumentNullException(nameof(newItem)); WriteError( new ErrorRecord( diff --git a/src/System.Management.Automation/utils/MshTraceSource.cs b/src/System.Management.Automation/utils/MshTraceSource.cs index 8ed5949c31a..8fbc3e2c8fe 100644 --- a/src/System.Management.Automation/utils/MshTraceSource.cs +++ b/src/System.Management.Automation/utils/MshTraceSource.cs @@ -217,6 +217,8 @@ internal static PSTraceSource GetNewTraceSource( #region TraceFlags.New*Exception methods/helpers + internal static PSArgumentNullException NewArgumentNullException() => new PSArgumentNullException(); + /// /// Traces the Message and StackTrace properties of the exception /// and returns the new exception. This is not allowed to call other