Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Microsoft.PowerShell.Security/security/CmsCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ protected override void EndProcessing()
{
StringBuilder outputString = new StringBuilder();

Collection<PSObject> output = System.Management.Automation.PowerShell.Create().
AddCommand("Microsoft.PowerShell.Utility\\Out-String").
AddParameter("Stream").
Invoke(_inputObjects);
Collection<PSObject> output = System.Management.Automation.PowerShell.Create()
.AddCommand("Microsoft.PowerShell.Utility\\Out-String")
.AddParameter("Stream")
.Invoke(_inputObjects);

foreach (PSObject outputObject in output)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ internal static int FormatEnumerationLimit()
// Win8: 192504
if (LocalPipeline.GetExecutionContextFromTLS() != null)
{
enumLimitVal = LocalPipeline.GetExecutionContextFromTLS().SessionState.PSVariable.
GetValue("global:" + InitialSessionState.FormatEnumerationLimit);
enumLimitVal = LocalPipeline.GetExecutionContextFromTLS()
.SessionState.PSVariable
.GetValue("global:" + InitialSessionState.FormatEnumerationLimit);
}
}
// Eat the following exceptions, enumerationLimit will use the default value
Expand Down
9 changes: 4 additions & 5 deletions src/System.Management.Automation/engine/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1675,11 +1675,10 @@ protected override void ValidateElement(object element)
string objString = element.ToString();
foreach (string setString in ValidValues)
{
if (CultureInfo.InvariantCulture.
CompareInfo.Compare(setString, objString,
IgnoreCase
? CompareOptions.IgnoreCase
: CompareOptions.None) == 0)
if (CultureInfo.InvariantCulture.CompareInfo.Compare(
setString,
objString,
IgnoreCase ? CompareOptions.IgnoreCase : CompareOptions.None) == 0)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1490,9 +1490,9 @@ public IEnumerable<CompletionResult> CompleteArgument(string commandName, string
}

var commandInfo = new CmdletInfo("Get-Command", typeof(GetCommandCommand));
var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace).
AddCommand(commandInfo).
AddParameter("Noun", wordToComplete + "*");
var ps = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)
.AddCommand(commandInfo)
.AddParameter("Noun", wordToComplete + "*");

if (fakeBoundParameters.Contains("Module"))
{
Expand Down
43 changes: 25 additions & 18 deletions src/System.Management.Automation/engine/InternalCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,20 +1589,24 @@ protected override void ProcessRecord()
{
// The binary operation is specified explicitly by the user and the -Value parameter is
// not specified
ThrowTerminatingError(ForEachObjectCommand.
GenerateNameParameterError("Value",
InternalCommandStrings.ValueNotSpecifiedForWhereObject,
"ValueNotSpecifiedForWhereObject", null));
ThrowTerminatingError(
ForEachObjectCommand.GenerateNameParameterError(
"Value",
InternalCommandStrings.ValueNotSpecifiedForWhereObject,
"ValueNotSpecifiedForWhereObject",
target: null));
}

// The binary operation needs to be specified if the user specifies both the -Property and -Value
if (!_valueNotSpecified && (_binaryOperator == TokenKind.Ieq && _forceBooleanEvaluation))
{
// The -Property and -Value are specified explicitly by the user but the binary operation is not
ThrowTerminatingError(ForEachObjectCommand.
GenerateNameParameterError("Operator",
InternalCommandStrings.OperatorNotSpecified,
"OperatorNotSpecified", null));
ThrowTerminatingError(
ForEachObjectCommand.GenerateNameParameterError(
"Operator",
InternalCommandStrings.OperatorNotSpecified,
"OperatorNotSpecified",
target: null));
}

bool strictModeWithError = false;
Expand Down Expand Up @@ -1654,11 +1658,12 @@ private object GetValue(ref bool error)
if (Context.IsStrictVersion(2))
{
WriteError(
ForEachObjectCommand.
GenerateNameParameterError("InputObject",
InternalCommandStrings.InputObjectIsNull,
"InputObjectIsNull", _inputObject,
_property));
ForEachObjectCommand.GenerateNameParameterError(
"InputObject",
InternalCommandStrings.InputObjectIsNull,
"InputObjectIsNull",
_inputObject,
_property));
error = true;
}
return null;
Expand Down Expand Up @@ -1695,11 +1700,13 @@ private object GetValue(ref bool error)
}

