From 9212aac0fa020b657454ef4f9ff2fdd6fc6d759c Mon Sep 17 00:00:00 2001
From: xtqqczze <45661989+xtqqczze@users.noreply.github.com>
Date: Tue, 19 May 2020 19:57:52 +0100
Subject: [PATCH] Use nameof operator (#12716)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
# PR Summary
Using *Roslynator Command Line Tool version 0.1.0.4*
* Fix RCS1015:
* `"argument"` → `nameof(argument)`
* `enum.ToString()` → `nameof(enum)`
[RCS1015.log](https://github.com/PowerShell/PowerShell/files/4646102/RCS1015.log)
## PR Context
## PR Checklist
- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
- If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
- [x] None
- **OR**
- [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
- [ ] Experimental feature name(s):
- **User-facing changes**
- [x] Not Applicable
- **OR**
- [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [ ] Issue filed:
- **Testing - New and feature**
- [x] N/A or can only be tested interactively
- **OR**
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- **Tooling**
- [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
- **OR**
- [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
- Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host).
- Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
- Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions).
- Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
---
.../cmdletization/SessionBasedWrapper.cs | 6 +-
.../cmdletization/cim/CimJobException.cs | 4 +-
.../cmdletization/cim/cimConverter.cs | 6 +-
.../cimSupport/cmdletization/cim/cimQuery.cs | 4 +-
.../cmdletization/cim/cimWrapper.cs | 2 +-
.../commands/management/CIMHelper.cs | 4 +-
.../commands/management/Computer.cs | 4 +-
.../commands/management/ContentCommandBase.cs | 4 +-
.../commands/management/Process.cs | 2 +-
.../commands/management/Service.cs | 6 +-
.../commands/management/SetContentCommand.cs | 2 +-
.../commands/utility/AddType.cs | 2 +-
.../commands/utility/CustomSerialization.cs | 4 +-
.../EnableDisableRunspaceDebugCommand.cs | 2 +-
.../OutGridView/OutWindowProxy.cs | 10 +-
.../commands/utility/GetRandomCommand.cs | 4 +-
.../utility/ImplicitRemotingCommands.cs | 68 ++++----
.../commands/utility/Select-Object.cs | 2 +-
.../ShowCommand/ShowCommandCommandInfo.cs | 4 +-
.../ShowCommand/ShowCommandModuleInfo.cs | 4 +-
.../ShowCommand/ShowCommandParameterInfo.cs | 4 +-
.../ShowCommandParameterSetInfo.cs | 4 +-
.../ShowCommand/ShowCommandParameterType.cs | 4 +-
.../commands/utility/UtilityCommon.cs | 6 +-
.../Common/InvokeRestMethodCommand.Common.cs | 4 +-
.../Common/WebRequestPSCmdlet.Common.cs | 30 ++--
.../Common/WebResponseObject.Common.cs | 2 +-
.../InvokeWebRequestCommand.CoreClr.cs | 2 +-
.../utility/WebCmdlet/CoreCLR/WebProxy.cs | 4 +-
.../utility/trace/MshHostTraceListener.cs | 2 +-
.../utility/trace/TraceExpressionCommand.cs | 4 +-
.../WindowsTaskbarJumpList/PropVariant.cs | 2 +-
.../host/msh/ConsoleControl.cs | 2 +-
.../host/msh/ConsoleHost.cs | 2 +-
.../host/msh/ConsoleHostRawUserInterface.cs | 24 +--
.../msh/ConsoleHostUserInterfacePrompt.cs | 6 +-
...ConsoleHostUserInterfacePromptForChoice.cs | 10 +-
.../host/msh/ProgressPane.cs | 2 +-
.../DotNetCode/Eventing/EventDescriptor.cs | 8 +-
.../DotNetCode/Eventing/EventProvider.cs | 6 +-
.../Eventing/EventProviderTraceListener.cs | 2 +-
.../VT100EscapeSequences.cs | 2 +-
.../security/AclCommands.cs | 22 +--
.../security/CertificateProvider.cs | 6 +-
.../security/SignatureCommands.cs | 2 +-
.../CurrentConfigurations.cs | 18 +--
src/Microsoft.WSMan.Management/WsManHelper.cs | 6 +-
.../CoreCLR/CorePsAssemblyLoadContext.cs | 4 +-
.../DscSupport/CimDSCParser.cs | 22 +--
.../FormatAndOutput/common/BaseCommand.cs | 2 +-
.../common/BaseFormattingCommandParameters.cs | 4 +-
.../common/BaseOutputtingCommand.cs | 2 +-
.../common/DisplayDatabase/FormatTable.cs | 10 +-
.../DisplayDatabase/displayDescriptionData.cs | 20 +--
.../displayDescriptionData_Complex.cs | 4 +-
.../displayDescriptionData_List.cs | 8 +-
.../displayDescriptionData_Table.cs | 8 +-
.../displayDescriptionData_Wide.cs | 10 +-
.../common/DisplayDatabase/typeDataManager.cs | 4 +-
.../DisplayDatabase/typeDataXmlLoader.cs | 20 +--
.../typeDataXmlLoader_Views.cs | 4 +-
.../common/FormatViewGenerator_Complex.cs | 4 +-
.../common/FormattingObjectsDeserializer.cs | 12 +-
.../FormatAndOutput/common/ILineOutput.cs | 6 +-
.../common/Utilities/MshParameter.cs | 2 +-
.../Utilities/MshParameterAssociation.cs | 2 +-
.../common/Utilities/Mshexpression.cs | 4 +-
.../out-console/ConsoleLineOutput.cs | 6 +-
.../cmdletization/MethodInvocationInfo.cs | 4 +-
.../cmdletization/ObjectModelWrapper.cs | 8 +-
.../other/ciminstancetypeadapter.cs | 14 +-
.../engine/ApplicationInfo.cs | 4 +-
.../ChildrenCmdletProviderInterfaces.cs | 4 +-
.../engine/CmdletFamilyProviderInterfaces.cs | 4 +-
.../engine/CmdletInfo.cs | 10 +-
.../engine/CmdletParameterBinderController.cs | 20 +--
.../engine/CodeMethods.cs | 4 +-
.../engine/CommandBase.cs | 2 +-
.../CommandCompletion/CommandCompletion.cs | 32 ++--
.../CommandCompletion/CompletionCompleters.cs | 2 +-
.../CommandCompletion/CompletionResult.cs | 8 +-
.../CommandCompletion/ExtensibleCompletion.cs | 8 +-
.../PseudoParameterBinder.cs | 22 +--
.../engine/CommandDiscovery.cs | 8 +-
.../engine/CommandInfo.cs | 8 +-
.../engine/CommandMetadata.cs | 12 +-
.../engine/CommandProcessor.cs | 2 +-
.../engine/CommandProcessorBase.cs | 6 +-
.../engine/CommonCommandParameters.cs | 2 +-
.../engine/CompiledCommandParameter.cs | 6 +-
.../engine/ContentCmdletProviderInterfaces.cs | 4 +-
.../engine/CoreAdapter.cs | 4 +-
.../engine/Credential.cs | 2 +-
.../engine/DataStoreAdapter.cs | 18 +--
.../engine/DataStoreAdapterProvider.cs | 8 +-
.../engine/DefaultCommandRuntime.cs | 2 +-
.../engine/DriveInterfaces.cs | 2 +-
.../engine/EngineIntrinsics.cs | 2 +-
.../engine/ErrorPackage.cs | 2 +-
.../engine/EventManager.cs | 14 +-
.../ExperimentalFeature.cs | 2 +-
.../engine/ExtendedTypeSystemException.cs | 2 +-
.../engine/ExternalScriptInfo.cs | 4 +-
.../engine/FunctionInfo.cs | 2 +-
.../engine/GetCommandCommand.cs | 2 +-
.../engine/ItemCmdletProviderInterfaces.cs | 4 +-
.../engine/LanguagePrimitives.cs | 14 +-
.../engine/MergedCommandParameterMetadata.cs | 4 +-
.../engine/Modules/ModuleCmdletBase.cs | 2 +-
.../engine/Modules/PSModuleInfo.cs | 4 +-
.../engine/Modules/RemoteDiscoveryHelper.cs | 2 +-
.../engine/MshCmdlet.cs | 16 +-
.../engine/MshCommandRuntime.cs | 8 +-
.../engine/MshMemberInfo.cs | 106 ++++++-------
.../engine/MshObject.cs | 10 +-
.../engine/MshObjectTypeDescriptor.cs | 6 +-
.../engine/NativeCommandProcessor.cs | 2 +-
.../engine/PSClassInfo.cs | 2 +-
.../engine/ParameterBinderBase.cs | 10 +-
.../engine/ParameterBinderController.cs | 2 +-
.../engine/ParameterInfo.cs | 2 +-
.../engine/ParameterSetInfo.cs | 4 +-
.../engine/ParameterSetSpecificMetadata.cs | 2 +-
.../engine/PathInterfaces.cs | 2 +-
.../engine/ProgressRecord.cs | 12 +-
.../PropertyCmdletProviderInterfaces.cs | 4 +-
.../engine/ProviderInterfaces.cs | 2 +-
.../engine/ProxyCommand.cs | 2 +-
.../engine/PseudoParameterBinder.cs | 2 +-
.../engine/PseudoParameters.cs | 4 +-
.../engine/ScopedItemSearcher.cs | 4 +-
.../engine/ScriptInfo.cs | 2 +-
...urityDescriptorCmdletProviderInterfaces.cs | 4 +-
.../engine/SessionState.cs | 2 +-
.../engine/SessionStateAliasAPIs.cs | 14 +-
.../engine/SessionStateCmdletAPIs.cs | 4 +-
.../engine/SessionStateContainer.cs | 62 ++++----
.../engine/SessionStateContent.cs | 18 +--
.../engine/SessionStateDriveAPIs.cs | 20 +--
.../engine/SessionStateDynamicProperty.cs | 72 ++++-----
.../engine/SessionStateFunctionAPIs.cs | 16 +-
.../engine/SessionStateItem.cs | 24 +--
.../engine/SessionStateLocationAPIs.cs | 14 +-
.../engine/SessionStateNavigation.cs | 30 ++--
.../engine/SessionStateProperty.cs | 22 +--
.../engine/SessionStateProviderAPIs.cs | 38 ++---
.../engine/SessionStatePublic.cs | 6 +-
.../engine/SessionStateScope.cs | 6 +-
...SessionStateSecurityDescriptorInterface.cs | 22 +--
.../engine/SessionStateUtils.cs | 2 +-
.../engine/SessionStateVariableAPIs.cs | 32 ++--
.../engine/ShellVariable.cs | 2 +-
.../engine/ThirdPartyAdapter.cs | 2 +-
.../engine/TypeMetadata.cs | 14 +-
.../engine/TypeTable.cs | 34 ++--
.../engine/UserFeedbackParameters.cs | 4 +-
.../engine/VariableAttributeCollection.cs | 2 +-
.../engine/VariableInterfaces.cs | 2 +-
.../engine/VariablePath.cs | 2 +-
.../engine/cmdlet.cs | 10 +-
.../engine/debugger/debugger.cs | 40 ++---
.../engine/hostifaces/AsyncResult.cs | 2 +-
.../engine/hostifaces/ChoiceDescription.cs | 6 +-
.../engine/hostifaces/Command.cs | 16 +-
.../engine/hostifaces/Connection.cs | 6 +-
.../engine/hostifaces/ConnectionBase.cs | 16 +-
.../engine/hostifaces/ConnectionFactory.cs | 12 +-
.../engine/hostifaces/FieldDescription.cs | 10 +-
.../engine/hostifaces/History.cs | 14 +-
.../engine/hostifaces/HostUtilities.cs | 4 +-
.../hostifaces/InternalHostUserInterface.cs | 14 +-
.../engine/hostifaces/ListModifier.cs | 10 +-
.../engine/hostifaces/LocalConnection.cs | 2 +-
.../engine/hostifaces/LocalPipeline.cs | 2 +-
.../hostifaces/MshHostRawUserInterface.cs | 16 +-
.../engine/hostifaces/PSCommand.cs | 8 +-
.../engine/hostifaces/PSDataCollection.cs | 16 +-
.../engine/hostifaces/PSTask.cs | 2 +-
.../engine/hostifaces/Parameter.cs | 10 +-
.../engine/hostifaces/Pipeline.cs | 2 +-
.../engine/hostifaces/PowerShell.cs | 28 ++--
.../engine/hostifaces/RunspacePoolInternal.cs | 30 ++--
.../engine/hostifaces/pipelinebase.cs | 4 +-
.../engine/lang/interface/PSParser.cs | 4 +-
.../engine/lang/parserutils.cs | 2 +-
.../engine/parser/Compiler.cs | 2 +-
.../engine/parser/SafeValues.cs | 2 +-
.../engine/parser/ast.cs | 150 +++++++++---------
.../engine/parser/tokenizer.cs | 8 +-
.../engine/pipeline.cs | 8 +-
.../engine/regex.cs | 4 +-
.../remoting/client/ClientMethodExecutor.cs | 2 +-
.../engine/remoting/client/Job.cs | 12 +-
.../engine/remoting/client/Job2.cs | 4 +-
.../engine/remoting/client/JobManager.cs | 10 +-
.../remoting/client/JobSourceAdapter.cs | 2 +-
.../client/RemoteRunspacePoolInternal.cs | 8 +-
.../remoting/client/RemotingErrorRecord.cs | 4 +-
.../engine/remoting/client/ThrottlingJob.cs | 8 +-
.../remoting/client/clientremotesession.cs | 6 +-
...clientremotesessionprotocolstatemachine.cs | 4 +-
.../engine/remoting/client/remotepipeline.cs | 2 +-
.../engine/remoting/client/remoterunspace.cs | 16 +-
.../client/remotingprotocolimplementation.cs | 12 +-
.../remoting/commands/InvokeCommandCommand.cs | 2 +-
.../remoting/commands/PSRemotingCmdlet.cs | 26 +--
.../remoting/commands/PopRunspaceCommand.cs | 2 +-
.../remoting/commands/PushRunspaceCommand.cs | 20 +--
.../remoting/commands/newrunspacecommand.cs | 12 +-
.../remoting/commands/remotingcommandutil.cs | 8 +-
.../common/RemoteSessionHyperVSocket.cs | 2 +-
.../remoting/common/RemoteSessionNamedPipe.cs | 22 +--
.../remoting/common/RunspaceConnectionInfo.cs | 20 +--
.../common/WireDataFormat/EncodeAndDecode.cs | 52 +++---
.../engine/remoting/common/misc.cs | 6 +-
.../remoting/common/remotingexceptions.cs | 8 +-
.../fanin/InitialSessionStateProvider.cs | 16 +-
.../fanin/OutOfProcTransportManager.cs | 22 +--
.../server/OutOfProcServerMediator.cs | 4 +-
.../ServerRemoteHostRawUserInterface.cs | 4 +-
.../server/ServerRemotingProtocol2.cs | 4 +-
.../server/ServerRunspacePoolDriver.cs | 6 +-
.../remoting/server/serverremotesession.cs | 8 +-
.../server/serverremotesessionstatemachine.cs | 48 +++---
.../serverremotingprotocolimplementation.cs | 2 +-
.../engine/runtime/CompiledScriptBlock.cs | 2 +-
.../engine/runtime/Operations/MiscOps.cs | 4 +-
.../engine/runtime/Operations/StringOps.cs | 2 +-
.../engine/serialization.cs | 32 ++--
.../help/CommandHelpProvider.cs | 2 +-
.../help/HelpCategoryInvalidException.cs | 2 +-
.../help/HelpNotFoundException.cs | 2 +-
.../help/ProviderHelpProvider.cs | 2 +-
.../logging/MshLog.cs | 34 ++--
.../namespaces/AliasProvider.cs | 2 +-
.../namespaces/CoreCommandContext.cs | 14 +-
.../namespaces/FileSystemContentStream.cs | 6 +-
.../namespaces/FileSystemProvider.cs | 82 +++++-----
.../namespaces/FileSystemSecurity.cs | 10 +-
.../namespaces/FunctionProvider.cs | 2 +-
.../namespaces/LocationGlobber.cs | 2 +-
.../namespaces/NavigationProviderBase.cs | 8 +-
.../namespaces/ProviderBase.cs | 18 +--
.../ProviderDeclarationAttribute.cs | 4 +-
.../namespaces/RegistryProvider.cs | 68 ++++----
.../namespaces/RegistrySecurity.cs | 12 +-
.../namespaces/SessionStateProviderBase.cs | 26 +--
.../namespaces/StackInfo.cs | 4 +-
.../security/Authenticode.cs | 8 +-
.../security/CredentialParameter.cs | 2 +-
.../security/SecureStringHelper.cs | 6 +-
.../security/SecurityManager.cs | 2 +-
.../singleshell/config/MshSnapinInfo.cs | 40 ++---
.../config/MshSnapinLoadException.cs | 2 +-
.../utils/CommandDiscoveryExceptions.cs | 8 +-
.../utils/ExecutionExceptions.cs | 14 +-
.../utils/MshArgumentException.cs | 2 +-
.../utils/MshArgumentNullException.cs | 2 +-
.../utils/MshArgumentOutOfRangeException.cs | 2 +-
.../utils/MshInvalidOperationException.cs | 2 +-
.../utils/MshNotImplementedException.cs | 2 +-
.../utils/MshNotSupportedException.cs | 2 +-
.../utils/MshObjectDisposedException.cs | 2 +-
.../utils/MshTraceSource.cs | 28 ++--
.../utils/ObjectReader.cs | 6 +-
.../utils/ObjectStream.cs | 8 +-
.../utils/ObjectWriter.cs | 2 +-
.../utils/ParameterBinderExceptions.cs | 16 +-
.../utils/ParserException.cs | 4 +-
.../utils/PowerShellExecutionHelper.cs | 2 +-
.../utils/PsUtils.cs | 12 +-
.../utils/ResourceManagerCache.cs | 12 +-
.../utils/RuntimeException.cs | 2 +-
.../utils/SessionStateExceptions.cs | 4 +-
.../utils/StructuredTraceSource.cs | 2 +-
.../utils/tracing/EtwActivity.cs | 24 +--
.../EtwActivityReverterMethodInvoker.cs | 2 +-
.../utils/tracing/EtwEventCorrelator.cs | 2 +-
278 files changed, 1429 insertions(+), 1429 deletions(-)
diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs
index 0c0362311..9ad44f3a0 100644
--- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/SessionBasedWrapper.cs
@@ -581,8 +581,8 @@ namespace Microsoft.PowerShell.Cmdletization
/// true if successful method invocations should emit downstream the being operated on.
public override void ProcessRecord(TObjectInstance objectInstance, MethodInvocationInfo methodInvocationInfo, bool passThru)
{
- if (objectInstance == null) throw new ArgumentNullException("objectInstance");
- if (methodInvocationInfo == null) throw new ArgumentNullException("methodInvocationInfo");
+ if (objectInstance == null) throw new ArgumentNullException(nameof(objectInstance));
+ if (methodInvocationInfo == null) throw new ArgumentNullException(nameof(methodInvocationInfo));
foreach (TSession sessionForJob in this.GetSessionsToActAgainst(objectInstance))
{
@@ -607,7 +607,7 @@ namespace Microsoft.PowerShell.Cmdletization
/// Method invocation details.
public override void ProcessRecord(MethodInvocationInfo methodInvocationInfo)
{
- if (methodInvocationInfo == null) throw new ArgumentNullException("methodInvocationInfo");
+ if (methodInvocationInfo == null) throw new ArgumentNullException(nameof(methodInvocationInfo));
foreach (TSession sessionForJob in this.GetSessionsToActAgainst(methodInvocationInfo))
{
diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CimJobException.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CimJobException.cs
index b9a1d2108..092103d6f 100644
--- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CimJobException.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/CimJobException.cs
@@ -56,7 +56,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
_errorRecord = (ErrorRecord)info.GetValue("errorRecord", typeof(ErrorRecord));
@@ -71,7 +71,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs
index 58a9f0233..033b88135 100644
--- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs
@@ -52,12 +52,12 @@ namespace Microsoft.PowerShell.Cim
{
if ((offset < 0) || (offset >= _string.Length))
{
- throw new ArgumentOutOfRangeException("offset");
+ throw new ArgumentOutOfRangeException(nameof(offset));
}
if (offset + charsToCopy > _string.Length)
{
- throw new ArgumentOutOfRangeException("charsToCopy");
+ throw new ArgumentOutOfRangeException(nameof(charsToCopy));
}
fixed (char* target = _string)
@@ -352,7 +352,7 @@ namespace Microsoft.PowerShell.Cim
/// The only kind of exception this method can throw.
internal static object ConvertFromCimToDotNet(object cimObject, Type expectedDotNetType)
{
- if (expectedDotNetType == null) { throw new ArgumentNullException("expectedDotNetType"); }
+ if (expectedDotNetType == null) { throw new ArgumentNullException(nameof(expectedDotNetType)); }
if (cimObject == null)
{
diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimQuery.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimQuery.cs
index ba727baae..551b2149e 100644
--- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimQuery.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimQuery.cs
@@ -316,12 +316,12 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
{
if (string.IsNullOrEmpty(optionName))
{
- throw new ArgumentNullException("optionName");
+ throw new ArgumentNullException(nameof(optionName));
}
if (optionValue == null)
{
- throw new ArgumentNullException("optionValue");
+ throw new ArgumentNullException(nameof(optionValue));
}
this.queryOptions[optionName] = optionValue;
diff --git a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs
index acd432037..d78c8d631 100644
--- a/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimWrapper.cs
@@ -175,7 +175,7 @@ namespace Microsoft.PowerShell.Cmdletization.Cim
CimQuery query = baseQuery as CimQuery;
if (query == null)
{
- throw new ArgumentNullException("baseQuery");
+ throw new ArgumentNullException(nameof(baseQuery));
}
TerminatingErrorTracker tracker = TerminatingErrorTracker.GetTracker(this.CmdletInvocationInfo, isStaticCmdlet: false);
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/CIMHelper.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/CIMHelper.cs
index edf124963..559af1312 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/CIMHelper.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/CIMHelper.cs
@@ -80,7 +80,7 @@ namespace Microsoft.PowerShell.Commands
internal static T GetFirst(CimSession session, string nameSpace, string wmiClassName) where T : class, new()
{
if (string.IsNullOrEmpty(wmiClassName))
- throw new ArgumentException("String argument may not be null or empty", "wmiClassName");
+ throw new ArgumentException("String argument may not be null or empty", nameof(wmiClassName));
try
{
@@ -133,7 +133,7 @@ namespace Microsoft.PowerShell.Commands
internal static T[] GetAll(CimSession session, string nameSpace, string wmiClassName) where T : class, new()
{
if (string.IsNullOrEmpty(wmiClassName))
- throw new ArgumentException("String argument may not be null or empty", "wmiClassName");
+ throw new ArgumentException("String argument may not be null or empty", nameof(wmiClassName));
var rv = new List();
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs
index 578b4a7ef..ece9d77e5 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs
@@ -107,7 +107,7 @@ namespace Microsoft.PowerShell.Commands
{
if (info == null)
{
- throw new PSArgumentNullException("info");
+ throw new PSArgumentNullException(nameof(info));
}
ComputerName = info.GetString("ComputerName");
@@ -128,7 +128,7 @@ namespace Microsoft.PowerShell.Commands
{
if (info == null)
{
- throw new PSArgumentNullException("info");
+ throw new PSArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs
index 34f763617..2271388c0 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/ContentCommandBase.cs
@@ -348,7 +348,7 @@ namespace Microsoft.PowerShell.Commands
{
if (pathInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("pathInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(pathInfo));
}
PathInfo = pathInfo;
@@ -370,7 +370,7 @@ namespace Microsoft.PowerShell.Commands
{
if (contentHolders == null)
{
- throw PSTraceSource.NewArgumentNullException("contentHolders");
+ throw PSTraceSource.NewArgumentNullException(nameof(contentHolders));
}
foreach (ContentHolder holder in contentHolders)
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
index 2ba50c234..b17dfa020 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
@@ -3005,7 +3005,7 @@ namespace Microsoft.PowerShell.Commands
base.GetObjectData(info, context);
if (info == null)
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
info.AddValue("ProcessName", _processName);
}
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
index 8081e98c2..f62591fa1 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Service.cs
@@ -547,7 +547,7 @@ namespace Microsoft.PowerShell.Commands
private bool Matches(ServiceController service, string[] matchList)
{
if (matchList == null)
- throw PSTraceSource.NewArgumentNullException("matchList");
+ throw PSTraceSource.NewArgumentNullException(nameof(matchList));
string serviceID = (selectionMode == SelectionMode.DisplayName)
? service.DisplayName
: service.ServiceName;
@@ -2566,7 +2566,7 @@ namespace Microsoft.PowerShell.Commands
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
_serviceName = info.GetString("ServiceName");
@@ -2581,7 +2581,7 @@ namespace Microsoft.PowerShell.Commands
{
if (info == null)
{
- throw new ArgumentNullException("info");
+ throw new ArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetContentCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetContentCommand.cs
index b73edc3f2..4e040517b 100644
--- a/src/Microsoft.PowerShell.Commands.Management/commands/management/SetContentCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/SetContentCommand.cs
@@ -28,7 +28,7 @@ namespace Microsoft.PowerShell.Commands
{
if (paths == null || paths.Length == 0)
{
- throw PSTraceSource.NewArgumentNullException("paths");
+ throw PSTraceSource.NewArgumentNullException(nameof(paths));
}
CmdletProviderContext context = new CmdletProviderContext(GetCurrentContext());
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs
index 833c373ca..2e733802f 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs
@@ -887,7 +887,7 @@ namespace Microsoft.PowerShell.Commands
case OutputAssemblyType.WindowsApplication:
return OutputKind.WindowsApplication;
default:
- throw new ArgumentOutOfRangeException("outputType");
+ throw new ArgumentOutOfRangeException(nameof(outputType));
}
}
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
index 91985bd17..22572c654 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/CustomSerialization.cs
@@ -55,12 +55,12 @@ namespace System.Management.Automation
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentException("writer");
+ throw PSTraceSource.NewArgumentException(nameof(writer));
}
if (depth < 1)
{
- throw PSTraceSource.NewArgumentException("writer", Serialization.DepthOfOneRequired);
+ throw PSTraceSource.NewArgumentException(nameof(writer), Serialization.DepthOfOneRequired);
}
_depth = depth;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/EnableDisableRunspaceDebugCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/EnableDisableRunspaceDebugCommand.cs
index 689691742..c1294a085 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/EnableDisableRunspaceDebugCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/EnableDisableRunspaceDebugCommand.cs
@@ -75,7 +75,7 @@ namespace Microsoft.PowerShell.Commands
/// Runspace local Id.
public PSRunspaceDebug(bool enabled, bool breakAll, string runspaceName, int runspaceId)
{
- if (string.IsNullOrEmpty(runspaceName)) { throw new PSArgumentNullException("runspaceName"); }
+ if (string.IsNullOrEmpty(runspaceName)) { throw new PSArgumentNullException(nameof(runspaceName)); }
this.Enabled = enabled;
this.BreakAll = breakAll;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
index 49d41d8ce..871b1a1bb 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutWindowProxy.cs
@@ -59,17 +59,17 @@ namespace Microsoft.PowerShell.Commands
{
if (propertyNames == null)
{
- throw new ArgumentNullException("propertyNames");
+ throw new ArgumentNullException(nameof(propertyNames));
}
if (displayNames == null)
{
- throw new ArgumentNullException("displayNames");
+ throw new ArgumentNullException(nameof(displayNames));
}
if (types == null)
{
- throw new ArgumentNullException("types");
+ throw new ArgumentNullException(nameof(types));
}
try
@@ -178,7 +178,7 @@ namespace Microsoft.PowerShell.Commands
{
if (livePSObject == null)
{
- throw new ArgumentNullException("livePSObject");
+ throw new ArgumentNullException(nameof(livePSObject));
}
if (_headerInfo == null)
@@ -204,7 +204,7 @@ namespace Microsoft.PowerShell.Commands
{
if (livePSObject == null)
{
- throw new ArgumentNullException("livePSObject");
+ throw new ArgumentNullException(nameof(livePSObject));
}
if (_headerInfo == null)
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs
index 91955c0f2..6e4445ba2 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/GetRandomCommand.cs
@@ -644,7 +644,7 @@ namespace Microsoft.PowerShell.Commands
{
if (maxValue < 0)
{
- throw new ArgumentOutOfRangeException("maxValue", GetRandomCommandStrings.MaxMustBeGreaterThanZeroApi);
+ throw new ArgumentOutOfRangeException(nameof(maxValue), GetRandomCommandStrings.MaxMustBeGreaterThanZeroApi);
}
return Next(0, maxValue);
@@ -660,7 +660,7 @@ namespace Microsoft.PowerShell.Commands
{
if (minValue > maxValue)
{
- throw new ArgumentOutOfRangeException("minValue", GetRandomCommandStrings.MinGreaterThanOrEqualMaxApi);
+ throw new ArgumentOutOfRangeException(nameof(minValue), GetRandomCommandStrings.MinGreaterThanOrEqualMaxApi);
}
int randomNumber = 0;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
index 61b71fe8f..a1bc3762f 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs
@@ -187,7 +187,7 @@ namespace Microsoft.PowerShell.Commands
{
if (moduleInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("moduleInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(moduleInfo));
}
// Note: we are using this.Context.Events to make sure that the event handler
@@ -534,7 +534,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(errorId))
{
- throw PSTraceSource.NewArgumentNullException("errorId");
+ throw PSTraceSource.NewArgumentNullException(nameof(errorId));
}
return new ErrorDetails(
@@ -564,7 +564,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
string errorId = "ErrorMalformedDataFromRemoteCommand";
@@ -585,7 +585,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandNames))
{
- throw PSTraceSource.NewArgumentNullException("commandNames");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandNames));
}
string errorId = "ErrorCommandSkippedBecauseOfShadowing";
@@ -606,7 +606,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
string errorId = "ErrorSkippedNonRequestedCommand";
@@ -627,7 +627,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(typeName))
{
- throw PSTraceSource.NewArgumentNullException("typeName");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeName));
}
string errorId = "ErrorSkippedNonRequestedTypeDefinition";
@@ -648,7 +648,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
string errorId = "ErrorSkippedUnsafeCommandName";
@@ -669,18 +669,18 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
if (string.IsNullOrEmpty(nameType))
{
- throw PSTraceSource.NewArgumentNullException("nameType");
+ throw PSTraceSource.NewArgumentNullException(nameof(nameType));
}
Dbg.Assert(nameType.Equals("Alias") || nameType.Equals("ParameterSet") || nameType.Equals("Parameter"), "nameType matches resource names");
if (string.IsNullOrEmpty(name))
{
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
}
string errorId = "ErrorSkippedUnsafe" + nameType + "Name";
@@ -701,12 +701,12 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
if (runtimeException == null)
{
- throw PSTraceSource.NewArgumentNullException("runtimeException");
+ throw PSTraceSource.NewArgumentNullException(nameof(runtimeException));
}
string errorId;
@@ -755,7 +755,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(aliasName))
{
- throw PSTraceSource.NewArgumentNullException("aliasName");
+ throw PSTraceSource.NewArgumentNullException(nameof(aliasName));
}
string errorId = "ErrorCouldntResolveAlias";
@@ -776,7 +776,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
string errorId = "ErrorNoResultsFromRemoteEnd";
@@ -872,7 +872,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentNullException("commandName");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandName));
}
if (this.AllowClobber.IsPresent)
@@ -1270,7 +1270,7 @@ namespace Microsoft.PowerShell.Commands
{
if (deserializedParameterMetadata == null)
{
- throw PSTraceSource.NewArgumentNullException("deserializedParameterMetadata");
+ throw PSTraceSource.NewArgumentNullException(nameof(deserializedParameterMetadata));
}
string name = GetPropertyValue("Get-Command", deserializedParameterMetadata, "Name");
@@ -1311,7 +1311,7 @@ namespace Microsoft.PowerShell.Commands
{
if (deserializedCommandInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("deserializedCommandInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(deserializedCommandInfo));
}
string name = GetPropertyValue("Get-Command", deserializedCommandInfo, "Name");
@@ -1964,7 +1964,7 @@ namespace Microsoft.PowerShell.Commands
{
if (name == null)
{
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
}
StringBuilder result = new StringBuilder(name.Length);
@@ -2014,7 +2014,7 @@ namespace Microsoft.PowerShell.Commands
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
GenerateTopComment(writer);
@@ -2087,7 +2087,7 @@ $script:MyModule = $MyInvocation.MyCommand.ScriptBlock.Module
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
// In Win8, we are no longer loading all assemblies by default.
@@ -2123,7 +2123,7 @@ function Write-PSImplicitRemotingMessage
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
writer.Write(HelperFunctionsWriteMessage);
@@ -2177,7 +2177,7 @@ if ($PSSessionOverride) {{ Set-PSImplicitRemotingSession $PSSessionOverride }}
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
string runspaceNameTemplate = StringUtil.Format(ImplicitRemotingStrings.ProxyRunspaceNameTemplate);
@@ -2208,7 +2208,7 @@ function Get-PSImplicitRemotingSessionOption
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
writer.Write(
@@ -2403,7 +2403,7 @@ function Get-PSImplicitRemotingSession
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
string hashString;
@@ -2752,7 +2752,7 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
writer.Write(HelperFunctionsModifyParameters);
@@ -2831,7 +2831,7 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
string functionNameForString = CodeGeneration.EscapeSingleQuotedStringContent(commandMetadata.Name);
@@ -2853,12 +2853,12 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
if (listOfCommandMetadata == null)
{
- throw PSTraceSource.NewArgumentNullException("listOfCommandMetadata");
+ throw PSTraceSource.NewArgumentNullException(nameof(listOfCommandMetadata));
}
this.GenerateSectionSeparator(writer);
@@ -2880,12 +2880,12 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
if (listOfCommandMetadata == null)
{
- throw PSTraceSource.NewArgumentNullException("listOfCommandMetadata");
+ throw PSTraceSource.NewArgumentNullException(nameof(listOfCommandMetadata));
}
this.GenerateSectionSeparator(writer);
@@ -2899,7 +2899,7 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (listOfCommandMetadata == null)
{
- throw PSTraceSource.NewArgumentNullException("listOfCommandMetadata");
+ throw PSTraceSource.NewArgumentNullException(nameof(listOfCommandMetadata));
}
List listOfCommandNames = new List();
@@ -2915,7 +2915,7 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (listOfStrings == null)
{
- throw PSTraceSource.NewArgumentNullException("listOfStrings");
+ throw PSTraceSource.NewArgumentNullException(nameof(listOfStrings));
}
StringBuilder arrayString = new StringBuilder();
@@ -2976,12 +2976,12 @@ function Get-PSImplicitRemotingClientSideParameters
{
if (writer == null)
{
- throw PSTraceSource.NewArgumentNullException("writer");
+ throw PSTraceSource.NewArgumentNullException(nameof(writer));
}
if (listOfFormatData == null)
{
- throw PSTraceSource.NewArgumentNullException("listOfFormatData");
+ throw PSTraceSource.NewArgumentNullException(nameof(listOfFormatData));
}
XmlWriterSettings settings = new XmlWriterSettings();
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
index e5405172b..7614278b6 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Select-Object.cs
@@ -25,7 +25,7 @@ namespace Microsoft.PowerShell.Commands
{
if (wildcardPatternsStrings == null)
{
- throw new ArgumentNullException("wildcardPatternsStrings");
+ throw new ArgumentNullException(nameof(wildcardPatternsStrings));
}
_wildcardPatterns = new WildcardPattern[wildcardPatternsStrings.Length];
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs
index 115920651..c0226471b 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandCommandInfo.cs
@@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Name;
@@ -71,7 +71,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Members["Name"].Value as string;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs
index 9111cd882..457cf6d70 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandModuleInfo.cs
@@ -21,7 +21,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Name;
@@ -37,7 +37,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Members["Name"].Value as string;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs
index 6e4732f7e..665fa0399 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterInfo.cs
@@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Name;
@@ -50,7 +50,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Members["Name"].Value as string;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs
index ff63ee13e..e3c4cbf2c 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterSetInfo.cs
@@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Name;
@@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.Name = other.Members["Name"].Value as string;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs
index f53d72ea8..d7a3258d2 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ShowCommand/ShowCommandParameterType.cs
@@ -22,7 +22,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.FullName = other.FullName;
@@ -51,7 +51,7 @@ namespace Microsoft.PowerShell.Commands.ShowCommandExtension
{
if (other == null)
{
- throw new ArgumentNullException("other");
+ throw new ArgumentNullException(nameof(other));
}
this.IsEnum = (bool)(other.Members["IsEnum"].Value);
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs
index e4ef04b96..1e404991b 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/UtilityCommon.cs
@@ -121,7 +121,7 @@ namespace Microsoft.PowerShell.Commands
{
if (value == null)
{
- throw PSTraceSource.NewArgumentNullException("value");
+ throw PSTraceSource.NewArgumentNullException(nameof(value));
}
Offset64 = offset;
@@ -150,7 +150,7 @@ namespace Microsoft.PowerShell.Commands
{
if (value == null)
{
- throw PSTraceSource.NewArgumentNullException("value");
+ throw PSTraceSource.NewArgumentNullException(nameof(value));
}
Offset64 = offset;
@@ -179,7 +179,7 @@ namespace Microsoft.PowerShell.Commands
{
if (value == null)
{
- throw PSTraceSource.NewArgumentNullException("value");
+ throw PSTraceSource.NewArgumentNullException(nameof(value));
}
Bytes = value;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
index fc0921d3c..273fae835 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/InvokeRestMethodCommand.Common.cs
@@ -380,7 +380,7 @@ namespace Microsoft.PowerShell.Commands
///
internal override void ProcessResponse(HttpResponseMessage response)
{
- if (response == null) { throw new ArgumentNullException("response"); }
+ if (response == null) { throw new ArgumentNullException(nameof(response)); }
var baseResponseStream = StreamHelper.GetResponseStream(response);
@@ -480,7 +480,7 @@ namespace Microsoft.PowerShell.Commands
private RestReturnType CheckReturnType(HttpResponseMessage response)
{
- if (response == null) { throw new ArgumentNullException("response"); }
+ if (response == null) { throw new ArgumentNullException(nameof(response)); }
RestReturnType rt = RestReturnType.Detect;
string contentType = ContentHelper.GetContentType(response);
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
index ee56360e1..801660c0e 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs
@@ -751,7 +751,7 @@ namespace Microsoft.PowerShell.Commands
private Uri CheckProtocol(Uri uri)
{
- if (uri == null) { throw new ArgumentNullException("uri"); }
+ if (uri == null) { throw new ArgumentNullException(nameof(uri)); }
if (!uri.IsAbsoluteUri)
{
@@ -770,7 +770,7 @@ namespace Microsoft.PowerShell.Commands
private string FormatDictionary(IDictionary content)
{
if (content == null)
- throw new ArgumentNullException("content");
+ throw new ArgumentNullException(nameof(content));
StringBuilder bodyBuilder = new StringBuilder();
foreach (string key in content.Keys)
@@ -1165,7 +1165,7 @@ namespace Microsoft.PowerShell.Commands
internal virtual void FillRequestStream(HttpRequestMessage request)
{
- if (request == null) { throw new ArgumentNullException("request"); }
+ if (request == null) { throw new ArgumentNullException(nameof(request)); }
// set the content type
if (ContentType != null)
@@ -1338,9 +1338,9 @@ namespace Microsoft.PowerShell.Commands
internal virtual HttpResponseMessage GetResponse(HttpClient client, HttpRequestMessage request, bool keepAuthorization)
{
- if (client == null) { throw new ArgumentNullException("client"); }
+ if (client == null) { throw new ArgumentNullException(nameof(client)); }
- if (request == null) { throw new ArgumentNullException("request"); }
+ if (request == null) { throw new ArgumentNullException(nameof(request)); }
// Add 1 to account for the first request.
int totalRequests = WebSession.MaximumRetryCount + 1;
@@ -1452,7 +1452,7 @@ namespace Microsoft.PowerShell.Commands
internal virtual void UpdateSession(HttpResponseMessage response)
{
- if (response == null) { throw new ArgumentNullException("response"); }
+ if (response == null) { throw new ArgumentNullException(nameof(response)); }
}
#endregion Virtual Methods
@@ -1658,7 +1658,7 @@ namespace Microsoft.PowerShell.Commands
internal long SetRequestContent(HttpRequestMessage request, byte[] content)
{
if (request == null)
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
if (content == null)
return 0;
@@ -1681,7 +1681,7 @@ namespace Microsoft.PowerShell.Commands
internal long SetRequestContent(HttpRequestMessage request, string content)
{
if (request == null)
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
if (content == null)
return 0;
@@ -1730,7 +1730,7 @@ namespace Microsoft.PowerShell.Commands
internal long SetRequestContent(HttpRequestMessage request, XmlNode xmlNode)
{
if (request == null)
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
if (xmlNode == null)
return 0;
@@ -1767,9 +1767,9 @@ namespace Microsoft.PowerShell.Commands
internal long SetRequestContent(HttpRequestMessage request, Stream contentStream)
{
if (request == null)
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
if (contentStream == null)
- throw new ArgumentNullException("contentStream");
+ throw new ArgumentNullException(nameof(contentStream));
var streamContent = new StreamContent(contentStream);
request.Content = streamContent;
@@ -1791,12 +1791,12 @@ namespace Microsoft.PowerShell.Commands
{
if (request == null)
{
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
}
if (multipartContent == null)
{
- throw new ArgumentNullException("multipartContent");
+ throw new ArgumentNullException(nameof(multipartContent));
}
request.Content = multipartContent;
@@ -1807,9 +1807,9 @@ namespace Microsoft.PowerShell.Commands
internal long SetRequestContent(HttpRequestMessage request, IDictionary content)
{
if (request == null)
- throw new ArgumentNullException("request");
+ throw new ArgumentNullException(nameof(request));
if (content == null)
- throw new ArgumentNullException("content");
+ throw new ArgumentNullException(nameof(content));
string body = FormatDictionary(content);
return (SetRequestContent(request, body));
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs
index 40e1ddffa..70c5721db 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs
@@ -182,7 +182,7 @@ namespace Microsoft.PowerShell.Commands
private void SetResponse(HttpResponseMessage response, Stream contentStream)
{
- if (response == null) { throw new ArgumentNullException("response"); }
+ if (response == null) { throw new ArgumentNullException(nameof(response)); }
BaseResponse = response;
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs
index 27cca4837..b0f849490 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/InvokeWebRequestCommand.CoreClr.cs
@@ -31,7 +31,7 @@ namespace Microsoft.PowerShell.Commands
///
internal override void ProcessResponse(HttpResponseMessage response)
{
- if (response == null) { throw new ArgumentNullException("response"); }
+ if (response == null) { throw new ArgumentNullException(nameof(response)); }
Stream responseStream = StreamHelper.GetResponseStream(response);
if (ShouldWriteToPipeline)
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
index c1df3aa0b..5cb4f2b4f 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/CoreCLR/WebProxy.cs
@@ -15,7 +15,7 @@ namespace Microsoft.PowerShell.Commands
{
if (address == null)
{
- throw new ArgumentNullException("address");
+ throw new ArgumentNullException(nameof(address));
}
_proxyAddress = address;
@@ -50,7 +50,7 @@ namespace Microsoft.PowerShell.Commands
{
if (destination == null)
{
- throw new ArgumentNullException("destination");
+ throw new ArgumentNullException(nameof(destination));
}
if (destination.IsLoopback)
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
index fc91cec91..9b225bdc1 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/MshHostTraceListener.cs
@@ -31,7 +31,7 @@ namespace Microsoft.PowerShell.Commands
{
if (cmdlet == null)
{
- throw new PSArgumentNullException("cmdlet");
+ throw new PSArgumentNullException(nameof(cmdlet));
}
Diagnostics.Assert(
diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
index c7668903e..12f8e5b4e 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/trace/TraceExpressionCommand.cs
@@ -334,12 +334,12 @@ namespace Microsoft.PowerShell.Commands
{
if (cmdlet == null)
{
- throw new ArgumentNullException("cmdlet");
+ throw new ArgumentNullException(nameof(cmdlet));
}
if (matchingSources == null)
{
- throw new ArgumentNullException("matchingSources");
+ throw new ArgumentNullException(nameof(matchingSources));
}
_cmdlet = cmdlet;
diff --git a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
index 3b9d73c0f..b877ab4e3 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/WindowsTaskbarJumpList/PropVariant.cs
@@ -31,7 +31,7 @@ namespace Microsoft.PowerShell
{
if (value == null)
{
- throw new ArgumentException("PropVariantNullString", "value");
+ throw new ArgumentException("PropVariantNullString", nameof(value));
}
#pragma warning disable CS0618 // Type or member is obsolete (might get deprecated in future versions
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs
index 8d3eb856b..2229dbb63 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs
@@ -1084,7 +1084,7 @@ namespace Microsoft.PowerShell
Dbg.Assert(!consoleHandle.IsClosed, "ConsoleHandle is closed");
if (contents == null)
{
- throw PSTraceSource.NewArgumentNullException("contents");
+ throw PSTraceSource.NewArgumentNullException(nameof(contents));
}
uint codePage;
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index 43b3a8660..44ad59579 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -735,7 +735,7 @@ namespace Microsoft.PowerShell
public ConsoleColorProxy(ConsoleHostUserInterface ui)
{
- if (ui == null) throw new ArgumentNullException("ui");
+ if (ui == null) throw new ArgumentNullException(nameof(ui));
_ui = ui;
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs
index c1487dead..91aceef2f 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostRawUserInterface.cs
@@ -609,7 +609,7 @@ namespace Microsoft.PowerShell
{
if ((options & (ReadKeyOptions.IncludeKeyDown | ReadKeyOptions.IncludeKeyUp)) == 0)
{
- throw PSTraceSource.NewArgumentException("options", ConsoleHostRawUserInterfaceStrings.InvalidReadKeyOptionsError);
+ throw PSTraceSource.NewArgumentException(nameof(options), ConsoleHostRawUserInterfaceStrings.InvalidReadKeyOptionsError);
}
// keyInfo is initialized in the below if-else statement
@@ -880,14 +880,14 @@ namespace Microsoft.PowerShell
{
if (contents == null)
{
- PSTraceSource.NewArgumentNullException("contents");
+ PSTraceSource.NewArgumentNullException(nameof(contents));
}
// the origin must be within the window.
ConsoleControl.CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
ConsoleHandle handle = GetBufferInfo(out bufferInfo);
- CheckCoordinateWithinBuffer(ref origin, ref bufferInfo, "origin");
+ CheckCoordinateWithinBuffer(ref origin, ref bufferInfo, nameof(origin));
// The output is clipped by the console subsystem, so we don't have to check that the array exceeds the buffer
// boundaries.
@@ -931,14 +931,14 @@ namespace Microsoft.PowerShell
// make sure the rect is valid
if (region.Right < region.Left)
{
- throw PSTraceSource.NewArgumentException("region",
+ throw PSTraceSource.NewArgumentException(nameof(region),
ConsoleHostRawUserInterfaceStrings.InvalidRegionErrorTemplate,
"region.Right", "region.Left");
}
if (region.Bottom < region.Top)
{
- throw PSTraceSource.NewArgumentException("region",
+ throw PSTraceSource.NewArgumentException(nameof(region),
ConsoleHostRawUserInterfaceStrings.InvalidRegionErrorTemplate,
"region.Bottom", "region.Top");
}
@@ -960,7 +960,7 @@ namespace Microsoft.PowerShell
ConsoleControl.IsCJKOutputCodePage(out codePage) &&
LengthInBufferCells(fill.Character) == 2)
{
- throw PSTraceSource.NewArgumentException("fill");
+ throw PSTraceSource.NewArgumentException(nameof(fill));
}
int cells = bufferWidth * bufferHeight;
@@ -1005,7 +1005,7 @@ namespace Microsoft.PowerShell
{
if (leftExisting[r, 0].BufferCellType == BufferCellType.Leading)
{
- throw PSTraceSource.NewArgumentException("fill");
+ throw PSTraceSource.NewArgumentException(nameof(fill));
}
}
}
@@ -1014,7 +1014,7 @@ namespace Microsoft.PowerShell
{
if (charLength == 2)
{
- throw PSTraceSource.NewArgumentException("fill");
+ throw PSTraceSource.NewArgumentException(nameof(fill));
}
}
else
@@ -1030,7 +1030,7 @@ namespace Microsoft.PowerShell
{
if (rightExisting[r, 0].BufferCellType == BufferCellType.Leading)
{
- throw PSTraceSource.NewArgumentException("fill");
+ throw PSTraceSource.NewArgumentException(nameof(fill));
}
}
}
@@ -1040,7 +1040,7 @@ namespace Microsoft.PowerShell
{
if (rightExisting[r, 0].BufferCellType == BufferCellType.Leading ^ charLength == 2)
{
- throw PSTraceSource.NewArgumentException("fill");
+ throw PSTraceSource.NewArgumentException(nameof(fill));
}
}
}
@@ -1091,14 +1091,14 @@ namespace Microsoft.PowerShell
// make sure the rect is valid
if (region.Right < region.Left)
{
- throw PSTraceSource.NewArgumentException("region",
+ throw PSTraceSource.NewArgumentException(nameof(region),
ConsoleHostRawUserInterfaceStrings.InvalidRegionErrorTemplate,
"region.Right", "region.Left");
}
if (region.Bottom < region.Top)
{
- throw PSTraceSource.NewArgumentException("region",
+ throw PSTraceSource.NewArgumentException(nameof(region),
ConsoleHostRawUserInterfaceStrings.InvalidRegionErrorTemplate,
"region.Bottom", "region.Top");
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs
index cd455c0f9..9449669ab 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePrompt.cs
@@ -97,12 +97,12 @@ namespace Microsoft.PowerShell
if (descriptions == null)
{
- throw PSTraceSource.NewArgumentNullException("descriptions");
+ throw PSTraceSource.NewArgumentNullException(nameof(descriptions));
}
if (descriptions.Count < 1)
{
- throw PSTraceSource.NewArgumentException("descriptions",
+ throw PSTraceSource.NewArgumentException(nameof(descriptions),
ConsoleHostUserInterfaceStrings.PromptEmptyDescriptionsErrorTemplate, "descriptions");
}
@@ -139,7 +139,7 @@ namespace Microsoft.PowerShell
descIndex++;
if (desc == null)
{
- throw PSTraceSource.NewArgumentException("descriptions",
+ throw PSTraceSource.NewArgumentException(nameof(descriptions),
ConsoleHostUserInterfaceStrings.NullErrorTemplate,
string.Format(CultureInfo.InvariantCulture, "descriptions[{0}]", descIndex));
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs
index 1988104db..70163c865 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterfacePromptForChoice.cs
@@ -46,18 +46,18 @@ namespace Microsoft.PowerShell
if (choices == null)
{
- throw PSTraceSource.NewArgumentNullException("choices");
+ throw PSTraceSource.NewArgumentNullException(nameof(choices));
}
if (choices.Count == 0)
{
- throw PSTraceSource.NewArgumentException("choices",
+ throw PSTraceSource.NewArgumentException(nameof(choices),
ConsoleHostUserInterfaceStrings.EmptyChoicesErrorTemplate, "choices");
}
if ((defaultChoice < -1) || (defaultChoice >= choices.Count))
{
- throw PSTraceSource.NewArgumentOutOfRangeException("defaultChoice", defaultChoice,
+ throw PSTraceSource.NewArgumentOutOfRangeException(nameof(defaultChoice), defaultChoice,
ConsoleHostUserInterfaceStrings.InvalidDefaultChoiceErrorTemplate, "defaultChoice", "choice");
}
@@ -175,12 +175,12 @@ namespace Microsoft.PowerShell
if (choices == null)
{
- throw PSTraceSource.NewArgumentNullException("choices");
+ throw PSTraceSource.NewArgumentNullException(nameof(choices));
}
if (choices.Count == 0)
{
- throw PSTraceSource.NewArgumentException("choices",
+ throw PSTraceSource.NewArgumentException(nameof(choices),
ConsoleHostUserInterfaceStrings.EmptyChoicesErrorTemplate, "choices");
}
diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs
index c2a13132e..55dba38d6 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs
@@ -27,7 +27,7 @@ namespace Microsoft.PowerShell
internal
ProgressPane(ConsoleHostUserInterface ui)
{
- if (ui == null) throw new ArgumentNullException("ui");
+ if (ui == null) throw new ArgumentNullException(nameof(ui));
_ui = ui;
_rawui = ui.RawUI;
}
diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs
index e01249c9b..7cfef28f7 100644
--- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs
+++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventDescriptor.cs
@@ -38,12 +38,12 @@ namespace System.Diagnostics.Eventing
{
if (id < 0)
{
- throw new ArgumentOutOfRangeException("id", DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(id), DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);
}
if (id > ushort.MaxValue)
{
- throw new ArgumentOutOfRangeException("id", string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
+ throw new ArgumentOutOfRangeException(nameof(id), string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
}
_id = (ushort)id;
@@ -55,12 +55,12 @@ namespace System.Diagnostics.Eventing
if (task < 0)
{
- throw new ArgumentOutOfRangeException("task", DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(task), DotNetEventingStrings.ArgumentOutOfRange_NeedNonNegNum);
}
if (task > ushort.MaxValue)
{
- throw new ArgumentOutOfRangeException("task", string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
+ throw new ArgumentOutOfRangeException(nameof(task), string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_NeedValidId, 1, ushort.MaxValue));
}
_task = (ushort)task;
diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs
index 05628d51f..1d2038b5b 100644
--- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs
+++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProvider.cs
@@ -435,7 +435,7 @@ namespace System.Diagnostics.Eventing
if (eventMessage == null)
{
- throw new ArgumentNullException("eventMessage");
+ throw new ArgumentNullException(nameof(eventMessage));
}
if (IsEnabled(eventLevel, eventKeywords))
@@ -619,7 +619,7 @@ namespace System.Diagnostics.Eventing
//
// too many arguments to log
//
- throw new ArgumentOutOfRangeException("eventPayload",
+ throw new ArgumentOutOfRangeException(nameof(eventPayload),
string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_MaxArgExceeded, s_etwMaxNumberArguments));
}
@@ -656,7 +656,7 @@ namespace System.Diagnostics.Eventing
}
else
{
- throw new ArgumentOutOfRangeException("eventPayload",
+ throw new ArgumentOutOfRangeException(nameof(eventPayload),
string.Format(CultureInfo.CurrentCulture, DotNetEventingStrings.ArgumentOutOfRange_MaxStringsExceeded, s_etwAPIMaxStringCount));
}
}
diff --git a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs
index 2c272226a..27b24de94 100644
--- a/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs
+++ b/src/Microsoft.PowerShell.CoreCLR.Eventing/DotNetCode/Eventing/EventProviderTraceListener.cs
@@ -70,7 +70,7 @@ namespace System.Diagnostics.Eventing
: base(name)
{
if (delimiter == null)
- throw new ArgumentNullException("delimiter");
+ throw new ArgumentNullException(nameof(delimiter));
if (delimiter.Length == 0)
throw new ArgumentException(DotNetEventingStrings.Argument_NeedNonemptyDelimiter);
diff --git a/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs b/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs
index 83e992989..8e6d5ba99 100644
--- a/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs
+++ b/src/Microsoft.PowerShell.MarkdownRender/VT100EscapeSequences.cs
@@ -287,7 +287,7 @@ namespace Microsoft.PowerShell.MarkdownRender
{
if (optionInfo == null)
{
- throw new ArgumentNullException("optionInfo");
+ throw new ArgumentNullException(nameof(optionInfo));
}
options = optionInfo;
diff --git a/src/Microsoft.PowerShell.Security/security/AclCommands.cs b/src/Microsoft.PowerShell.Security/security/AclCommands.cs
index 9cdae9175..7447318f0 100644
--- a/src/Microsoft.PowerShell.Security/security/AclCommands.cs
+++ b/src/Microsoft.PowerShell.Security/security/AclCommands.cs
@@ -178,7 +178,7 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
else
{
@@ -205,13 +205,13 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
ObjectSecurity sd = instance.BaseObject as ObjectSecurity;
if (sd == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
// Get owner
@@ -245,13 +245,13 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
ObjectSecurity sd = instance.BaseObject as ObjectSecurity;
if (sd == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
// Get Group
@@ -284,13 +284,13 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
ObjectSecurity sd = instance.BaseObject as ObjectSecurity;
if (sd == null)
{
- PSTraceSource.NewArgumentException("instance");
+ PSTraceSource.NewArgumentException(nameof(instance));
}
// Get DACL
@@ -323,13 +323,13 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
ObjectSecurity sd = instance.BaseObject as ObjectSecurity;
if (sd == null)
{
- PSTraceSource.NewArgumentException("instance");
+ PSTraceSource.NewArgumentException(nameof(instance));
}
AuthorizationRuleCollection sacl;
@@ -585,13 +585,13 @@ namespace Microsoft.PowerShell.Commands
{
if (instance == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
ObjectSecurity sd = instance.BaseObject as ObjectSecurity;
if (sd == null)
{
- throw PSTraceSource.NewArgumentNullException("instance");
+ throw PSTraceSource.NewArgumentNullException(nameof(instance));
}
string sddl = sd.GetSecurityDescriptorSddlForm(AccessControlSections.All);
diff --git a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
index 7bdb82865..cde06e0ed 100644
--- a/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
+++ b/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs
@@ -605,7 +605,7 @@ namespace Microsoft.PowerShell.Commands
X509StoreLocation user =
new X509StoreLocation(StoreLocation.CurrentUser);
s_storeLocations.Add(user);
- AddItemToCache(StoreLocation.CurrentUser.ToString(),
+ AddItemToCache(nameof(StoreLocation.CurrentUser),
user);
//
@@ -614,7 +614,7 @@ namespace Microsoft.PowerShell.Commands
X509StoreLocation machine =
new X509StoreLocation(StoreLocation.LocalMachine);
s_storeLocations.Add(machine);
- AddItemToCache(StoreLocation.LocalMachine.ToString(),
+ AddItemToCache(nameof(StoreLocation.LocalMachine),
machine);
AddItemToCache(string.Empty, s_storeLocations);
@@ -1324,7 +1324,7 @@ namespace Microsoft.PowerShell.Commands
if (string.IsNullOrEmpty(path))
{
- throw PSTraceSource.NewArgumentException("path");
+ throw PSTraceSource.NewArgumentException(nameof(path));
}
// Normalize the path
diff --git a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs
index ae9004f8d..91a3e8e3a 100644
--- a/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs
+++ b/src/Microsoft.PowerShell.Security/security/SignatureCommands.cs
@@ -555,7 +555,7 @@ namespace Microsoft.PowerShell.Commands
System.Globalization.CultureInfo.CurrentCulture,
UtilsStrings.FileSmallerThan4Bytes, filePath);
- PSArgumentException e = new PSArgumentException(message, "filePath");
+ PSArgumentException e = new PSArgumentException(message, nameof(filePath));
ErrorRecord er = SecurityUtils.CreateInvalidArgumentErrorRecord(
e,
"SignatureCommandsBaseFileSmallerThan4Bytes"
diff --git a/src/Microsoft.WSMan.Management/CurrentConfigurations.cs b/src/Microsoft.WSMan.Management/CurrentConfigurations.cs
index 42709bc83..01ba71f68 100644
--- a/src/Microsoft.WSMan.Management/CurrentConfigurations.cs
+++ b/src/Microsoft.WSMan.Management/CurrentConfigurations.cs
@@ -63,7 +63,7 @@ namespace Microsoft.WSMan.Management
{
if (serverSession == null)
{
- throw new ArgumentNullException("serverSession");
+ throw new ArgumentNullException(nameof(serverSession));
}
this.rootDocument = new XmlDocument();
@@ -81,7 +81,7 @@ namespace Microsoft.WSMan.Management
{
if (string.IsNullOrEmpty(responseOfGet))
{
- throw new ArgumentNullException("responseOfGet");
+ throw new ArgumentNullException(nameof(responseOfGet));
}
this.rootDocument.LoadXml(responseOfGet);
@@ -103,7 +103,7 @@ namespace Microsoft.WSMan.Management
{
if (string.IsNullOrEmpty(resourceUri))
{
- throw new ArgumentNullException("resourceUri");
+ throw new ArgumentNullException(nameof(resourceUri));
}
this.serverSession.Put(resourceUri, this.rootDocument.InnerXml, 0);
@@ -119,7 +119,7 @@ namespace Microsoft.WSMan.Management
{
if (pathToNodeFromRoot == null)
{
- throw new ArgumentNullException("pathToNodeFromRoot");
+ throw new ArgumentNullException(nameof(pathToNodeFromRoot));
}
XmlNode nodeToRemove =
@@ -136,7 +136,7 @@ namespace Microsoft.WSMan.Management
}
else
{
- throw new ArgumentException("Node is not present in the XML, Please give valid XPath", "pathToNodeFromRoot");
+ throw new ArgumentException("Node is not present in the XML, Please give valid XPath", nameof(pathToNodeFromRoot));
}
}
@@ -152,17 +152,17 @@ namespace Microsoft.WSMan.Management
{
if (pathToNodeFromRoot == null)
{
- throw new ArgumentNullException("pathToNodeFromRoot");
+ throw new ArgumentNullException(nameof(pathToNodeFromRoot));
}
if (string.IsNullOrEmpty(configurationName))
{
- throw new ArgumentNullException("configurationName");
+ throw new ArgumentNullException(nameof(configurationName));
}
if (configurationValue == null)
{
- throw new ArgumentNullException("configurationValue");
+ throw new ArgumentNullException(nameof(configurationValue));
}
XmlNode nodeToUpdate =
@@ -197,7 +197,7 @@ namespace Microsoft.WSMan.Management
{
if (pathFromRoot == null)
{
- throw new ArgumentNullException("pathFromRoot");
+ throw new ArgumentNullException(nameof(pathFromRoot));
}
XmlNode requiredNode =
diff --git a/src/Microsoft.WSMan.Management/WsManHelper.cs b/src/Microsoft.WSMan.Management/WsManHelper.cs
index 32e1f88e5..23593d686 100644
--- a/src/Microsoft.WSMan.Management/WsManHelper.cs
+++ b/src/Microsoft.WSMan.Management/WsManHelper.cs
@@ -180,12 +180,12 @@ namespace Microsoft.WSMan.Management
{
if (resourceManager == null)
{
- throw new ArgumentNullException("resourceManager");
+ throw new ArgumentNullException(nameof(resourceManager));
}
if (string.IsNullOrEmpty(resourceName))
{
- throw new ArgumentNullException("resourceName");
+ throw new ArgumentNullException(nameof(resourceName));
}
string template = resourceManager.GetString(resourceName);
@@ -478,7 +478,7 @@ namespace Microsoft.WSMan.Management
if (string.IsNullOrEmpty(entry.Key.ToString()))
{
// XmlNode newnode = xmlfile.CreateNode(XmlNodeType.Attribute, ATTR_NIL_NAME, NS_XSI_URI);
- XmlAttribute newnode = xmlfile.CreateAttribute(XmlNodeType.Attribute.ToString(), ATTR_NIL_NAME, NS_XSI_URI);
+ XmlAttribute newnode = xmlfile.CreateAttribute(nameof(XmlNodeType.Attribute), ATTR_NIL_NAME, NS_XSI_URI);
newnode.Value = "true";
node.Attributes.Append(newnode);
// (newnode.Attributes.Item(0).FirstChild );
diff --git a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs
index fafd27c2c..ef210304a 100644
--- a/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs
+++ b/src/System.Management.Automation/CoreCLR/CorePsAssemblyLoadContext.cs
@@ -78,7 +78,7 @@ namespace System.Management.Automation
if (!Directory.Exists(basePath))
{
string message = string.Format(CultureInfo.CurrentCulture, BaseFolderDoesNotExist, basePath);
- throw new ArgumentException(message, "basePaths");
+ throw new ArgumentException(message, nameof(basePaths));
}
_probingPaths[i] = basePath.Trim();
@@ -582,7 +582,7 @@ namespace System.Management.Automation
public static void SetPowerShellAssemblyLoadContext([MarshalAs(UnmanagedType.LPWStr)]string basePaths)
{
if (string.IsNullOrEmpty(basePaths))
- throw new ArgumentNullException("basePaths");
+ throw new ArgumentNullException(nameof(basePaths));
PowerShellAssemblyLoadContext.InitializeSingleton(basePaths);
}
diff --git a/src/System.Management.Automation/DscSupport/CimDSCParser.cs b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
index c5fd73bf5..908025c14 100644
--- a/src/System.Management.Automation/DscSupport/CimDSCParser.cs
+++ b/src/System.Management.Automation/DscSupport/CimDSCParser.cs
@@ -298,7 +298,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
if (engineIntrinsics == null)
{
- throw PSTraceSource.NewArgumentNullException("engineIntrinsics");
+ throw PSTraceSource.NewArgumentNullException(nameof(engineIntrinsics));
}
return PsUtils.EvaluatePowerShellDataFileAsModuleManifest(
@@ -372,7 +372,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration
{
if (string.IsNullOrEmpty(fullFilePath))
{
- throw PSTraceSource.NewArgumentNullException("fullFilePath");
+ throw PSTraceSource.NewArgumentNullException(nameof(fullFilePath));
}
if (!File.Exists(fullFilePath))
@@ -951,7 +951,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (string.IsNullOrEmpty(path))
{
- throw PSTraceSource.NewArgumentNullException("path");
+ throw PSTraceSource.NewArgumentNullException(nameof(path));
}
s_tracer.WriteLine("DSC ClassCache: importing file: {0}", path);
@@ -1179,7 +1179,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (string.IsNullOrWhiteSpace(fileName))
{
- throw PSTraceSource.NewArgumentNullException("fileName");
+ throw PSTraceSource.NewArgumentNullException(nameof(fileName));
}
List listCimClass;
@@ -1197,7 +1197,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (string.IsNullOrWhiteSpace(moduleName))
{
- throw PSTraceSource.NewArgumentNullException("moduleName");
+ throw PSTraceSource.NewArgumentNullException(nameof(moduleName));
}
var moduleFileName = moduleName + ".schema.mof";
@@ -1214,7 +1214,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (string.IsNullOrEmpty(path))
{
- throw PSTraceSource.NewArgumentNullException("path");
+ throw PSTraceSource.NewArgumentNullException(nameof(path));
}
var parser = new Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser(MyClassCallback);
@@ -1256,7 +1256,7 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (string.IsNullOrEmpty(instanceText))
{
- throw PSTraceSource.NewArgumentNullException("instanceText");
+ throw PSTraceSource.NewArgumentNullException(nameof(instanceText));
}
var parser = new Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser(MyClassCallback);
@@ -3220,12 +3220,12 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (module == null)
{
- throw PSTraceSource.NewArgumentNullException("module");
+ throw PSTraceSource.NewArgumentNullException(nameof(module));
}
if (resourceName == null)
{
- throw PSTraceSource.NewArgumentNullException("resourceName");
+ throw PSTraceSource.NewArgumentNullException(nameof(resourceName));
}
string dscResourcesPath = Path.Combine(module.ModuleBase, "DscResources");
@@ -3332,12 +3332,12 @@ namespace Microsoft.PowerShell.DesiredStateConfiguration.Internal
{
if (module == null)
{
- throw PSTraceSource.NewArgumentNullException("module");
+ throw PSTraceSource.NewArgumentNullException(nameof(module));
}
if (resourceName == null)
{
- throw PSTraceSource.NewArgumentNullException("resourceName");
+ throw PSTraceSource.NewArgumentNullException(nameof(resourceName));
}
schemaFilePath = Path.Combine(Path.Combine(Path.Combine(module.ModuleBase, "DscResources"), resourceName), resourceName + ".Schema.psm1");
diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseCommand.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseCommand.cs
index 6574914c3..e03b4ae61 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/BaseCommand.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/BaseCommand.cs
@@ -18,7 +18,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal TerminatingErrorContext(PSCmdlet command)
{
if (command == null)
- throw PSTraceSource.NewArgumentNullException("command");
+ throw PSTraceSource.NewArgumentNullException(nameof(command));
_command = command;
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommandParameters.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommandParameters.cs
index 26e62bc8a..cdd60637a 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommandParameters.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/BaseFormattingCommandParameters.cs
@@ -171,7 +171,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (val == null)
{
- throw PSTraceSource.NewArgumentNullException("val");
+ throw PSTraceSource.NewArgumentNullException(nameof(val));
}
// need to check the type:
@@ -201,7 +201,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
return ex;
}
- PSTraceSource.NewArgumentException("val");
+ PSTraceSource.NewArgumentException(nameof(val));
return null;
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs
index 5025fc6c3..4467744a6 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/BaseOutputtingCommand.cs
@@ -510,7 +510,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
// we assume FormatEntryData as a standard wrapper
if (fed == null)
{
- PSTraceSource.NewArgumentNullException("fed");
+ PSTraceSource.NewArgumentNullException(nameof(fed));
}
if (fed.formatEntryInfo == null)
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs
index da440d8f6..6b647bd09 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/FormatTable.cs
@@ -87,7 +87,7 @@ namespace System.Management.Automation.Runspaces
{
if (info == null)
{
- throw new PSArgumentNullException("info");
+ throw new PSArgumentNullException(nameof(info));
}
int errorCount = info.GetInt32("ErrorCount");
@@ -114,7 +114,7 @@ namespace System.Management.Automation.Runspaces
{
if (info == null)
{
- throw new PSArgumentNullException("info");
+ throw new PSArgumentNullException(nameof(info));
}
base.GetObjectData(info, context);
@@ -207,7 +207,7 @@ namespace System.Management.Automation.Runspaces
public void AppendFormatData(IEnumerable formatData)
{
if (formatData == null)
- throw PSTraceSource.NewArgumentNullException("formatData");
+ throw PSTraceSource.NewArgumentNullException(nameof(formatData));
_formatDBMgr.AddFormatData(formatData, false);
}
@@ -226,7 +226,7 @@ namespace System.Management.Automation.Runspaces
public void PrependFormatData(IEnumerable formatData)
{
if (formatData == null)
- throw PSTraceSource.NewArgumentNullException("formatData");
+ throw PSTraceSource.NewArgumentNullException(nameof(formatData));
_formatDBMgr.AddFormatData(formatData, true);
}
@@ -253,7 +253,7 @@ namespace System.Management.Automation.Runspaces
{
if (formatFiles == null)
{
- throw PSTraceSource.NewArgumentNullException("formatFiles");
+ throw PSTraceSource.NewArgumentNullException(nameof(formatFiles));
}
_formatDBMgr = new TypeInfoDataBaseManager(formatFiles, true, authorizationManager, host);
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs
index 50f687c46..64af2244f 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs
@@ -376,22 +376,22 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (control is TableControlBody)
{
- return FormatShape.Table.ToString();
+ return nameof(FormatShape.Table);
}
if (control is ListControlBody)
{
- return FormatShape.List.ToString();
+ return nameof(FormatShape.List);
}
if (control is WideControlBody)
{
- return FormatShape.Wide.ToString();
+ return nameof(FormatShape.Wide);
}
if (control is ComplexControlBody)
{
- return FormatShape.Complex.ToString();
+ return nameof(FormatShape.Complex);
}
return string.Empty;
@@ -635,9 +635,9 @@ namespace System.Management.Automation
public ExtendedTypeDefinition(string typeName, IEnumerable viewDefinitions) : this()
{
if (string.IsNullOrEmpty(typeName))
- throw PSTraceSource.NewArgumentNullException("typeName");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeName));
if (viewDefinitions == null)
- throw PSTraceSource.NewArgumentNullException("viewDefinitions");
+ throw PSTraceSource.NewArgumentNullException(nameof(viewDefinitions));
TypeNames.Add(typeName);
foreach (FormatViewDefinition definition in viewDefinitions)
@@ -653,7 +653,7 @@ namespace System.Management.Automation
public ExtendedTypeDefinition(string typeName) : this()
{
if (string.IsNullOrEmpty(typeName))
- throw PSTraceSource.NewArgumentNullException("typeName");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeName));
TypeNames.Add(typeName);
}
@@ -691,9 +691,9 @@ namespace System.Management.Automation
public FormatViewDefinition(string name, PSControl control)
{
if (string.IsNullOrEmpty(name))
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
if (control == null)
- throw PSTraceSource.NewArgumentNullException("control");
+ throw PSTraceSource.NewArgumentNullException(nameof(control));
Name = name;
Control = control;
@@ -800,7 +800,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(value))
if (value == null || type == DisplayEntryValueType.Property)
- throw PSTraceSource.NewArgumentNullException("value");
+ throw PSTraceSource.NewArgumentNullException(nameof(value));
Value = value;
ValueType = type;
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Complex.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Complex.cs
index 6e11d2164..d3290c187 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Complex.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Complex.cs
@@ -420,13 +420,13 @@ namespace System.Management.Automation
// Mutually exclusive
if (leftIndent != 0 && rightIndent != 0)
{
- throw PSTraceSource.NewArgumentException("leftIndent");
+ throw PSTraceSource.NewArgumentException(nameof(leftIndent));
}
// Mutually exclusive
if (firstLineHanging != 0 && firstLineIndent != 0)
{
- throw PSTraceSource.NewArgumentException("firstLineHanging");
+ throw PSTraceSource.NewArgumentException(nameof(firstLineHanging));
}
var frame = new CustomItemFrame
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs
index 06a330c02..6025acfff 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_List.cs
@@ -173,7 +173,7 @@ namespace System.Management.Automation
: this()
{
if (entries == null)
- throw PSTraceSource.NewArgumentNullException("entries");
+ throw PSTraceSource.NewArgumentNullException(nameof(entries));
foreach (ListControlEntry entry in entries)
{
this.Entries.Add(entry);
@@ -242,7 +242,7 @@ namespace System.Management.Automation
: this()
{
if (listItems == null)
- throw PSTraceSource.NewArgumentNullException("listItems");
+ throw PSTraceSource.NewArgumentNullException(nameof(listItems));
foreach (ListControlEntryItem item in listItems)
{
this.Items.Add(item);
@@ -253,9 +253,9 @@ namespace System.Management.Automation
public ListControlEntry(IEnumerable listItems, IEnumerable selectedBy)
{
if (listItems == null)
- throw PSTraceSource.NewArgumentNullException("listItems");
+ throw PSTraceSource.NewArgumentNullException(nameof(listItems));
if (selectedBy == null)
- throw PSTraceSource.NewArgumentNullException("selectedBy");
+ throw PSTraceSource.NewArgumentNullException(nameof(selectedBy));
EntrySelectedBy = new EntrySelectedBy { TypeNames = new List(selectedBy) };
foreach (ListControlEntryItem item in listItems)
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs
index 2afbab8a7..ddd8446b0 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Table.cs
@@ -306,7 +306,7 @@ namespace System.Management.Automation
if (tableControlRow == null)
throw PSTraceSource.NewArgumentNullException("tableControlRows");
if (tableControlColumnHeaders == null)
- throw PSTraceSource.NewArgumentNullException("tableControlColumnHeaders");
+ throw PSTraceSource.NewArgumentNullException(nameof(tableControlColumnHeaders));
this.Rows.Add(tableControlRow);
foreach (TableControlColumnHeader header in tableControlColumnHeaders)
@@ -355,7 +355,7 @@ namespace System.Management.Automation
public TableControlColumnHeader(string label, int width, Alignment alignment)
{
if (width < 0)
- throw PSTraceSource.NewArgumentOutOfRangeException("width", width);
+ throw PSTraceSource.NewArgumentOutOfRangeException(nameof(width), width);
this.Label = label;
this.Width = width;
@@ -467,7 +467,7 @@ namespace System.Management.Automation
public TableControlRow(IEnumerable columns) : this()
{
if (columns == null)
- throw PSTraceSource.NewArgumentNullException("columns");
+ throw PSTraceSource.NewArgumentNullException(nameof(columns));
foreach (TableControlColumn column in columns)
{
Columns.Add(column);
@@ -507,7 +507,7 @@ namespace System.Management.Automation
private TableRowDefinitionBuilder AddItem(string value, DisplayEntryValueType entryType, Alignment alignment, string format)
{
if (string.IsNullOrEmpty(value))
- throw PSTraceSource.NewArgumentException("value");
+ throw PSTraceSource.NewArgumentException(nameof(value));
var tableControlColumn = new TableControlColumn(alignment, new DisplayEntry(value, entryType))
{
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs
index 2b4dd913f..0e140fa5e 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/displayDescriptionData_Wide.cs
@@ -145,7 +145,7 @@ namespace System.Management.Automation
public WideControl(IEnumerable wideEntries) : this()
{
if (wideEntries == null)
- throw PSTraceSource.NewArgumentNullException("wideEntries");
+ throw PSTraceSource.NewArgumentNullException(nameof(wideEntries));
foreach (WideControlEntryItem entryItem in wideEntries)
{
@@ -157,7 +157,7 @@ namespace System.Management.Automation
public WideControl(IEnumerable wideEntries, uint columns) : this()
{
if (wideEntries == null)
- throw PSTraceSource.NewArgumentNullException("wideEntries");
+ throw PSTraceSource.NewArgumentNullException(nameof(wideEntries));
foreach (WideControlEntryItem entryItem in wideEntries)
{
@@ -224,7 +224,7 @@ namespace System.Management.Automation
public WideControlEntryItem(DisplayEntry entry) : this()
{
if (entry == null)
- throw PSTraceSource.NewArgumentNullException("entry");
+ throw PSTraceSource.NewArgumentNullException(nameof(entry));
this.DisplayEntry = entry;
}
@@ -234,9 +234,9 @@ namespace System.Management.Automation
public WideControlEntryItem(DisplayEntry entry, IEnumerable selectedBy) : this()
{
if (entry == null)
- throw PSTraceSource.NewArgumentNullException("entry");
+ throw PSTraceSource.NewArgumentNullException(nameof(entry));
if (selectedBy == null)
- throw PSTraceSource.NewArgumentNullException("selectedBy");
+ throw PSTraceSource.NewArgumentNullException(nameof(selectedBy));
this.DisplayEntry = entry;
this.EntrySelectedBy = EntrySelectedBy.Get(selectedBy, null);
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs
index d03d2eb1a..21a180baf 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataManager.cs
@@ -79,7 +79,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (string.IsNullOrEmpty(formatFile) || (!Path.IsPathRooted(formatFile)))
{
- throw PSTraceSource.NewArgumentException("formatFiles", FormatAndOutXmlLoadingStrings.FormatFileNotRooted, formatFile);
+ throw PSTraceSource.NewArgumentException(nameof(formatFiles), FormatAndOutXmlLoadingStrings.FormatFileNotRooted, formatFile);
}
PSSnapInTypeAndFormatErrors fileToLoad = new PSSnapInTypeAndFormatErrors(string.Empty, formatFile);
@@ -122,7 +122,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (string.IsNullOrEmpty(formatFile) || (!Path.IsPathRooted(formatFile)))
{
- throw PSTraceSource.NewArgumentException("formatFile", FormatAndOutXmlLoadingStrings.FormatFileNotRooted, formatFile);
+ throw PSTraceSource.NewArgumentException(nameof(formatFile), FormatAndOutXmlLoadingStrings.FormatFileNotRooted, formatFile);
}
lock (_formatFileList)
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
index 82277eeeb..79bcbd61d 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs
@@ -193,16 +193,16 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
bool preValidated)
{
if (info == null)
- throw PSTraceSource.NewArgumentNullException("info");
+ throw PSTraceSource.NewArgumentNullException(nameof(info));
if (info.filePath == null)
throw PSTraceSource.NewArgumentNullException("info.filePath");
if (db == null)
- throw PSTraceSource.NewArgumentNullException("db");
+ throw PSTraceSource.NewArgumentNullException(nameof(db));
if (expressionFactory == null)
- throw PSTraceSource.NewArgumentNullException("expressionFactory");
+ throw PSTraceSource.NewArgumentNullException(nameof(expressionFactory));
if (SecuritySupport.IsProductBinary(info.filePath))
{
@@ -288,13 +288,13 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
bool isForHelp)
{
if (typeDefinition == null)
- throw PSTraceSource.NewArgumentNullException("typeDefinition");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeDefinition));
if (typeDefinition.TypeName == null)
throw PSTraceSource.NewArgumentNullException("typeDefinition.TypeName");
if (db == null)
- throw PSTraceSource.NewArgumentNullException("db");
+ throw PSTraceSource.NewArgumentNullException(nameof(db));
if (expressionFactory == null)
- throw PSTraceSource.NewArgumentNullException("expressionFactory");
+ throw PSTraceSource.NewArgumentNullException(nameof(expressionFactory));
this.expressionFactory = expressionFactory;
this.ReportTrace("loading ExtendedTypeDefinition started");
@@ -337,10 +337,10 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
private void LoadData(XmlDocument doc, TypeInfoDataBase db)
{
if (doc == null)
- throw PSTraceSource.NewArgumentNullException("doc");
+ throw PSTraceSource.NewArgumentNullException(nameof(doc));
if (db == null)
- throw PSTraceSource.NewArgumentNullException("db");
+ throw PSTraceSource.NewArgumentNullException(nameof(db));
// create a new instance of the database to be loaded
XmlElement documentElement = doc.DocumentElement;
@@ -428,7 +428,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
throw PSTraceSource.NewArgumentNullException("viewDefinition");
if (db == null)
- throw PSTraceSource.NewArgumentNullException("db");
+ throw PSTraceSource.NewArgumentNullException(nameof(db));
int viewIndex = 0;
foreach (FormatViewDefinition formatView in typeDefinition.FormatViewDefinition)
@@ -2054,7 +2054,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal bool ProcessExpressionDirectives(XmlNode containerNode, List unprocessedNodes)
{
if (containerNode == null)
- throw PSTraceSource.NewArgumentNullException("containerNode");
+ throw PSTraceSource.NewArgumentNullException(nameof(containerNode));
string formatString = null;
TextToken textToken = null;
diff --git a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs
index 66d819a0f..34702849d 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader_Views.cs
@@ -201,10 +201,10 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
private bool LoadCommonViewData(XmlNode viewNode, ViewDefinition view, List unprocessedNodes)
{
if (viewNode == null)
- throw PSTraceSource.NewArgumentNullException("viewNode");
+ throw PSTraceSource.NewArgumentNullException(nameof(viewNode));
if (view == null)
- throw PSTraceSource.NewArgumentNullException("view");
+ throw PSTraceSource.NewArgumentNullException(nameof(view));
// set loading information
view.loadingInfo = this.LoadingInfo;
diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs
index eeacaad45..c9cd80bbe 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Complex.cs
@@ -93,7 +93,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (control == null)
{
- throw PSTraceSource.NewArgumentNullException("control");
+ throw PSTraceSource.NewArgumentNullException(nameof(control));
}
ExecuteFormatControl(new TraversalInfo(0, maxTreeDepth), control,
@@ -190,7 +190,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (so == null)
{
- throw PSTraceSource.NewArgumentNullException("so");
+ throw PSTraceSource.NewArgumentNullException(nameof(so));
}
// guard against infinite loop
diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs b/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
index dd0dbf473..3e8c32039 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/FormattingObjectsDeserializer.cs
@@ -142,7 +142,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
string msg = StringUtil.Format(FormatAndOut_format_xxx.FOD_ClassIdInvalid, classId);
ErrorRecord errorRecord = new ErrorRecord(
- PSTraceSource.NewArgumentException("classId"),
+ PSTraceSource.NewArgumentException(nameof(classId)),
errorId,
ErrorCategory.InvalidData,
obj);
@@ -217,7 +217,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
string msg = StringUtil.Format(FormatAndOut_format_xxx.FOD_RecursiveProperty, property);
ErrorRecord errorRecord = new ErrorRecord(
- PSTraceSource.NewArgumentException("property"),
+ PSTraceSource.NewArgumentException(nameof(property)),
"FormatObjectDeserializerRecursiveProperty",
ErrorCategory.InvalidData,
so);
@@ -247,7 +247,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
string msg = StringUtil.Format(FormatAndOut_format_xxx.FOD_InvalidPropertyType, t.Name, property);
ErrorRecord errorRecord = new ErrorRecord(
- PSTraceSource.NewArgumentException("property"),
+ PSTraceSource.NewArgumentException(nameof(property)),
"FormatObjectDeserializerInvalidPropertyType",
ErrorCategory.InvalidData,
so);
@@ -392,7 +392,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (so == null)
{
- throw PSTraceSource.NewArgumentNullException("so");
+ throw PSTraceSource.NewArgumentNullException(nameof(so));
}
// look for the property that defines the type of object
@@ -421,7 +421,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
Func ctor;
if (!s_constructors.TryGetValue(clsid, out ctor))
{
- CreateInstanceError(PSTraceSource.NewArgumentException("clsid"), clsid, deserializer);
+ CreateInstanceError(PSTraceSource.NewArgumentException(nameof(clsid)), clsid, deserializer);
return null;
}
@@ -504,7 +504,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
{
if (lst == null)
{
- throw PSTraceSource.NewArgumentNullException("lst");
+ throw PSTraceSource.NewArgumentNullException(nameof(lst));
}
object memberRaw = FormatObjectDeserializer.GetProperty(so, property);
diff --git a/src/System.Management.Automation/FormatAndOutput/common/ILineOutput.cs b/src/System.Management.Automation/FormatAndOutput/common/ILineOutput.cs
index 03cd5a1a2..09432253e 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/ILineOutput.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/ILineOutput.cs
@@ -282,9 +282,9 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal WriteLineHelper(bool lineWrap, WriteCallback wlc, WriteCallback wc, DisplayCells displayCells)
{
if (wlc == null)
- throw PSTraceSource.NewArgumentNullException("wlc");
+ throw PSTraceSource.NewArgumentNullException(nameof(wlc));
if (displayCells == null)
- throw PSTraceSource.NewArgumentNullException("displayCells");
+ throw PSTraceSource.NewArgumentNullException(nameof(displayCells));
_displayCells = displayCells;
_writeLineCall = wlc;
@@ -474,7 +474,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
: base(culture)
{
if (writeCall == null)
- throw PSTraceSource.NewArgumentNullException("writeCall");
+ throw PSTraceSource.NewArgumentNullException(nameof(writeCall));
_writeCall = writeCall;
}
diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs
index 3de036f35..15aecfacc 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameter.cs
@@ -140,7 +140,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal HashtableEntryDefinition MatchEntry(string keyName, TerminatingErrorContext invocationContext)
{
if (string.IsNullOrEmpty(keyName))
- PSTraceSource.NewArgumentNullException("keyName");
+ PSTraceSource.NewArgumentNullException(nameof(keyName));
HashtableEntryDefinition matchingEntry = null;
for (int k = 0; k < this.hashEntries.Count; k++)
diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs
index 25e7fd612..7042bf85d 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/MshParameterAssociation.cs
@@ -23,7 +23,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal MshResolvedExpressionParameterAssociation(MshParameter parameter, PSPropertyExpression expression)
{
if (expression == null)
- throw PSTraceSource.NewArgumentNullException("expression");
+ throw PSTraceSource.NewArgumentNullException(nameof(expression));
OriginatingParameter = parameter;
ResolvedExpression = expression;
diff --git a/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs b/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
index 37408c2e7..bf3acfab2 100644
--- a/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
+++ b/src/System.Management.Automation/FormatAndOutput/common/Utilities/Mshexpression.cs
@@ -71,7 +71,7 @@ namespace Microsoft.PowerShell.Commands
{
if (string.IsNullOrEmpty(s))
{
- throw PSTraceSource.NewArgumentNullException("s");
+ throw PSTraceSource.NewArgumentNullException(nameof(s));
}
_stringValue = s;
@@ -87,7 +87,7 @@ namespace Microsoft.PowerShell.Commands
{
if (scriptBlock == null)
{
- throw PSTraceSource.NewArgumentNullException("scriptBlock");
+ throw PSTraceSource.NewArgumentNullException(nameof(scriptBlock));
}
Script = scriptBlock;
diff --git a/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs b/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs
index 0b2dfe2f7..b0fe26cfd 100644
--- a/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs
+++ b/src/System.Management.Automation/FormatAndOutput/out-console/ConsoleLineOutput.cs
@@ -252,9 +252,9 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal ConsoleLineOutput(PSHostUserInterface hostConsole, bool paging, TerminatingErrorContext errorContext)
{
if (hostConsole == null)
- throw PSTraceSource.NewArgumentNullException("hostConsole");
+ throw PSTraceSource.NewArgumentNullException(nameof(hostConsole));
if (errorContext == null)
- throw PSTraceSource.NewArgumentNullException("errorContext");
+ throw PSTraceSource.NewArgumentNullException(nameof(errorContext));
_console = hostConsole;
_errorContext = errorContext;
@@ -474,7 +474,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
internal PromptHandler(string s, ConsoleLineOutput cmdlet)
{
if (string.IsNullOrEmpty(s))
- throw PSTraceSource.NewArgumentNullException("s");
+ throw PSTraceSource.NewArgumentNullException(nameof(s));
_promptString = s;
_callingCmdlet = cmdlet;
diff --git a/src/System.Management.Automation/cimSupport/cmdletization/MethodInvocationInfo.cs b/src/System.Management.Automation/cimSupport/cmdletization/MethodInvocationInfo.cs
index 44cda85e5..81a4c3306 100644
--- a/src/System.Management.Automation/cimSupport/cmdletization/MethodInvocationInfo.cs
+++ b/src/System.Management.Automation/cimSupport/cmdletization/MethodInvocationInfo.cs
@@ -21,8 +21,8 @@ namespace Microsoft.PowerShell.Cmdletization
/// Return value of the method (ok to pass null if the method doesn't return anything).
public MethodInvocationInfo(string name, IEnumerable parameters, MethodParameter returnValue)
{
- if (name == null) throw new ArgumentNullException("name");
- if (parameters == null) throw new ArgumentNullException("parameters");
+ if (name == null) throw new ArgumentNullException(nameof(name));
+ if (parameters == null) throw new ArgumentNullException(nameof(parameters));
// returnValue can be null
MethodName = name;
diff --git a/src/System.Management.Automation/cimSupport/cmdletization/ObjectModelWrapper.cs b/src/System.Management.Automation/cimSupport/cmdletization/ObjectModelWrapper.cs
index 4851bf1f9..289ad0c3a 100644
--- a/src/System.Management.Automation/cimSupport/cmdletization/ObjectModelWrapper.cs
+++ b/src/System.Management.Automation/cimSupport/cmdletization/ObjectModelWrapper.cs
@@ -19,22 +19,22 @@ namespace Microsoft.PowerShell.Cmdletization
{
if (cmdlet == null)
{
- throw new ArgumentNullException("cmdlet");
+ throw new ArgumentNullException(nameof(cmdlet));
}
if (string.IsNullOrEmpty(className))
{
- throw new ArgumentNullException("className");
+ throw new ArgumentNullException(nameof(className));
}
if (classVersion == null) // possible and ok to have classVersion==string.Empty
{
- throw new ArgumentNullException("classVersion");
+ throw new ArgumentNullException(nameof(classVersion));
}
if (privateData == null)
{
- throw new ArgumentNullException("privateData");
+ throw new ArgumentNullException(nameof(privateData));
}
_cmdlet = cmdlet;
diff --git a/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs b/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs
index 47fb00d2e..3a7e29a4c 100644
--- a/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs
+++ b/src/System.Management.Automation/cimSupport/other/ciminstancetypeadapter.cs
@@ -105,7 +105,7 @@ namespace Microsoft.PowerShell.Cim
{
if (propertyName == null)
{
- throw new PSArgumentNullException("propertyName");
+ throw new PSArgumentNullException(nameof(propertyName));
}
// baseObject should never be null
@@ -199,7 +199,7 @@ namespace Microsoft.PowerShell.Cim
{
if (adaptedProperty == null)
{
- throw new ArgumentNullException("adaptedProperty");
+ throw new ArgumentNullException(nameof(adaptedProperty));
}
CimProperty cimProperty = adaptedProperty.Tag as CimProperty;
@@ -213,7 +213,7 @@ namespace Microsoft.PowerShell.Cim
return ToStringCodeMethods.Type(typeof(string));
}
- throw new ArgumentNullException("adaptedProperty");
+ throw new ArgumentNullException(nameof(adaptedProperty));
}
///
@@ -224,7 +224,7 @@ namespace Microsoft.PowerShell.Cim
{
if (adaptedProperty == null)
{
- throw new ArgumentNullException("adaptedProperty");
+ throw new ArgumentNullException(nameof(adaptedProperty));
}
CimProperty cimProperty = adaptedProperty.Tag as CimProperty;
@@ -239,7 +239,7 @@ namespace Microsoft.PowerShell.Cim
return cimInstance.GetCimSessionComputerName();
}
- throw new ArgumentNullException("adaptedProperty");
+ throw new ArgumentNullException(nameof(adaptedProperty));
}
private void AddTypeNameHierarchy(IList typeNamesWithNamespace, IList typeNamesWithoutNamespace, string namespaceName, string className)
@@ -288,7 +288,7 @@ namespace Microsoft.PowerShell.Cim
var cimInstance = baseObject as CimInstance;
if (cimInstance == null)
{
- throw new ArgumentNullException("baseObject");
+ throw new ArgumentNullException(nameof(baseObject));
}
var typeNamesWithNamespace = new List();
@@ -381,7 +381,7 @@ namespace Microsoft.PowerShell.Cim
{
if (adaptedProperty == null)
{
- throw new ArgumentNullException("adaptedProperty");
+ throw new ArgumentNullException(nameof(adaptedProperty));
}
if (!IsSettable(adaptedProperty))
diff --git a/src/System.Management.Automation/engine/ApplicationInfo.cs b/src/System.Management.Automation/engine/ApplicationInfo.cs
index 308cea39b..9e785aee9 100644
--- a/src/System.Management.Automation/engine/ApplicationInfo.cs
+++ b/src/System.Management.Automation/engine/ApplicationInfo.cs
@@ -39,12 +39,12 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(path))
{
- throw PSTraceSource.NewArgumentException("path");
+ throw PSTraceSource.NewArgumentException(nameof(path));
}
if (context == null)
{
- throw PSTraceSource.NewArgumentNullException("context");
+ throw PSTraceSource.NewArgumentNullException(nameof(context));
}
Path = path;
diff --git a/src/System.Management.Automation/engine/ChildrenCmdletProviderInterfaces.cs b/src/System.Management.Automation/engine/ChildrenCmdletProviderInterfaces.cs
index 7fafdf845..85cff4c8e 100644
--- a/src/System.Management.Automation/engine/ChildrenCmdletProviderInterfaces.cs
+++ b/src/System.Management.Automation/engine/ChildrenCmdletProviderInterfaces.cs
@@ -35,7 +35,7 @@ namespace System.Management.Automation
{
if (cmdlet == null)
{
- throw PSTraceSource.NewArgumentNullException("cmdlet");
+ throw PSTraceSource.NewArgumentNullException(nameof(cmdlet));
}
_cmdlet = cmdlet;
@@ -55,7 +55,7 @@ namespace System.Management.Automation
{
if (sessionState == null)
{
- throw PSTraceSource.NewArgumentNullException("sessionState");
+ throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}
_sessionState = sessionState;
diff --git a/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs b/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs
index 2ce58a04a..27537b216 100644
--- a/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs
+++ b/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs
@@ -38,7 +38,7 @@ namespace System.Management.Automation
{
if (cmdlet == null)
{
- throw PSTraceSource.NewArgumentNullException("cmdlet");
+ throw PSTraceSource.NewArgumentNullException(nameof(cmdlet));
}
_cmdlet = cmdlet;
@@ -59,7 +59,7 @@ namespace System.Management.Automation
{
if (sessionState == null)
{
- throw PSTraceSource.NewArgumentNullException("sessionState");
+ throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}
Item = new ItemCmdletProviderIntrinsics(sessionState);
diff --git a/src/System.Management.Automation/engine/CmdletInfo.cs b/src/System.Management.Automation/engine/CmdletInfo.cs
index 896763d9d..2861fa3a8 100644
--- a/src/System.Management.Automation/engine/CmdletInfo.cs
+++ b/src/System.Management.Automation/engine/CmdletInfo.cs
@@ -44,7 +44,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(name))
{
- throw PSTraceSource.NewArgumentException("name");
+ throw PSTraceSource.NewArgumentException(nameof(name));
}
// Get the verb and noun from the name
@@ -52,7 +52,7 @@ namespace System.Management.Automation
{
throw
PSTraceSource.NewArgumentException(
- "name",
+ nameof(name),
DiscoveryExceptions.InvalidCmdletNameFormat,
name);
}
@@ -105,12 +105,12 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(name))
{
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
}
if (implementingType == null)
{
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
}
if (!typeof(Cmdlet).IsAssignableFrom(implementingType))
@@ -123,7 +123,7 @@ namespace System.Management.Automation
{
throw
PSTraceSource.NewArgumentException(
- "name",
+ nameof(name),
DiscoveryExceptions.InvalidCmdletNameFormat,
name);
}
diff --git a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs
index 72d6ba964..069201589 100644
--- a/src/System.Management.Automation/engine/CmdletParameterBinderController.cs
+++ b/src/System.Management.Automation/engine/CmdletParameterBinderController.cs
@@ -54,12 +54,12 @@ namespace System.Management.Automation
{
if (cmdlet == null)
{
- throw PSTraceSource.NewArgumentNullException("cmdlet");
+ throw PSTraceSource.NewArgumentNullException(nameof(cmdlet));
}
if (commandMetadata == null)
{
- throw PSTraceSource.NewArgumentNullException("commandMetadata");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandMetadata));
}
this.Command = cmdlet;
@@ -4275,7 +4275,7 @@ namespace System.Management.Automation
{
if (parameters == null)
{
- throw PSTraceSource.NewArgumentNullException("parameters");
+ throw PSTraceSource.NewArgumentNullException(nameof(parameters));
}
// Get all the matching arguments from the defaultParameterValues collection
@@ -4409,7 +4409,7 @@ namespace System.Management.Automation
{
if (dictionary == null)
{
- throw PSTraceSource.NewArgumentNullException("dictionary");
+ throw PSTraceSource.NewArgumentNullException(nameof(dictionary));
}
// Contains keys that are in bad format. For every bad format key, we should write out a warning message
// the first time we encounter it, and remove it from the $PSDefaultParameterValues
@@ -4481,7 +4481,7 @@ namespace System.Management.Automation
{
if (key == null)
{
- throw PSTraceSource.NewArgumentNullException("key");
+ throw PSTraceSource.NewArgumentNullException(nameof(key));
}
var strKey = key as string;
@@ -4508,13 +4508,13 @@ namespace System.Management.Automation
{
if (key == null)
{
- throw PSTraceSource.NewArgumentNullException("key");
+ throw PSTraceSource.NewArgumentNullException(nameof(key));
}
var strKey = key as string;
if (strKey == null)
{
- throw PSTraceSource.NewArgumentException("key", ParameterBinderStrings.StringValueKeyExpected, key, key.GetType().FullName);
+ throw PSTraceSource.NewArgumentException(nameof(key), ParameterBinderStrings.StringValueKeyExpected, key, key.GetType().FullName);
}
string keyAfterTrim = strKey.Trim();
@@ -4530,7 +4530,7 @@ namespace System.Management.Automation
return;
}
- throw PSTraceSource.NewArgumentException("key", ParameterBinderStrings.KeyAlreadyAdded, key);
+ throw PSTraceSource.NewArgumentException(nameof(key), ParameterBinderStrings.KeyAlreadyAdded, key);
}
if (!CheckKeyIsValid(keyAfterTrim, ref cmdletName, ref parameterName))
@@ -4555,7 +4555,7 @@ namespace System.Management.Automation
{
get
{
- if (key == null) { throw PSTraceSource.NewArgumentNullException("key"); }
+ if (key == null) { throw PSTraceSource.NewArgumentNullException(nameof(key)); }
var strKey = key as string;
if (strKey == null) { return null; }
@@ -4578,7 +4578,7 @@ namespace System.Management.Automation
{
if (key == null)
{
- throw PSTraceSource.NewArgumentNullException("key");
+ throw PSTraceSource.NewArgumentNullException(nameof(key));
}
var strKey = key as string;
diff --git a/src/System.Management.Automation/engine/CodeMethods.cs b/src/System.Management.Automation/engine/CodeMethods.cs
index d764f5e37..7fd88909f 100644
--- a/src/System.Management.Automation/engine/CodeMethods.cs
+++ b/src/System.Management.Automation/engine/CodeMethods.cs
@@ -67,7 +67,7 @@ namespace Microsoft.PowerShell
{
if (largeIntegerInstance == null)
{
- throw PSTraceSource.NewArgumentException("largeIntegerInstance");
+ throw PSTraceSource.NewArgumentException(nameof(largeIntegerInstance));
}
object largeIntObject = (object)largeIntegerInstance.BaseObject;
@@ -111,7 +111,7 @@ namespace Microsoft.PowerShell
{
if (dnWithBinaryInstance == null)
{
- throw PSTraceSource.NewArgumentException("dnWithBinaryInstance");
+ throw PSTraceSource.NewArgumentException(nameof(dnWithBinaryInstance));
}
object dnWithBinaryObject = (object)dnWithBinaryInstance.BaseObject;
diff --git a/src/System.Management.Automation/engine/CommandBase.cs b/src/System.Management.Automation/engine/CommandBase.cs
index 0e925f964..720a93ab8 100644
--- a/src/System.Management.Automation/engine/CommandBase.cs
+++ b/src/System.Management.Automation/engine/CommandBase.cs
@@ -484,7 +484,7 @@ namespace System.Management.Automation
{
if (providerId == null)
{
- throw PSTraceSource.NewArgumentNullException("providerId");
+ throw PSTraceSource.NewArgumentNullException(nameof(providerId));
}
PathInfo result = SessionState.Path.CurrentProviderLocation(providerId);
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs
index d1f4aa486..e4c253e9d 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs
@@ -72,7 +72,7 @@ namespace System.Management.Automation
{
if (cursorIndex > input.Length)
{
- throw PSTraceSource.NewArgumentException("cursorIndex");
+ throw PSTraceSource.NewArgumentException(nameof(cursorIndex));
}
Token[] tokens;
@@ -112,17 +112,17 @@ namespace System.Management.Automation
{
if (ast == null)
{
- throw PSTraceSource.NewArgumentNullException("ast");
+ throw PSTraceSource.NewArgumentNullException(nameof(ast));
}
if (tokens == null)
{
- throw PSTraceSource.NewArgumentNullException("tokens");
+ throw PSTraceSource.NewArgumentNullException(nameof(tokens));
}
if (positionOfCursor == null)
{
- throw PSTraceSource.NewArgumentNullException("positionOfCursor");
+ throw PSTraceSource.NewArgumentNullException(nameof(positionOfCursor));
}
return CompleteInputImpl(ast, tokens, positionOfCursor, options);
@@ -147,12 +147,12 @@ namespace System.Management.Automation
if (cursorIndex > input.Length)
{
- throw PSTraceSource.NewArgumentException("cursorIndex");
+ throw PSTraceSource.NewArgumentException(nameof(cursorIndex));
}
if (powershell == null)
{
- throw PSTraceSource.NewArgumentNullException("powershell");
+ throw PSTraceSource.NewArgumentNullException(nameof(powershell));
}
// If we are in a debugger stop, let the debugger do the command completion.
@@ -216,22 +216,22 @@ namespace System.Management.Automation
{
if (ast == null)
{
- throw PSTraceSource.NewArgumentNullException("ast");
+ throw PSTraceSource.NewArgumentNullException(nameof(ast));
}
if (tokens == null)
{
- throw PSTraceSource.NewArgumentNullException("tokens");
+ throw PSTraceSource.NewArgumentNullException(nameof(tokens));
}
if (cursorPosition == null)
{
- throw PSTraceSource.NewArgumentNullException("cursorPosition");
+ throw PSTraceSource.NewArgumentNullException(nameof(cursorPosition));
}
if (powershell == null)
{
- throw PSTraceSource.NewArgumentNullException("powershell");
+ throw PSTraceSource.NewArgumentNullException(nameof(powershell));
}
// If we are in a debugger stop, let the debugger do the command completion.
@@ -334,12 +334,12 @@ namespace System.Management.Automation
if (cursorIndex > input.Length)
{
- throw PSTraceSource.NewArgumentException("cursorIndex");
+ throw PSTraceSource.NewArgumentException(nameof(cursorIndex));
}
if (debugger == null)
{
- throw PSTraceSource.NewArgumentNullException("debugger");
+ throw PSTraceSource.NewArgumentNullException(nameof(debugger));
}
Command cmd = new Command("TabExpansion2");
@@ -363,22 +363,22 @@ namespace System.Management.Automation
{
if (ast == null)
{
- throw PSTraceSource.NewArgumentNullException("ast");
+ throw PSTraceSource.NewArgumentNullException(nameof(ast));
}
if (tokens == null)
{
- throw PSTraceSource.NewArgumentNullException("tokens");
+ throw PSTraceSource.NewArgumentNullException(nameof(tokens));
}
if (cursorPosition == null)
{
- throw PSTraceSource.NewArgumentNullException("cursorPosition");
+ throw PSTraceSource.NewArgumentNullException(nameof(cursorPosition));
}
if (debugger == null)
{
- throw PSTraceSource.NewArgumentNullException("debugger");
+ throw PSTraceSource.NewArgumentNullException(nameof(debugger));
}
// For remote debugging just pass string input.
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
index 70027d06c..7ff174350 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
@@ -207,7 +207,7 @@ namespace System.Management.Automation
}
private static readonly HashSet s_keywordsToExcludeFromAddingAmpersand
- = new HashSet(StringComparer.OrdinalIgnoreCase) { TokenKind.InlineScript.ToString(), TokenKind.Configuration.ToString() };
+ = new HashSet(StringComparer.OrdinalIgnoreCase) { nameof(TokenKind.InlineScript), nameof(TokenKind.Configuration) };
internal static CompletionResult GetCommandNameCompletionResult(string name, object command, bool addAmpersandIfNecessary, string quote)
{
string syntax = name, listItem = name;
diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionResult.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionResult.cs
index 763f54b60..3fe4a54e0 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/CompletionResult.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionResult.cs
@@ -170,22 +170,22 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(completionText))
{
- throw PSTraceSource.NewArgumentNullException("completionText");
+ throw PSTraceSource.NewArgumentNullException(nameof(completionText));
}
if (string.IsNullOrEmpty(listItemText))
{
- throw PSTraceSource.NewArgumentNullException("listItemText");
+ throw PSTraceSource.NewArgumentNullException(nameof(listItemText));
}
if (resultType < CompletionResultType.Text || resultType > CompletionResultType.DynamicKeyword)
{
- throw PSTraceSource.NewArgumentOutOfRangeException("resultType", resultType);
+ throw PSTraceSource.NewArgumentOutOfRangeException(nameof(resultType), resultType);
}
if (string.IsNullOrEmpty(toolTip))
{
- throw PSTraceSource.NewArgumentNullException("toolTip");
+ throw PSTraceSource.NewArgumentNullException(nameof(toolTip));
}
_completionText = completionText;
diff --git a/src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs b/src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs
index 71c76b3ce..9bb33ef56 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs
@@ -34,7 +34,7 @@ namespace System.Management.Automation
{
if (type == null || (type.GetInterfaces().All(t => t != typeof(IArgumentCompleter))))
{
- throw PSTraceSource.NewArgumentException("type");
+ throw PSTraceSource.NewArgumentException(nameof(type));
}
Type = type;
@@ -48,7 +48,7 @@ namespace System.Management.Automation
{
if (scriptBlock == null)
{
- throw PSTraceSource.NewArgumentNullException("scriptBlock");
+ throw PSTraceSource.NewArgumentNullException(nameof(scriptBlock));
}
ScriptBlock = scriptBlock;
@@ -176,12 +176,12 @@ namespace System.Management.Automation
{
if (completions == null)
{
- throw PSTraceSource.NewArgumentNullException("completions");
+ throw PSTraceSource.NewArgumentNullException(nameof(completions));
}
if (completions.Length == 0)
{
- throw PSTraceSource.NewArgumentOutOfRangeException("completions", completions);
+ throw PSTraceSource.NewArgumentOutOfRangeException(nameof(completions), completions);
}
_completions = completions;
diff --git a/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs b/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
index 2b10b988e..b8ed6df50 100644
--- a/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
+++ b/src/System.Management.Automation/engine/CommandCompletion/PseudoParameterBinder.cs
@@ -75,7 +75,7 @@ namespace System.Management.Automation.Language
internal PipeObjectPair(string parameterName, Type pipeObjType)
{
if (parameterName == null)
- throw PSTraceSource.NewArgumentNullException("parameterName");
+ throw PSTraceSource.NewArgumentNullException(nameof(parameterName));
Parameter = null;
ParameterArgumentType = AstParameterArgumentType.PipeObject;
@@ -96,9 +96,9 @@ namespace System.Management.Automation.Language
internal AstArrayPair(string parameterName, ICollection arguments)
{
if (parameterName == null)
- throw PSTraceSource.NewArgumentNullException("parameterName");
+ throw PSTraceSource.NewArgumentNullException(nameof(parameterName));
if (arguments == null || arguments.Count == 0)
- throw PSTraceSource.NewArgumentNullException("arguments");
+ throw PSTraceSource.NewArgumentNullException(nameof(arguments));
Parameter = null;
ParameterArgumentType = AstParameterArgumentType.AstArray;
@@ -125,7 +125,7 @@ namespace System.Management.Automation.Language
internal FakePair(CommandParameterAst parameterAst)
{
if (parameterAst == null)
- throw PSTraceSource.NewArgumentNullException("parameterAst");
+ throw PSTraceSource.NewArgumentNullException(nameof(parameterAst));
Parameter = parameterAst;
ParameterArgumentType = AstParameterArgumentType.Fake;
@@ -145,7 +145,7 @@ namespace System.Management.Automation.Language
internal SwitchPair(CommandParameterAst parameterAst)
{
if (parameterAst == null)
- throw PSTraceSource.NewArgumentNullException("parameterAst");
+ throw PSTraceSource.NewArgumentNullException(nameof(parameterAst));
Parameter = parameterAst;
ParameterArgumentType = AstParameterArgumentType.Switch;
@@ -175,7 +175,7 @@ namespace System.Management.Automation.Language
internal AstPair(CommandParameterAst parameterAst)
{
if (parameterAst == null || parameterAst.Argument == null)
- throw PSTraceSource.NewArgumentException("parameterAst");
+ throw PSTraceSource.NewArgumentException(nameof(parameterAst));
Parameter = parameterAst;
ParameterArgumentType = AstParameterArgumentType.AstPair;
@@ -192,10 +192,10 @@ namespace System.Management.Automation.Language
internal AstPair(CommandParameterAst parameterAst, ExpressionAst argumentAst)
{
if (parameterAst != null && parameterAst.Argument != null)
- throw PSTraceSource.NewArgumentException("parameterAst");
+ throw PSTraceSource.NewArgumentException(nameof(parameterAst));
if (parameterAst == null && argumentAst == null)
- throw PSTraceSource.NewArgumentNullException("argumentAst");
+ throw PSTraceSource.NewArgumentNullException(nameof(argumentAst));
Parameter = parameterAst;
ParameterArgumentType = AstParameterArgumentType.AstPair;
@@ -212,10 +212,10 @@ namespace System.Management.Automation.Language
internal AstPair(CommandParameterAst parameterAst, CommandElementAst argumentAst)
{
if (parameterAst != null && parameterAst.Argument != null)
- throw PSTraceSource.NewArgumentException("parameterAst");
+ throw PSTraceSource.NewArgumentException(nameof(parameterAst));
if (parameterAst == null || argumentAst == null)
- throw PSTraceSource.NewArgumentNullException("argumentAst");
+ throw PSTraceSource.NewArgumentNullException(nameof(argumentAst));
Parameter = parameterAst;
ParameterArgumentType = AstParameterArgumentType.AstPair;
@@ -949,7 +949,7 @@ namespace System.Management.Automation.Language
{
if (command == null)
{
- throw PSTraceSource.NewArgumentNullException("command");
+ throw PSTraceSource.NewArgumentNullException(nameof(command));
}
// initialize/reset the private members
diff --git a/src/System.Management.Automation/engine/CommandDiscovery.cs b/src/System.Management.Automation/engine/CommandDiscovery.cs
index c194a2f40..4b58da58c 100644
--- a/src/System.Management.Automation/engine/CommandDiscovery.cs
+++ b/src/System.Management.Automation/engine/CommandDiscovery.cs
@@ -133,7 +133,7 @@ namespace System.Management.Automation
{
if (context == null)
{
- throw PSTraceSource.NewArgumentNullException("context");
+ throw PSTraceSource.NewArgumentNullException(nameof(context));
}
Context = context;
@@ -202,7 +202,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(name))
{
- throw PSTraceSource.NewArgumentException("name");
+ throw PSTraceSource.NewArgumentException(nameof(name));
}
if (newCmdletInfo == null)
@@ -1525,7 +1525,7 @@ namespace System.Management.Automation
if (context == null)
{
- throw PSTraceSource.NewArgumentNullException("context");
+ throw PSTraceSource.NewArgumentNullException(nameof(context));
}
// check the PSVariable
@@ -1687,7 +1687,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(item))
{
- throw PSTraceSource.NewArgumentException("item");
+ throw PSTraceSource.NewArgumentException(nameof(item));
}
int result = -1;
diff --git a/src/System.Management.Automation/engine/CommandInfo.cs b/src/System.Management.Automation/engine/CommandInfo.cs
index e55240a4c..1090a3fbb 100644
--- a/src/System.Management.Automation/engine/CommandInfo.cs
+++ b/src/System.Management.Automation/engine/CommandInfo.cs
@@ -112,7 +112,7 @@ namespace System.Management.Automation
if (name == null)
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
Name = name;
@@ -287,7 +287,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(newName))
{
- throw new ArgumentNullException("newName");
+ throw new ArgumentNullException(nameof(newName));
}
Name = newName;
@@ -800,7 +800,7 @@ namespace System.Management.Automation
{
if (typeDefinitionAst == null)
{
- throw PSTraceSource.NewArgumentNullException("typeDefinitionAst");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeDefinitionAst));
}
TypeDefinitionAst = typeDefinitionAst;
@@ -814,7 +814,7 @@ namespace System.Management.Automation
{
if (typeName == null)
{
- throw PSTraceSource.NewArgumentNullException("typeName");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeName));
}
_type = typeName.GetReflectionType();
diff --git a/src/System.Management.Automation/engine/CommandMetadata.cs b/src/System.Management.Automation/engine/CommandMetadata.cs
index 02f4f23c3..5ad657b03 100644
--- a/src/System.Management.Automation/engine/CommandMetadata.cs
+++ b/src/System.Management.Automation/engine/CommandMetadata.cs
@@ -105,7 +105,7 @@ namespace System.Management.Automation
{
if (commandInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("commandInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandInfo));
}
while (commandInfo is AliasInfo)
{
@@ -162,7 +162,7 @@ namespace System.Management.Automation
{
if (other == null)
{
- throw PSTraceSource.NewArgumentNullException("other");
+ throw PSTraceSource.NewArgumentNullException(nameof(other));
}
Name = other.Name;
@@ -315,7 +315,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentException("commandName");
+ throw PSTraceSource.NewArgumentException(nameof(commandName));
}
CommandMetadata result = null;
@@ -369,7 +369,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(commandName))
{
- throw PSTraceSource.NewArgumentException("commandName");
+ throw PSTraceSource.NewArgumentException(nameof(commandName));
}
Name = commandName;
@@ -412,7 +412,7 @@ namespace System.Management.Automation
{
if (scriptblock == null)
{
- throw PSTraceSource.NewArgumentException("scriptblock");
+ throw PSTraceSource.NewArgumentException(nameof(scriptblock));
}
CmdletBindingAttribute cmdletBindingAttribute = scriptblock.CmdletBindingAttribute;
@@ -725,7 +725,7 @@ namespace System.Management.Automation
{
if (attribute == null)
{
- throw PSTraceSource.NewArgumentNullException("attribute");
+ throw PSTraceSource.NewArgumentNullException(nameof(attribute));
}
// Process the default parameter set name
diff --git a/src/System.Management.Automation/engine/CommandProcessor.cs b/src/System.Management.Automation/engine/CommandProcessor.cs
index e7454b112..48abebc7a 100644
--- a/src/System.Management.Automation/engine/CommandProcessor.cs
+++ b/src/System.Management.Automation/engine/CommandProcessor.cs
@@ -104,7 +104,7 @@ namespace System.Management.Automation
Cmdlet cmdlet = command as Cmdlet;
if (cmdlet == null)
{
- throw PSTraceSource.NewArgumentException("command");
+ throw PSTraceSource.NewArgumentException(nameof(command));
}
ParameterBinderBase parameterBinder;
diff --git a/src/System.Management.Automation/engine/CommandProcessorBase.cs b/src/System.Management.Automation/engine/CommandProcessorBase.cs
index 8a01dc349..e2c8ad46e 100644
--- a/src/System.Management.Automation/engine/CommandProcessorBase.cs
+++ b/src/System.Management.Automation/engine/CommandProcessorBase.cs
@@ -35,7 +35,7 @@ namespace System.Management.Automation
{
if (commandInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("commandInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandInfo));
}
if (commandInfo is IScriptCommandInfo scriptCommand)
@@ -278,12 +278,12 @@ namespace System.Management.Automation
{
if (context == null)
{
- throw PSTraceSource.NewArgumentNullException("context");
+ throw PSTraceSource.NewArgumentNullException(nameof(context));
}
if (string.IsNullOrEmpty(helpTarget))
{
- throw PSTraceSource.NewArgumentNullException("helpTarget");
+ throw PSTraceSource.NewArgumentNullException(nameof(helpTarget));
}
CommandProcessorBase helpCommandProcessor = context.CreateCommand("get-help", false);
diff --git a/src/System.Management.Automation/engine/CommonCommandParameters.cs b/src/System.Management.Automation/engine/CommonCommandParameters.cs
index 19c693551..9cc0b2ad8 100644
--- a/src/System.Management.Automation/engine/CommonCommandParameters.cs
+++ b/src/System.Management.Automation/engine/CommonCommandParameters.cs
@@ -28,7 +28,7 @@ namespace System.Management.Automation.Internal
{
if (commandRuntime == null)
{
- throw PSTraceSource.NewArgumentNullException("commandRuntime");
+ throw PSTraceSource.NewArgumentNullException(nameof(commandRuntime));
}
_commandRuntime = commandRuntime;
diff --git a/src/System.Management.Automation/engine/CompiledCommandParameter.cs b/src/System.Management.Automation/engine/CompiledCommandParameter.cs
index 48a7b2fd4..a9e85f432 100644
--- a/src/System.Management.Automation/engine/CompiledCommandParameter.cs
+++ b/src/System.Management.Automation/engine/CompiledCommandParameter.cs
@@ -37,7 +37,7 @@ namespace System.Management.Automation
{
if (runtimeDefinedParameter == null)
{
- throw PSTraceSource.NewArgumentNullException("runtimeDefinedParameter");
+ throw PSTraceSource.NewArgumentNullException(nameof(runtimeDefinedParameter));
}
this.Name = runtimeDefinedParameter.Name;
@@ -123,7 +123,7 @@ namespace System.Management.Automation
{
if (member == null)
{
- throw PSTraceSource.NewArgumentNullException("member");
+ throw PSTraceSource.NewArgumentNullException(nameof(member));
}
this.Name = member.Name;
@@ -146,7 +146,7 @@ namespace System.Management.Automation
{
ArgumentException e =
PSTraceSource.NewArgumentException(
- "member",
+ nameof(member),
DiscoveryExceptions.CompiledCommandParameterMemberMustBeFieldOrProperty);
throw e;
diff --git a/src/System.Management.Automation/engine/ContentCmdletProviderInterfaces.cs b/src/System.Management.Automation/engine/ContentCmdletProviderInterfaces.cs
index a2997a77b..382f6b7e4 100644
--- a/src/System.Management.Automation/engine/ContentCmdletProviderInterfaces.cs
+++ b/src/System.Management.Automation/engine/ContentCmdletProviderInterfaces.cs
@@ -39,7 +39,7 @@ namespace System.Management.Automation
{
if (cmdlet == null)
{
- throw PSTraceSource.NewArgumentNullException("cmdlet");
+ throw PSTraceSource.NewArgumentNullException(nameof(cmdlet));
}
_cmdlet = cmdlet;
@@ -59,7 +59,7 @@ namespace System.Management.Automation
{
if (sessionState == null)
{
- throw PSTraceSource.NewArgumentNullException("sessionState");
+ throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}
_sessionState = sessionState;
diff --git a/src/System.Management.Automation/engine/CoreAdapter.cs b/src/System.Management.Automation/engine/CoreAdapter.cs
index 6bf9d0c52..44361ffa0 100644
--- a/src/System.Management.Automation/engine/CoreAdapter.cs
+++ b/src/System.Management.Automation/engine/CoreAdapter.cs
@@ -1856,7 +1856,7 @@ namespace System.Management.Automation
{
if (resultType == null)
{
- throw PSTraceSource.NewArgumentNullException("resultType");
+ throw PSTraceSource.NewArgumentNullException(nameof(resultType));
}
bool isArgumentByRef;
@@ -1911,7 +1911,7 @@ namespace System.Management.Automation
{
if (resultType == null)
{
- throw PSTraceSource.NewArgumentNullException("resultType");
+ throw PSTraceSource.NewArgumentNullException(nameof(resultType));
}
PSObject mshObj = valueToConvert as PSObject;
diff --git a/src/System.Management.Automation/engine/Credential.cs b/src/System.Management.Automation/engine/Credential.cs
index df17c38a8..6b9c4be8d 100644
--- a/src/System.Management.Automation/engine/Credential.cs
+++ b/src/System.Management.Automation/engine/Credential.cs
@@ -219,7 +219,7 @@ namespace System.Management.Automation
public PSCredential(PSObject pso)
{
if (pso == null)
- throw PSTraceSource.NewArgumentNullException("pso");
+ throw PSTraceSource.NewArgumentNullException(nameof(pso));
if (pso.Properties["UserName"] != null)
{
diff --git a/src/System.Management.Automation/engine/DataStoreAdapter.cs b/src/System.Management.Automation/engine/DataStoreAdapter.cs
index 3b01bae29..6b9a77f45 100644
--- a/src/System.Management.Automation/engine/DataStoreAdapter.cs
+++ b/src/System.Management.Automation/engine/DataStoreAdapter.cs
@@ -127,7 +127,7 @@ namespace System.Management.Automation
{
if (path == null)
{
- throw PSTraceSource.NewArgumentNullException("path");
+ throw PSTraceSource.NewArgumentNullException(nameof(path));
}
if (!DriveBeingCreated)
@@ -271,7 +271,7 @@ namespace System.Management.Automation
{
if (driveInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("driveInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(driveInfo));
}
_name = driveInfo.Name;
@@ -326,17 +326,17 @@ namespace System.Management.Automation
if (name == null)
{
- throw PSTraceSource.NewArgumentNullException("name");
+ throw PSTraceSource.NewArgumentNullException(nameof(name));
}
if (provider == null)
{
- throw PSTraceSource.NewArgumentNullException("provider");
+ throw PSTraceSource.NewArgumentNullException(nameof(provider));
}
if (root == null)
{
- throw PSTraceSource.NewArgumentNullException("root");
+ throw PSTraceSource.NewArgumentNullException(nameof(root));
}
// Copy the parameters to the local members
@@ -508,7 +508,7 @@ namespace System.Management.Automation
{
if (string.IsNullOrEmpty(newName))
{
- throw PSTraceSource.NewArgumentException("newName");
+ throw PSTraceSource.NewArgumentException(nameof(newName));
}
_name = newName;
@@ -534,7 +534,7 @@ namespace System.Management.Automation
{
if (newProvider == null)
{
- throw PSTraceSource.NewArgumentNullException("newProvider");
+ throw PSTraceSource.NewArgumentNullException(nameof(newProvider));
}
_provider = newProvider;
@@ -602,7 +602,7 @@ namespace System.Management.Automation
if (drive == null)
{
- throw PSTraceSource.NewArgumentNullException("drive");
+ throw PSTraceSource.NewArgumentNullException(nameof(drive));
}
return string.Compare(Name, drive.Name, StringComparison.OrdinalIgnoreCase);
@@ -631,7 +631,7 @@ namespace System.Management.Automation
{
ArgumentException e =
PSTraceSource.NewArgumentException(
- "obj",
+ nameof(obj),
SessionStateStrings.OnlyAbleToComparePSDriveInfo);
throw e;
}
diff --git a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs
index d341b2803..cfc7528b9 100644
--- a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs
+++ b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs
@@ -297,7 +297,7 @@ namespace System.Management.Automation
{
if (providerInfo == null)
{
- throw PSTraceSource.NewArgumentNullException("providerInfo");
+ throw PSTraceSource.NewArgumentNullException(nameof(providerInfo));
}
Name = providerInfo.Name;
@@ -394,17 +394,17 @@ namespace System.Management.Automation
// Verify parameters
if (sessionState == null)
{
- throw PSTraceSource.NewArgumentNullException("sessionState");
+ throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}
if (implementingType == null)
{
- throw PSTraceSource.NewArgumentNullException("implementingType");
+ throw PSTraceSource.NewArgumentNullException(nameof(implementingType));
}
if (string.IsNullOrEmpty(name))
{
- throw PSTraceSource.NewArgumentException("name");
+ throw PSTraceSource.NewArgumentException(nameof(name));
}
_sessionState = sessionState;
diff --git a/src/System.Management.Automation/engine/DefaultCommandRuntime.cs b/src/System.Management.Automation/engine/DefaultCommandRuntime.cs
index 4df5c39fe..b4f21bb5c 100644
--- a/src/System.Management.Automation/engine/DefaultCommandRuntime.cs
+++ b/src/System.Management.Automation/engine/DefaultCommandRuntime.cs
@@ -21,7 +21,7 @@ namespace System.Management.Automation
public DefaultCommandRuntime(List