diff --git a/src/System.Management.Automation/engine/ExecutionContext.cs b/src/System.Management.Automation/engine/ExecutionContext.cs
index 4e4afe0f721..118ff82a899 100644
--- a/src/System.Management.Automation/engine/ExecutionContext.cs
+++ b/src/System.Management.Automation/engine/ExecutionContext.cs
@@ -1056,7 +1056,7 @@ internal ActionPreference DebugPreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.DebugPreferenceVarPath,
- InitialSessionState.defaultDebugPreference,
+ InitialSessionState.DefaultDebugPreference,
out defaultUsed);
}
@@ -1077,7 +1077,7 @@ internal ActionPreference VerbosePreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.VerbosePreferenceVarPath,
- InitialSessionState.defaultVerbosePreference,
+ InitialSessionState.DefaultVerbosePreference,
out defaultUsed);
}
@@ -1098,7 +1098,7 @@ internal ActionPreference ErrorActionPreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.ErrorActionPreferenceVarPath,
- InitialSessionState.defaultErrorActionPreference,
+ InitialSessionState.DefaultErrorActionPreference,
out defaultUsed);
}
@@ -1119,7 +1119,7 @@ internal ActionPreference WarningActionPreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.WarningPreferenceVarPath,
- InitialSessionState.defaultWarningPreference,
+ InitialSessionState.DefaultWarningPreference,
out defaultUsed);
}
@@ -1140,7 +1140,7 @@ internal ActionPreference InformationActionPreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.InformationPreferenceVarPath,
- InitialSessionState.defaultInformationPreference,
+ InitialSessionState.DefaultInformationPreference,
out defaultUsed);
}
@@ -1186,7 +1186,7 @@ internal ConfirmImpact ConfirmPreferenceVariable
bool defaultUsed = false;
return this.GetEnumPreference(
SpecialVariables.ConfirmPreferenceVarPath,
- InitialSessionState.defaultConfirmPreference,
+ InitialSessionState.DefaultConfirmPreference,
out defaultUsed);
}
diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs
index 3abb53b0b80..101461be407 100644
--- a/src/System.Management.Automation/engine/InitialSessionState.cs
+++ b/src/System.Management.Automation/engine/InitialSessionState.cs
@@ -188,7 +188,7 @@ public SessionStateTypeEntry(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
{
- throw PSTraceSource.NewArgumentException("fileName");
+ throw PSTraceSource.NewArgumentException(nameof(fileName));
}
FileName = fileName.Trim();
@@ -203,7 +203,7 @@ public SessionStateTypeEntry(TypeTable typeTable)
{
if (typeTable == null)
{
- throw PSTraceSource.NewArgumentNullException("typeTable");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeTable));
}
TypeTable = typeTable;
@@ -219,7 +219,7 @@ public SessionStateTypeEntry(TypeData typeData, bool isRemove)
{
if (typeData == null)
{
- throw PSTraceSource.NewArgumentNullException("typeData");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeData));
}
TypeData = typeData;
@@ -295,7 +295,7 @@ public SessionStateFormatEntry(string fileName)
{
if (string.IsNullOrWhiteSpace(fileName))
{
- throw PSTraceSource.NewArgumentException("fileName");
+ throw PSTraceSource.NewArgumentException(nameof(fileName));
}
FileName = fileName.Trim();
@@ -310,7 +310,7 @@ public SessionStateFormatEntry(FormatTable formattable)
{
if (formattable == null)
{
- throw PSTraceSource.NewArgumentNullException("formattable");
+ throw PSTraceSource.NewArgumentNullException(nameof(formattable));
}
Formattable = formattable;
@@ -325,7 +325,7 @@ public SessionStateFormatEntry(ExtendedTypeDefinition typeDefinition)
{
if (typeDefinition == null)
{
- throw PSTraceSource.NewArgumentNullException("typeDefinition");
+ throw PSTraceSource.NewArgumentNullException(nameof(typeDefinition));
}
FormatData = typeDefinition;
@@ -619,8 +619,7 @@ public SessionStateAliasEntry(string name, string definition, string description
/// A description of the purpose of the alias.
/// Options defining the scope visibility, readonly and constant.
///
- internal SessionStateAliasEntry(string name, string definition, string description,
- ScopedItemOptions options, SessionStateEntryVisibility visibility)
+ internal SessionStateAliasEntry(string name, string definition, string description, ScopedItemOptions options, SessionStateEntryVisibility visibility)
: base(name, visibility)
{
Definition = definition;
@@ -769,14 +768,12 @@ internal static SessionStateFunctionEntry GetDelayParsedFunctionEntry(string nam
internal static SessionStateFunctionEntry GetDelayParsedFunctionEntry(string name, string definition, bool isProductCode)
{
var sb = ScriptBlock.CreateDelayParsedScriptBlock(definition, isProductCode);
- return new SessionStateFunctionEntry(name, definition, ScopedItemOptions.None,
- SessionStateEntryVisibility.Public, sb, null);
+ return new SessionStateFunctionEntry(name, definition, ScopedItemOptions.None, SessionStateEntryVisibility.Public, sb, null);
}
internal static SessionStateFunctionEntry GetDelayParsedFunctionEntry(string name, string definition, ScriptBlock sb)
{
- return new SessionStateFunctionEntry(name, definition, ScopedItemOptions.None,
- SessionStateEntryVisibility.Public, sb, null);
+ return new SessionStateFunctionEntry(name, definition, ScopedItemOptions.None, SessionStateEntryVisibility.Public, sb, null);
}
///
@@ -868,8 +865,7 @@ public SessionStateVariableEntry(string name, object value, string description,
/// A descriptive string to attach to the variable.
/// Options like readonly, constant, allscope, etc.
/// A list of attributes to attach to the variable.
- public SessionStateVariableEntry(string name, object value, string description,
- ScopedItemOptions options, Collection attributes)
+ public SessionStateVariableEntry(string name, object value, string description, ScopedItemOptions options, Collection attributes)
: base(name, SessionStateEntryVisibility.Public)
{
Value = value;
@@ -889,8 +885,7 @@ public SessionStateVariableEntry(string name, object value, string description,
/// A descriptive string to attach to the variable.
/// Options like readonly, constant, allscope, etc.
/// A single attribute to attach to the variable.
- public SessionStateVariableEntry(string name, object value, string description,
- ScopedItemOptions options, Attribute attribute)
+ public SessionStateVariableEntry(string name, object value, string description, ScopedItemOptions options, Attribute attribute)
: base(name, SessionStateEntryVisibility.Public)
{
Value = value;
@@ -912,8 +907,7 @@ public SessionStateVariableEntry(string name, object value, string description,
/// Options like readonly, constant, allscope, etc.
/// A single attribute to attach to the variable.
///
- internal SessionStateVariableEntry(string name, object value, string description,
- ScopedItemOptions options, Collection attributes, SessionStateEntryVisibility visibility)
+ internal SessionStateVariableEntry(string name, object value, string description, ScopedItemOptions options, Collection attributes, SessionStateEntryVisibility visibility)
: base(name, visibility)
{
Value = value;
@@ -931,7 +925,10 @@ public override InitialSessionStateEntry Clone()
// Copy the attribute collection if necessary...
Collection attrs = null;
if (_attributes != null && _attributes.Count > 0)
+ {
attrs = new Collection(_attributes);
+ }
+
return new SessionStateVariableEntry(Name, Value, Description, Options, attrs, Visibility);
}
@@ -982,7 +979,7 @@ public InitialSessionStateEntryCollection(IEnumerable items)
{
if (items == null)
{
- throw new ArgumentNullException("items");
+ throw new ArgumentNullException(nameof(items));
}
_internalCollection = new Collection();
@@ -1084,7 +1081,10 @@ public Collection this[string name]
///
internal Collection LookUpByName(string name)
{
- if (name == null) { throw new PSArgumentNullException("name"); }
+ if (name == null)
+ {
+ throw new PSArgumentNullException(nameof(name));
+ }
Collection result = new Collection();
WildcardPattern namePattern = WildcardPattern.Get(name, WildcardOptions.IgnoreCase);
@@ -1152,7 +1152,9 @@ public void Clear()
public void Remove(string name, object type)
{
if (name == null)
- throw new ArgumentNullException("name");
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
lock (_syncObject)
{
@@ -1168,7 +1170,10 @@ public void Remove(string name, object type)
{
T element = _internalCollection[i];
if (element == null)
+ {
continue;
+ }
+
if ((objType == null || element.GetType() == objType) &&
string.Equals(element.Name, name, StringComparison.OrdinalIgnoreCase))
{
@@ -1185,7 +1190,9 @@ public void Remove(string name, object type)
public void Add(T item)
{
if (item == null)
- throw new ArgumentNullException("item");
+ {
+ throw new ArgumentNullException(nameof(item));
+ }
lock (_syncObject)
{
@@ -1200,7 +1207,9 @@ public void Add(T item)
public void Add(IEnumerable items)
{
if (items == null)
- throw new ArgumentNullException("items");
+ {
+ throw new ArgumentNullException(nameof(items));
+ }
lock (_syncObject)
{
@@ -1367,10 +1376,7 @@ private static InitialSessionState CreateRestrictedForRemoteServer()
iss.ImportPSSnapIn(si, out warning);
}
- //
// restrict what gets exposed
- //
-
List allowedCommands = new List();
// required by implicit remoting and interactive remoting
@@ -1412,9 +1418,7 @@ private static InitialSessionState CreateRestrictedForRemoteServer()
// Add built-in variables.
iss.Variables.Add(BuiltInVariables);
- //
// wrap some commands in a proxy function to restrict their parameters
- //
foreach (KeyValuePair proxyFunction in CommandMetadata.GetRestrictedCommands(SessionCapabilities.RemoteServer))
{
string commandName = proxyFunction.Key;
@@ -1773,7 +1777,10 @@ internal bool EnforceInputParameterValidation
///
public Microsoft.PowerShell.ExecutionPolicy ExecutionPolicy
{
- get { return _executionPolicy; }
+ get
+ {
+ return _executionPolicy;
+ }
set
{
@@ -1832,7 +1839,7 @@ public void ImportPSModule(params string[] name)
{
if (name == null)
{
- throw new ArgumentNullException("name");
+ throw new ArgumentNullException(nameof(name));
}
foreach (string n in name)
@@ -1860,7 +1867,7 @@ public void ImportPSModule(IEnumerable modules)
{
if (modules == null)
{
- throw new ArgumentNullException("modules");
+ throw new ArgumentNullException(nameof(modules));
}
foreach (var moduleSpecification in modules)
@@ -1890,7 +1897,10 @@ public void ImportPSModulesFromPath(string path)
internal void ImportPSCoreModule(string[] name)
{
if (name == null)
- throw new ArgumentNullException("name");
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
foreach (string n in name)
{
CoreModulesToImport.Add(n);
@@ -1922,7 +1932,10 @@ public virtual InitialSessionStateEntryCollection Ass
get
{
if (_assemblies == null)
+ {
Interlocked.CompareExchange(ref _assemblies, new InitialSessionStateEntryCollection(), null);
+ }
+
return _assemblies;
}
}
@@ -1937,7 +1950,10 @@ public virtual InitialSessionStateEntryCollection Types
get
{
if (_types == null)
+ {
Interlocked.CompareExchange(ref _types, new InitialSessionStateEntryCollection(), null);
+ }
+
return _types;
}
}
@@ -1951,7 +1967,10 @@ public virtual InitialSessionStateEntryCollection Forma
get
{
if (_formats == null)
+ {
Interlocked.CompareExchange(ref _formats, new InitialSessionStateEntryCollection(), null);
+ }
+
return _formats;
}
}
@@ -1973,7 +1992,10 @@ public virtual InitialSessionStateEntryCollection Pro
get
{
if (_providers == null)
+ {
Interlocked.CompareExchange(ref _providers, new InitialSessionStateEntryCollection(), null);
+ }
+
return _providers;
}
}
@@ -1988,7 +2010,10 @@ public virtual InitialSessionStateEntryCollection Comm
get
{
if (_commands == null)
+ {
Interlocked.CompareExchange(ref _commands, new InitialSessionStateEntryCollection(), null);
+ }
+
return _commands;
}
}
@@ -2002,7 +2027,10 @@ internal HashSet UnresolvedCommandsToExpose
get
{
if (_unresolvedCommandsToExpose == null)
+ {
Interlocked.CompareExchange(ref _unresolvedCommandsToExpose, new HashSet(StringComparer.OrdinalIgnoreCase), null);
+ }
+
return _unresolvedCommandsToExpose;
}
}
@@ -2014,7 +2042,10 @@ internal Dictionary CommandModifications
get
{
if (_commandModifications == null)
+ {
Interlocked.CompareExchange(ref _commandModifications, new Dictionary(StringComparer.OrdinalIgnoreCase), null);
+ }
+
return _commandModifications;
}
}
@@ -2026,7 +2057,10 @@ internal List DynamicVariablesToDefine
get
{
if (_dynamicVariablesToDefine == null)
+ {
Interlocked.CompareExchange(ref _dynamicVariablesToDefine, new List(), null);
+ }
+
return _dynamicVariablesToDefine;
}
}
@@ -2040,7 +2074,10 @@ public virtual InitialSessionStateEntryCollection Var
get
{
if (_variables == null)
+ {
Interlocked.CompareExchange(ref _variables, new InitialSessionStateEntryCollection(), null);
+ }
+
return _variables;
}
}
@@ -2054,7 +2091,10 @@ public virtual InitialSessionStateEntryCollection Env
get
{
if (_environmentVariables == null)
+ {
Interlocked.CompareExchange(ref _environmentVariables, new InitialSessionStateEntryCollection(), null);
+ }
+
return _environmentVariables;
}
}
@@ -2068,7 +2108,10 @@ public virtual HashSet StartupScripts
get
{
if (_startupScripts == null)
+ {
Interlocked.CompareExchange(ref _startupScripts, new HashSet(), null);
+ }
+
return _startupScripts;
}
}
@@ -2186,7 +2229,10 @@ internal void Bind(ExecutionContext context, bool updateOnly, PSModuleInfo modul
private void Bind_SetVariables(SessionStateInternal ss)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.LoadVariablesStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadVariablesStart();
+ }
// Add all of the variables to session state...
foreach (SessionStateVariableEntry var in Variables)
@@ -2194,64 +2240,105 @@ private void Bind_SetVariables(SessionStateInternal ss)
ss.AddSessionStateEntry(var);
}
- if (etwEnabled) RunspaceEventSource.Log.LoadVariablesStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadVariablesStop();
+ }
}
private void Bind_SetEnvironment()
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.LoadEnvironmentVariablesStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadEnvironmentVariablesStart();
+ }
foreach (SessionStateVariableEntry var in EnvironmentVariables)
{
Environment.SetEnvironmentVariable(var.Name, var.Value.ToString());
}
- if (etwEnabled) RunspaceEventSource.Log.LoadEnvironmentVariablesStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadEnvironmentVariablesStop();
+ }
}
private void Bind_UpdateTypes(ExecutionContext context, bool updateOnly)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.UpdateTypeTableStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.UpdateTypeTableStart();
+ }
+
this.UpdateTypes(context, updateOnly);
- if (etwEnabled) RunspaceEventSource.Log.UpdateTypeTableStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.UpdateTypeTableStop();
+ }
}
private void Bind_UpdateFormats(ExecutionContext context, bool updateOnly)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.UpdateFormatTableStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.UpdateFormatTableStart();
+ }
this.UpdateFormats(context, updateOnly);
- if (etwEnabled) RunspaceEventSource.Log.UpdateFormatTableStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.UpdateFormatTableStop();
+ }
}
private void Bind_LoadProviders(SessionStateInternal ss)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.LoadProvidersStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadProvidersStart();
+ }
// Add all of the providers to session state...
foreach (SessionStateProviderEntry provider in Providers)
{
- if (etwEnabled) RunspaceEventSource.Log.LoadProviderStart(provider.Name);
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadProviderStart(provider.Name);
+ }
+
ss.AddSessionStateEntry(provider);
- if (etwEnabled) RunspaceEventSource.Log.LoadProviderStop(provider.Name);
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadProviderStop(provider.Name);
+ }
}
- if (etwEnabled) RunspaceEventSource.Log.LoadProvidersStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadProvidersStop();
+ }
}
private void Bind_BindCommands(PSModuleInfo module, bool noClobber, bool local, SessionStateInternal ss)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.LoadCommandsStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadCommandsStart();
+ }
foreach (SessionStateCommandEntry cmd in Commands)
{
- if (etwEnabled) RunspaceEventSource.Log.LoadCommandStart(cmd.Name);
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadCommandStart(cmd.Name);
+ }
SessionStateCmdletEntry ssce = cmd as SessionStateCmdletEntry;
if (ssce != null)
@@ -2306,16 +2393,25 @@ private void Bind_BindCommands(PSModuleInfo module, bool noClobber, bool local,
continue;
}
- if (etwEnabled) RunspaceEventSource.Log.LoadCommandStop(cmd.Name);
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadCommandStop(cmd.Name);
+ }
}
- if (etwEnabled) RunspaceEventSource.Log.LoadCommandsStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadCommandsStop();
+ }
}
private void Bind_LoadAssemblies(ExecutionContext context)
{
bool etwEnabled = RunspaceEventSource.Log.IsEnabled();
- if (etwEnabled) RunspaceEventSource.Log.LoadAssembliesStart();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadAssembliesStart();
+ }
// Load the assemblies and initialize the assembly cache...
foreach (SessionStateAssemblyEntry ssae in Assemblies)
@@ -2338,7 +2434,8 @@ private void Bind_LoadAssemblies(ExecutionContext context)
// throw the exception instead of writing it out...
if ((!string.IsNullOrEmpty(context.ModuleBeingProcessed) &&
Path.GetExtension(context.ModuleBeingProcessed)
- .Equals(StringLiterals.PowerShellDataFileExtension,
+ .Equals(
+ StringLiterals.PowerShellDataFileExtension,
StringComparison.OrdinalIgnoreCase)) ||
ThrowOnRunspaceOpenError)
{
@@ -2350,10 +2447,16 @@ private void Bind_LoadAssemblies(ExecutionContext context)
}
}
- if (etwEnabled) RunspaceEventSource.Log.LoadAssemblyStop(ssae.Name, ssae.FileName);
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadAssemblyStop(ssae.Name, ssae.FileName);
+ }
}
- if (etwEnabled) RunspaceEventSource.Log.LoadAssembliesStop();
+ if (etwEnabled)
+ {
+ RunspaceEventSource.Log.LoadAssembliesStop();
+ }
}
internal Exception BindRunspace(Runspace initializedRunspace, PSTraceSource runspaceInitTracer)
@@ -2374,7 +2477,9 @@ HashSet GetPublicCommands()
publicCommands = new HashSet();
foreach (CommandInfo sessionCommand in initializedRunspace.ExecutionContext.SessionState.InvokeCommand.GetCommands(
- "*", CommandTypes.Alias | CommandTypes.Function | CommandTypes.Filter | CommandTypes.Cmdlet, nameIsPattern: true))
+ name: "*",
+ CommandTypes.Alias | CommandTypes.Function | CommandTypes.Filter | CommandTypes.Cmdlet,
+ nameIsPattern: true))
{
if (sessionCommand.Visibility == SessionStateEntryVisibility.Public)
{
@@ -2405,7 +2510,8 @@ HashSet GetPublicCommands()
if (moduleImportException != null)
{
runspaceInitTracer.WriteLine(
- "Runspace open failed while loading module: First error {1}", moduleImportException);
+ "Runspace open failed while loading module: First error {1}",
+ moduleImportException);
return moduleImportException;
}
}
@@ -2440,7 +2546,8 @@ HashSet GetPublicCommands()
if (userDriveException != null)
{
runspaceInitTracer.WriteLine(
- "Runspace open failed while processing user drive with error {1}", userDriveException);
+ "Runspace open failed while processing user drive with error {1}",
+ userDriveException);
Exception result = PSTraceSource.NewInvalidOperationException(userDriveException, RemotingErrorIdStrings.UserDriveProcessingThrewTerminatingError, userDriveException.Message);
return result;
@@ -2454,7 +2561,8 @@ HashSet GetPublicCommands()
if (startupScriptException != null)
{
runspaceInitTracer.WriteLine(
- "Runspace open failed while running startup script: First error {1}", startupScriptException);
+ "Runspace open failed while running startup script: First error {1}",
+ startupScriptException);
Exception result = PSTraceSource.NewInvalidOperationException(startupScriptException, RemotingErrorIdStrings.StartupScriptThrewTerminatingError, startupScriptException.Message);
return result;
@@ -2889,7 +2997,8 @@ private RunspaceOpenModuleLoadException ProcessModulesToImport(
version = moduleSpecification.MaximumVersion;
}
- string message = StringUtil.Format(global::Modules.RequiredModuleNotFoundWrongGuidVersion,
+ string message = StringUtil.Format(
+ global::Modules.RequiredModuleNotFoundWrongGuidVersion,
moduleSpecification.Name,
moduleSpecification.Guid,
version);
@@ -2916,15 +3025,17 @@ private RunspaceOpenModuleLoadException ProcessModulesToImport(
foreach (CommandInfo cmd in LookupCommands(commandToMakeVisible, moduleName, initializedRunspace.ExecutionContext))
{
- if (!found) { found = true; }
+ if (!found)
+ {
+ found = true;
+ }
try
{
// Special case for wild card lookups.
// "Import-Module" or "ipmo" cannot be visible when exposing commands via VisibleCmdlets, etc.
if ((cmd.Name.Equals("Import-Module", StringComparison.OrdinalIgnoreCase) &&
- (!string.IsNullOrEmpty(cmd.ModuleName) && cmd.ModuleName.Equals("Microsoft.PowerShell.Core", StringComparison.OrdinalIgnoreCase))
- ) ||
+ (!string.IsNullOrEmpty(cmd.ModuleName) && cmd.ModuleName.Equals("Microsoft.PowerShell.Core", StringComparison.OrdinalIgnoreCase))) ||
cmd.Name.Equals("ipmo", StringComparison.OrdinalIgnoreCase)
)
{
@@ -2936,8 +3047,10 @@ private RunspaceOpenModuleLoadException ProcessModulesToImport(
publicCommands.Add(cmd);
}
}
- // Some CommandInfo derivations throw on the Visibility setter.
- catch (PSNotImplementedException) { }
+ catch (PSNotImplementedException)
+ {
+ // Some CommandInfo derivations throw on the Visibility setter.
+ }
}
if (found && !WildcardPattern.ContainsWildcardCharacters(commandToMakeVisible))
@@ -2968,7 +3081,7 @@ private IEnumerable LookupCommands(
ExecutionContext context)
{
bool isWildCardPattern = WildcardPattern.ContainsWildcardCharacters(commandPattern);
- var searchOptions = (isWildCardPattern) ?
+ var searchOptions = isWildCardPattern ?
SearchResolutionOptions.CommandNameIsPattern | SearchResolutionOptions.ResolveFunctionPatterns | SearchResolutionOptions.SearchAllScopes :
SearchResolutionOptions.ResolveFunctionPatterns | SearchResolutionOptions.SearchAllScopes;
@@ -2987,12 +3100,18 @@ private IEnumerable LookupCommands(
continue;
}
- if (!found) { found = true; }
+ if (!found)
+ {
+ found = true;
+ }
yield return commandInfo;
// Return first match unless a wild card pattern is submitted.
- if (!isWildCardPattern) { break; }
+ if (!isWildCardPattern)
+ {
+ break;
+ }
}
if (found || (cmdOrigin == CommandOrigin.Internal))
@@ -3065,7 +3184,9 @@ private RunspaceOpenModuleLoadException ProcessOneModule(Runspace initializedRun
if (this.DefaultCommandVisibility != SessionStateEntryVisibility.Public)
{
foreach (CommandInfo importedCommand in initializedRunspace.ExecutionContext.SessionState.InvokeCommand.GetCommands(
- "*", CommandTypes.Alias | CommandTypes.Function | CommandTypes.Filter | CommandTypes.Cmdlet, true))
+ name: "*",
+ CommandTypes.Alias | CommandTypes.Function | CommandTypes.Filter | CommandTypes.Cmdlet,
+ true))
{
try
{
@@ -3076,8 +3197,10 @@ private RunspaceOpenModuleLoadException ProcessOneModule(Runspace initializedRun
importedCommand.Visibility = this.DefaultCommandVisibility;
}
}
- // Some CommandInfo derivations throw on the Visibility setter.
- catch (PSNotImplementedException) { }
+ catch (PSNotImplementedException)
+ {
+ // Some CommandInfo derivations throw on the Visibility setter.
+ }
}
}
@@ -3140,8 +3263,11 @@ internal void ResetRunspaceState(ExecutionContext context)
// Add the built-in variables
foreach (SessionStateVariableEntry e in InitialSessionState.BuiltInVariables)
{
- PSVariable v = new PSVariable(e.Name, e.Value,
- e.Options, e.Attributes, e.Description)
+ PSVariable v = new PSVariable(
+ e.Name,
+ e.Value,
+ e.Options, e.Attributes,
+ e.Description)
{ Visibility = e.Visibility };
ss.GlobalScope.SetVariable(e.Name, v, false, true, ss, fastPath: true);
}
@@ -3151,8 +3277,12 @@ internal void ResetRunspaceState(ExecutionContext context)
// Then re-initialize it with variables to session state...
foreach (SessionStateVariableEntry e in Variables)
{
- PSVariable v = new PSVariable(e.Name, e.Value,
- e.Options, e.Attributes, e.Description)
+ PSVariable v = new PSVariable(
+ e.Name,
+ e.Value,
+ e.Options,
+ e.Attributes,
+ e.Description)
{ Visibility = e.Visibility };
ss.GlobalScope.SetVariable(e.Name, v, false, true, ss, fastPath: true);
}
@@ -3454,10 +3584,15 @@ internal void UpdateTypes(ExecutionContext context, bool updateOnly)
ConcurrentBag errors = new ConcurrentBag();
// Use at most 3 locks (we don't expect contention on that many cores anyways,
// and typically we'll be processing just 2 or 3 files anyway, hence capacity=3.
- ConcurrentDictionary filesProcessed
- = new ConcurrentDictionary(/*concurrencyLevel*/3, /*capacity*/3, StringComparer.OrdinalIgnoreCase);
- Parallel.ForEach(Types, sste =>
- {
+ ConcurrentDictionary filesProcessed = new ConcurrentDictionary(
+ concurrencyLevel: 3,
+ capacity: 3,
+ StringComparer.OrdinalIgnoreCase);
+ Parallel.ForEach(
+ Types,
+ sste =>
+ {
+ // foreach (var sste in Types)
if (sste.FileName != null)
{
if (filesProcessed.TryAdd(sste.FileName, null))
@@ -3469,8 +3604,7 @@ ConcurrentDictionary filesProcessed
}
bool unused;
- context.TypeTable.Update(moduleName, sste.FileName, errors,
- context.AuthorizationManager, context.EngineHostInterface, out unused);
+ context.TypeTable.Update(moduleName, sste.FileName, errors, context.AuthorizationManager, context.EngineHostInterface, out unused);
}
}
else if (sste.TypeTable != null)
@@ -3652,7 +3786,7 @@ public PSSnapInInfo ImportPSSnapIn(string name, out PSSnapInException warning)
{
if (string.IsNullOrEmpty(name))
{
- PSTraceSource.NewArgumentNullException("name");
+ PSTraceSource.NewArgumentException(nameof(name));
}
// Check whether the mshsnapin is present in the registry.
@@ -3664,10 +3798,11 @@ public PSSnapInInfo ImportPSSnapIn(string name, out PSSnapInException warning)
{
s_PSSnapInTracer.TraceError("MshSnapin {0} and current monad engine's versions don't match.", name);
- throw PSTraceSource.NewArgumentException("mshSnapInID",
- ConsoleInfoErrorStrings.AddPSSnapInBadMonadVersion,
- newPSSnapIn.PSVersion.ToString(),
- "2.0");
+ throw PSTraceSource.NewArgumentException(
+ "mshSnapInID",
+ ConsoleInfoErrorStrings.AddPSSnapInBadMonadVersion,
+ newPSSnapIn.PSVersion.ToString(),
+ "2.0");
}
// Now actually load the snapin...
@@ -3734,7 +3869,7 @@ internal PSSnapInInfo ImportPSSnapIn(PSSnapInInfo psSnapInInfo, out PSSnapInExce
if (psSnapInInfo == null)
{
- ArgumentNullException e = new ArgumentNullException("psSnapInInfo");
+ ArgumentNullException e = new ArgumentNullException(nameof(psSnapInInfo));
throw e;
}
@@ -3794,8 +3929,7 @@ internal PSSnapInInfo ImportPSSnapIn(PSSnapInInfo psSnapInInfo, out PSSnapInExce
this.Formats.Add(formatEntry);
}
- SessionStateAssemblyEntry assemblyEntry =
- new SessionStateAssemblyEntry(psSnapInInfo.AssemblyName, psSnapInInfo.AbsoluteModulePath);
+ SessionStateAssemblyEntry assemblyEntry = new SessionStateAssemblyEntry(psSnapInInfo.AssemblyName, psSnapInInfo.AbsoluteModulePath);
assemblyEntry.SetPSSnapIn(psSnapInInfo);
@@ -3911,7 +4045,7 @@ internal void ImportCmdletsFromAssembly(Assembly assembly, PSModuleInfo module)
{
if (assembly == null)
{
- ArgumentNullException e = new ArgumentNullException("assembly");
+ ArgumentNullException e = new ArgumentNullException(nameof(assembly));
throw e;
}
@@ -3926,8 +4060,7 @@ internal void ImportCmdletsFromAssembly(Assembly assembly, PSModuleInfo module)
// since it can't be loaded by path or name
if (!string.IsNullOrEmpty(assembly.Location))
{
- SessionStateAssemblyEntry assemblyEntry =
- new SessionStateAssemblyEntry(assembly.FullName, assemblyPath);
+ SessionStateAssemblyEntry assemblyEntry = new SessionStateAssemblyEntry(assembly.FullName, assemblyPath);
this.Assemblies.Add(assemblyEntry);
}
@@ -3959,9 +4092,7 @@ internal void ImportCmdletsFromAssembly(Assembly assembly, PSModuleInfo module)
}
}
- //
// Now define a bunch of functions that describe the rest of the default session state...
- //
internal const string FormatEnumerationLimit = "FormatEnumerationLimit";
internal const int DefaultFormatEnumerationLimit = 4;
@@ -4288,16 +4419,16 @@ .ForwardHelpCategory Cmdlet
";
}
- internal const ActionPreference defaultDebugPreference = ActionPreference.SilentlyContinue;
- internal const ActionPreference defaultErrorActionPreference = ActionPreference.Continue;
- internal const ActionPreference defaultProgressPreference = ActionPreference.Continue;
- internal const ActionPreference defaultVerbosePreference = ActionPreference.SilentlyContinue;
- internal const ActionPreference defaultWarningPreference = ActionPreference.Continue;
- internal const ActionPreference defaultInformationPreference = ActionPreference.SilentlyContinue;
+ internal const ActionPreference DefaultDebugPreference = ActionPreference.SilentlyContinue;
+ internal const ActionPreference DefaultErrorActionPreference = ActionPreference.Continue;
+ internal const ActionPreference DefaultProgressPreference = ActionPreference.Continue;
+ internal const ActionPreference DefaultVerbosePreference = ActionPreference.SilentlyContinue;
+ internal const ActionPreference DefaultWarningPreference = ActionPreference.Continue;
+ internal const ActionPreference DefaultInformationPreference = ActionPreference.SilentlyContinue;
- internal const ErrorView defaultErrorView = ErrorView.NormalView;
- internal const bool defaultWhatIfPreference = false;
- internal const ConfirmImpact defaultConfirmPreference = ConfirmImpact.High;
+ internal const ErrorView DefaultErrorView = ErrorView.NormalView;
+ internal const bool DefaultWhatIfPreference = false;
+ internal const ConfirmImpact DefaultConfirmPreference = ConfirmImpact.High;
internal static SessionStateVariableEntry[] BuiltInVariables = new SessionStateVariableEntry[]
{
@@ -4315,97 +4446,83 @@ .ForwardHelpCategory Cmdlet
Utils.utf8NoBom,
RunspaceInit.OutputEncodingDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(System.Text.Encoding))
- ),
+ new ArgumentTypeConverterAttribute(typeof(System.Text.Encoding))),
// Preferences
-
+ //
// NTRAID#Windows Out Of Band Releases-931461-2006/03/13
// ArgumentTypeConverterAttribute is applied to these variables,
// but this only reaches the global variable. If these are
// redefined in script scope etc, the type conversion
// is not applicable.
-
+ //
// Variables typed to ActionPreference
new SessionStateVariableEntry(
SpecialVariables.ConfirmPreference,
- defaultConfirmPreference,
+ DefaultConfirmPreference,
RunspaceInit.ConfirmPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ConfirmImpact))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ConfirmImpact))),
new SessionStateVariableEntry(
SpecialVariables.DebugPreference,
- defaultDebugPreference,
+ DefaultDebugPreference,
RunspaceInit.DebugPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorActionPreference,
- defaultErrorActionPreference,
+ DefaultErrorActionPreference,
RunspaceInit.ErrorActionPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ProgressPreference,
- defaultProgressPreference,
+ DefaultProgressPreference,
RunspaceInit.ProgressPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.VerbosePreference,
- defaultVerbosePreference,
+ DefaultVerbosePreference,
RunspaceInit.VerbosePreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.WarningPreference,
- defaultWarningPreference,
+ DefaultWarningPreference,
RunspaceInit.WarningPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.InformationPreference,
- defaultInformationPreference,
+ DefaultInformationPreference,
RunspaceInit.InformationPreferenceDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ActionPreference))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ActionPreference))),
new SessionStateVariableEntry(
SpecialVariables.ErrorView,
- ExperimentalFeature.IsEnabled("PSErrorView") ? ErrorView.ConciseView : defaultErrorView,
+ ExperimentalFeature.IsEnabled("PSErrorView") ? ErrorView.ConciseView : DefaultErrorView,
RunspaceInit.ErrorViewDescription,
ScopedItemOptions.None,
- new ArgumentTypeConverterAttribute(typeof(ErrorView))
- ),
+ new ArgumentTypeConverterAttribute(typeof(ErrorView))),
new SessionStateVariableEntry(
SpecialVariables.NestedPromptLevel,
0,
- RunspaceInit.NestedPromptLevelDescription
- ),
-
+ RunspaceInit.NestedPromptLevelDescription),
new SessionStateVariableEntry(
SpecialVariables.WhatIfPreference,
- defaultWhatIfPreference,
- RunspaceInit.WhatIfPreferenceDescription
- ),
+ DefaultWhatIfPreference,
+ RunspaceInit.WhatIfPreferenceDescription),
new SessionStateVariableEntry(
FormatEnumerationLimit,
DefaultFormatEnumerationLimit,
- RunspaceInit.FormatEnumerationLimitDescription
- ),
+ RunspaceInit.FormatEnumerationLimitDescription),
// variable for PSEmailServer
new SessionStateVariableEntry(
SpecialVariables.PSEmailServer,
string.Empty,
- RunspaceInit.PSEmailServerDescription
- ),
+ RunspaceInit.PSEmailServerDescription),
// Start: Variables which control remoting behavior
new SessionStateVariableEntry(
@@ -4725,51 +4842,51 @@ internal static void RemoveAllDrivesForProvider(ProviderInfo pi, SessionStateInt
// The list of engine modules to create warnings when you try to remove them
internal static HashSet EngineModules = new HashSet(StringComparer.OrdinalIgnoreCase)
- {
- "Microsoft.PowerShell.Utility",
- "Microsoft.PowerShell.Management",
- "Microsoft.PowerShell.Diagnostics",
- "Microsoft.PowerShell.Host",
- "Microsoft.PowerShell.Security",
- "Microsoft.WSMan.Management"
- };
+ {
+ "Microsoft.PowerShell.Utility",
+ "Microsoft.PowerShell.Management",
+ "Microsoft.PowerShell.Diagnostics",
+ "Microsoft.PowerShell.Host",
+ "Microsoft.PowerShell.Security",
+ "Microsoft.WSMan.Management"
+ };
internal static HashSet NestedEngineModules = new HashSet(StringComparer.OrdinalIgnoreCase)
- {
- "Microsoft.PowerShell.Commands.Utility",
- "Microsoft.PowerShell.Commands.Management",
- "Microsoft.PowerShell.Commands.Diagnostics",
- "Microsoft.PowerShell.ConsoleHost"
- };
+ {
+ "Microsoft.PowerShell.Commands.Utility",
+ "Microsoft.PowerShell.Commands.Management",
+ "Microsoft.PowerShell.Commands.Diagnostics",
+ "Microsoft.PowerShell.ConsoleHost"
+ };
internal static Dictionary EngineModuleNestedModuleMapping = new Dictionary(StringComparer.OrdinalIgnoreCase)
- {
- { "Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Commands.Utility"},
- { "Microsoft.PowerShell.Management", "Microsoft.PowerShell.Commands.Management"},
- { "Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics"},
- { "Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost"},
- };
+ {
+ { "Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Commands.Utility"},
+ { "Microsoft.PowerShell.Management", "Microsoft.PowerShell.Commands.Management"},
+ { "Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics"},
+ { "Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost"},
+ };
internal static Dictionary NestedModuleEngineModuleMapping = new Dictionary(StringComparer.OrdinalIgnoreCase)
- {
- { "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.Utility"},
- { "Microsoft.PowerShell.Commands.Management", "Microsoft.PowerShell.Management"},
- { "Microsoft.PowerShell.Commands.Diagnostics", "Microsoft.PowerShell.Diagnostics"},
- { "Microsoft.PowerShell.ConsoleHost", "Microsoft.PowerShell.Host"},
- { "Microsoft.PowerShell.Security", "Microsoft.PowerShell.Security"},
- { "Microsoft.WSMan.Management", "Microsoft.WSMan.Management"},
- };
+ {
+ { "Microsoft.PowerShell.Commands.Utility", "Microsoft.PowerShell.Utility"},
+ { "Microsoft.PowerShell.Commands.Management", "Microsoft.PowerShell.Management"},
+ { "Microsoft.PowerShell.Commands.Diagnostics", "Microsoft.PowerShell.Diagnostics"},
+ { "Microsoft.PowerShell.ConsoleHost", "Microsoft.PowerShell.Host"},
+ { "Microsoft.PowerShell.Security", "Microsoft.PowerShell.Security"},
+ { "Microsoft.WSMan.Management", "Microsoft.WSMan.Management"},
+ };
// The list of engine modules that we will not allow users to remove
internal static HashSet ConstantEngineModules = new HashSet(StringComparer.OrdinalIgnoreCase)
- {
- CoreModule,
- };
+ {
+ CoreModule,
+ };
// The list of nested engine modules that we will not allow users to remove
internal static HashSet ConstantEngineNestedModules = new HashSet(StringComparer.OrdinalIgnoreCase)
- {
- "System.Management.Automation",
- };
+ {
+ "System.Management.Automation",
+ };
internal static string GetNestedModuleDllName(string moduleName)
{
@@ -5085,7 +5202,10 @@ private static void AnalyzeModuleAssemblyWithReflection(
foreach (Type type in assemblyTypes)
{
- if (!HasDefaultConstructor(type)) { continue; }
+ if (!HasDefaultConstructor(type))
+ {
+ continue;
+ }
// Check for cmdlets
if (IsCmdletClass(type) && TryGetCustomAttribute(type, out CmdletAttribute cmdletAttribute))
@@ -5106,9 +5226,15 @@ private static void AnalyzeModuleAssemblyWithReflection(
}
SessionStateCmdletEntry cmdlet = new SessionStateCmdletEntry(cmdletName, type, helpFile);
- if (psSnapInInfo != null) { cmdlet.SetPSSnapIn(psSnapInInfo); }
+ if (psSnapInInfo != null)
+ {
+ cmdlet.SetPSSnapIn(psSnapInInfo);
+ }
- if (moduleInfo != null) { cmdlet.SetModule(moduleInfo); }
+ if (moduleInfo != null)
+ {
+ cmdlet.SetModule(moduleInfo);
+ }
cmdlets = cmdlets ?? new Dictionary(StringComparer.OrdinalIgnoreCase);
cmdlets.Add(cmdletName, cmdlet);
@@ -5126,7 +5252,10 @@ private static void AnalyzeModuleAssemblyWithReflection(
var aliasEntry = new SessionStateAliasEntry(alias, cmdletName, description: string.Empty, ScopedItemOptions.None);
if (psSnapInInfo != null) { aliasEntry.SetPSSnapIn(psSnapInInfo); }
- if (moduleInfo != null) { aliasEntry.SetModule(moduleInfo); }
+ if (moduleInfo != null)
+ {
+ aliasEntry.SetModule(moduleInfo);
+ }
aliasList.Add(aliasEntry);
}
@@ -5155,9 +5284,15 @@ private static void AnalyzeModuleAssemblyWithReflection(
}
SessionStateProviderEntry provider = new SessionStateProviderEntry(providerName, type, helpFile);
- if (psSnapInInfo != null) { provider.SetPSSnapIn(psSnapInInfo); }
+ if (psSnapInInfo != null)
+ {
+ provider.SetPSSnapIn(psSnapInInfo);
+ }
- if (moduleInfo != null) { provider.SetModule(moduleInfo); }
+ if (moduleInfo != null)
+ {
+ provider.SetModule(moduleInfo);
+ }
providers = providers ?? new Dictionary(StringComparer.OrdinalIgnoreCase);
providers.Add(providerName, provider);
@@ -5167,6 +5302,7 @@ private static void AnalyzeModuleAssemblyWithReflection(
}
}
+ [SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1001:CommasMustBeSpacedCorrectly", Justification = "Reviewed.")]
private static void InitializeCoreCmdletsAndProviders(
PSSnapInInfo psSnapInInfo,
out Dictionary cmdlets,
@@ -5307,12 +5443,14 @@ internal static IEnumerable GetAssemblyTypes(Assembly assembly, string nam
}
// cmdletCache holds the list of cmdlets along with its aliases per each assembly.
- private static Lazy>>>> s_cmdletCache =
+ private static readonly Lazy>>>> s_cmdletCache =
new Lazy>>>>();
- private static Lazy>> s_providerCache =
+
+ private static readonly Lazy>> s_providerCache =
new Lazy>>();
+
// Using a ConcurrentDictionary for this so that we can avoid having a private lock variable. We use only the keys for checking.
- private static Lazy> s_assembliesWithModuleInitializerCache = new Lazy>();
+ private static readonly Lazy> s_assembliesWithModuleInitializerCache = new Lazy>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsCmdletClass(Type type)
diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs
index cf1260f1fc9..19c328785d8 100644
--- a/src/System.Management.Automation/engine/MshCommandRuntime.cs
+++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs
@@ -2927,7 +2927,7 @@ internal void _WriteErrorSkipAllowCheck(ErrorRecord errorRecord, ActionPreferenc
// See "User Feedback Mechanisms - Note.doc" for details.
private bool _isConfirmPreferenceCached = false;
- private ConfirmImpact _confirmPreference = InitialSessionState.defaultConfirmPreference;
+ private ConfirmImpact _confirmPreference = InitialSessionState.DefaultConfirmPreference;
///
/// Preference setting controlling behavior of ShouldProcess()
///
@@ -2967,7 +2967,7 @@ internal ConfirmImpact ConfirmPreference
}
private bool _isDebugPreferenceSet = false;
- private ActionPreference _debugPreference = InitialSessionState.defaultDebugPreference;
+ private ActionPreference _debugPreference = InitialSessionState.DefaultDebugPreference;
private bool _isDebugPreferenceCached = false;
///
/// Preference setting.
@@ -3021,7 +3021,7 @@ internal ActionPreference DebugPreference
}
private bool _isVerbosePreferenceCached = false;
- private ActionPreference _verbosePreference = InitialSessionState.defaultVerbosePreference;
+ private ActionPreference _verbosePreference = InitialSessionState.DefaultVerbosePreference;
///
/// Preference setting.
///
@@ -3070,7 +3070,7 @@ internal ActionPreference VerbosePreference
internal bool IsWarningActionSet { get; private set; } = false;
private bool _isWarningPreferenceCached = false;
- private ActionPreference _warningPreference = InitialSessionState.defaultWarningPreference;
+ private ActionPreference _warningPreference = InitialSessionState.DefaultWarningPreference;
///
/// Preference setting.
///
@@ -3209,7 +3209,7 @@ internal bool Debug
internal bool IsDebugFlagSet { get; private set; } = false;
- private bool _whatIfFlag = InitialSessionState.defaultWhatIfPreference;
+ private bool _whatIfFlag = InitialSessionState.DefaultWhatIfPreference;
private bool _isWhatIfPreferenceCached /* = false */;
///
/// WhatIf indicates that the command should not
@@ -3241,7 +3241,7 @@ internal SwitchParameter WhatIf
internal bool IsWhatIfFlagSet { get; private set; }
- private ActionPreference _errorAction = InitialSessionState.defaultErrorActionPreference;
+ private ActionPreference _errorAction = InitialSessionState.DefaultErrorActionPreference;
private bool _isErrorActionPreferenceCached = false;
///
/// ErrorAction tells the command what to do when an error occurs.
@@ -3317,7 +3317,7 @@ internal ActionPreference ProgressPreference
}
}
- private ActionPreference _progressPreference = InitialSessionState.defaultProgressPreference;
+ private ActionPreference _progressPreference = InitialSessionState.DefaultProgressPreference;
private bool _isProgressPreferenceSet = false;
private bool _isProgressPreferenceCached = false;
@@ -3354,7 +3354,7 @@ internal ActionPreference InformationPreference
}
}
- private ActionPreference _informationPreference = InitialSessionState.defaultInformationPreference;
+ private ActionPreference _informationPreference = InitialSessionState.DefaultInformationPreference;
internal bool IsInformationActionSet { get; private set; } = false;