WriteError(
ForEachObjectCommand.
GenerateNameParameterError("Property",
InternalCommandStrings.AmbiguousPropertyOrMethodName,
"AmbiguousPropertyName", _inputObject,
_property, possibleMatches));
ForEachObjectCommand.GenerateNameParameterError(
"Property",
InternalCommandStrings.AmbiguousPropertyOrMethodName,
"AmbiguousPropertyName",
_inputObject,
_property,
possibleMatches));
error = true;
}
else if (members.Count == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4667,8 +4667,13 @@ internal static String ResolveRootedFilePath(string filePath, ExecutionContext c
if (!provider.NameEquals(context.ProviderNames.FileSystem))
{
// "The current provider ({0}) cannot open a file"
throw InterpreterError.NewInterpreterException(filePath, typeof(RuntimeException),
null, "FileOpenError", ParserStrings.FileOpenError, provider.FullName);
throw InterpreterError.NewInterpreterException(
filePath,
typeof(RuntimeException),
errorPosition: null,
"FileOpenError",
ParserStrings.FileOpenError,
provider.FullName);
}
}

Expand All @@ -4681,9 +4686,12 @@ internal static String ResolveRootedFilePath(string filePath, ExecutionContext c
if (filePaths.Count > 1)
{
// "The path resolved to more than one file; can only process one file at a time."
throw InterpreterError.
NewInterpreterException(filePaths, typeof(RuntimeException),
null, "AmbiguousPath", ParserStrings.AmbiguousPath);
throw InterpreterError.NewInterpreterException(
filePaths,
typeof(RuntimeException),
errorPosition: null,
"AmbiguousPath",
ParserStrings.AmbiguousPath);
}

return filePaths[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ private FlowControlException InvokeHelper()
// Set Informational Buffers on the host only if this is not a child.
// Do not overwrite parent's informational buffers.
if (!this.IsChild)
LocalRunspace.ExecutionContext.InternalHost.
InternalUI.SetInformationalMessageBuffers(InformationalBuffers);
{
LocalRunspace.ExecutionContext.InternalHost.InternalUI.SetInformationalMessageBuffers(InformationalBuffers);
}

bool oldQuestionMarkValue = true;
bool savedIgnoreScriptDebug = this.LocalRunspace.ExecutionContext.IgnoreScriptDebug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,7 @@ public override void StartJob()
ExecutionError.Add(
new ErrorRecord(e.Error,
"ContainerParentJobStartError",
ErrorCategory.
InvalidResult,
ErrorCategory.InvalidResult,
childJob));
_tracer.WriteMessage(TraceClassName, "StartJob-Handler", Guid.Empty, this,
"Child job asynchronously had error, child InstanceId: {0}", childJob.InstanceId.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ internal ClientPowerShellDataStructureHandler CreatePowerShellDataStructureHandl
ClientRemotePowerShell shell)
{
BaseClientCommandTransportManager clientTransportMgr =
RemoteSession.SessionDataStructureHandler.
CreateClientCommandTransportManager(shell, shell.NoInput);
RemoteSession.SessionDataStructureHandler.CreateClientCommandTransportManager(shell, shell.NoInput);

return new ClientPowerShellDataStructureHandler(
clientTransportMgr, _clientRunspacePoolId, shell.InstanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ internal static ExecutionContextForStepping PrepareExecutionContext(
= ctxt.InternalHost.InternalUI.GetInformationalMessageBuffers();
result._originalHost = ctxt.InternalHost.ExternalHost;

ctxt.InternalHost.
InternalUI.SetInformationalMessageBuffers(newBuffers);
ctxt.InternalHost.InternalUI.SetInformationalMessageBuffers(newBuffers);
ctxt.InternalHost.SetHostRef(newHost);

return result;
Expand All @@ -48,8 +47,7 @@ internal static ExecutionContextForStepping PrepareExecutionContext(
// resetting unmanaged resources.
void IDisposable.Dispose()
{
_executionContext.InternalHost.
InternalUI.SetInformationalMessageBuffers(_originalInformationalBuffers);
_executionContext.InternalHost.InternalUI.SetInformationalMessageBuffers(_originalInformationalBuffers);
_executionContext.InternalHost.SetHostRef(_originalHost);
GC.SuppressFinalize(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,7 @@ internal override void Bind(PipelineProcessor pipelineProcessor, CommandProcesso
// context.CurrentCommandProcessor will be null. We don't try passing along variable lists in such case.
if (context.CurrentCommandProcessor != null)
{
context.CurrentCommandProcessor.CommandRuntime.
OutputPipe.SetVariableListForTemporaryPipe(pipe);
context.CurrentCommandProcessor.CommandRuntime.OutputPipe.SetVariableListForTemporaryPipe(pipe);
}

commandProcessor.CommandRuntime.OutputPipe = pipe;
Expand All @@ -1036,8 +1035,7 @@ internal override void Bind(PipelineProcessor pipelineProcessor, CommandProcesso
// Since a temp output pipe is going to be used, we should pass along the error and warning variable list.
if (context.CurrentCommandProcessor != null)
{
context.CurrentCommandProcessor.CommandRuntime.
OutputPipe.SetVariableListForTemporaryPipe(pipe);
context.CurrentCommandProcessor.CommandRuntime.OutputPipe.SetVariableListForTemporaryPipe(pipe);
}

commandProcessor.CommandRuntime.OutputPipe = pipe;
Expand Down
8 changes: 4 additions & 4 deletions src/System.Management.Automation/help/HelpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -792,10 +792,10 @@ Uri result in
// 2. This method is primarily used to get uri faster while serializing the CommandInfo objects (from Get-Command)
// 3. Exchange uses Get-Help proxy to not call Get-Help cmdlet at-all while serializing CommandInfo objects
// 4. Using HelpSystem directly will not allow Get-Help proxy to do its job.
System.Management.Automation.PowerShell getHelpPS = System.Management.Automation.PowerShell.Create(
RunspaceMode.CurrentRunspace).AddCommand("get-help").
AddParameter("Name", cmdName).AddParameter("Category",
cmdInfo.HelpCategory.ToString());
var getHelpPS = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace)
.AddCommand("get-help")
.AddParameter("Name", cmdName)
.AddParameter("Category", cmdInfo.HelpCategory.ToString());
try
{
Collection<PSObject> helpInfos = getHelpPS.Invoke();
Expand Down
22 changes: 3 additions & 19 deletions src/System.Management.Automation/namespaces/LocationGlobber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3435,12 +3435,7 @@ private List<string> GenerateNewPSPathsWithGlobLeaf(
{
string parentPath = RemoveMshQualifier(mshQualifiedParentPath, drive);

childPath =
_sessionState.Internal.
MakePath(
parentPath,
child,
context);
childPath = _sessionState.Internal.MakePath(parentPath, child, context);

childPath = GetMshQualifiedPath(childPath, drive);
}
Expand Down Expand Up @@ -3487,13 +3482,7 @@ private List<string> GenerateNewPSPathsWithGlobLeaf(
{
string parentPath = RemoveMshQualifier(resolvedPath, drive);

childPath =
_sessionState.Internal.
MakePath(
parentPath,
backslashEscapedLeafElement,
context);

childPath = _sessionState.Internal.MakePath(parentPath, backslashEscapedLeafElement, context);
childPath = GetMshQualifiedPath(childPath, drive);
}

Expand Down Expand Up @@ -4033,12 +4022,7 @@ internal List<string> GenerateNewPathsWithGlobLeaf(

if (navigationProvider != null)
{
childPath =
navigationProvider.
MakePath(
unescapedDir,
child,
context);
childPath = navigationProvider.MakePath(unescapedDir, child, context);
}

s_tracer.WriteLine("Adding child path to dirs {0}", childPath);
Expand Down