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
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ private List<string> TestRestartStageUsingWsman(IEnumerable<string> computerName
{
try
{
if (token.IsCancellationRequested) { break; }
if (token.IsCancellationRequested)
{
break;
}

using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, Credential, WsmanAuthentication, isLocalHost: false, this, token))
{
Expand Down Expand Up @@ -675,7 +678,10 @@ internal static List<string> TestWmiConnectionUsingWsman(List<string> computerNa
{
try
{
if (token.IsCancellationRequested) { break; }
if (token.IsCancellationRequested)
{
break;
}

using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, credential, wsmanAuthentication, isLocalHost: false, cmdlet, token))
{
Expand Down Expand Up @@ -830,7 +836,10 @@ protected override void ProcessRecord()
ValidateComputerNames();

object[] flags = new object[] { 2, 0 };
if (Force) flags[0] = forcedReboot;
if (Force)
{
flags[0] = forcedReboot;
}

if (ParameterSetName.Equals(DefaultParameterSet, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -905,14 +914,18 @@ protected override void ProcessRecord()

while (true)
{
int loopCount = actualDelay * 4; // (delay * 1000)/250ms
// (delay * 1000)/250ms
int loopCount = actualDelay * 4;
while (loopCount > 0)
{
WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing);

loopCount--;
_waitHandler.Wait(250);
if (_exit) { break; }
if (_exit)
{
break;
}
}

if (first)
Expand All @@ -932,7 +945,10 @@ protected override void ProcessRecord()
// Test restart stage.
// We check if the target machine has already rebooted by querying the LastBootUpTime from the Win32_OperatingSystem object.
// So after this step, we are sure that both the Network and the WMI or WinRM service have already come up.
if (_exit) { break; }
if (_exit)
{
break;
}

if (restartStageTestList.Count > 0)
{
Expand All @@ -948,7 +964,10 @@ protected override void ProcessRecord()
}

// Test WMI service
if (_exit) { break; }
if (_exit)
{
break;
}

if (wmiTestList.Count > 0)
{
Expand All @@ -966,10 +985,16 @@ protected override void ProcessRecord()
}
}

if (isForWmi) { break; }
if (isForWmi)
{
break;
}

// Test WinRM service
if (_exit) { break; }
if (_exit)
{
break;
}

if (winrmTestList.Count > 0)
{
Expand All @@ -994,16 +1019,25 @@ protected override void ProcessRecord()

loopCount--;
_waitHandler.Wait(250);
if (_exit) { break; }
if (_exit)
{
break;
}
}
}
}
}

if (isForWinRm) { break; }
if (isForWinRm)
{
break;
}

// Test PowerShell
if (_exit) { break; }
if (_exit)
{
break;
}

if (psTestList.Count > 0)
{
Expand All @@ -1019,7 +1053,10 @@ protected override void ProcessRecord()
} while (false);

// if time is up or Ctrl+c is typed, break out
if (_exit) { break; }
if (_exit)
{
break;
}

// Check if the restart completes
switch (_waitFor)
Expand Down Expand Up @@ -1063,18 +1100,38 @@ protected override void ProcessRecord()
// The timeout expires. Write out timeout error messages for the computers that haven't finished restarting
do
{
if (restartStageTestList.Count > 0) { WriteOutTimeoutError(restartStageTestList); }
if (restartStageTestList.Count > 0)
{
WriteOutTimeoutError(restartStageTestList);
}

if (wmiTestList.Count > 0)
{
WriteOutTimeoutError(wmiTestList);
}

if (wmiTestList.Count > 0) { WriteOutTimeoutError(wmiTestList); }
// Wait for WMI. All computers that finished restarting are put in "winrmTestList"
if (isForWmi) { break; }
if (isForWmi)
{
break;
}

// Wait for WinRM. All computers that finished restarting are put in "psTestList"
if (winrmTestList.Count > 0) { WriteOutTimeoutError(winrmTestList); }
if (winrmTestList.Count > 0)
{
WriteOutTimeoutError(winrmTestList);
}

if (isForWinRm) { break; }
if (isForWinRm)
{
break;
}

if (psTestList.Count > 0)
{
WriteOutTimeoutError(psTestList);
}

if (psTestList.Count > 0) { WriteOutTimeoutError(psTestList); }
// Wait for PowerShell. All computers that finished restarting are put in "allDoneList"
} while (false);
}
Expand Down Expand Up @@ -1221,7 +1278,10 @@ private void ProcessWSManProtocol(object[] flags)
string strLocal = string.Empty;
bool isLocalHost = false;

if (_cancel.Token.IsCancellationRequested) { break; }
if (_cancel.Token.IsCancellationRequested)
{
break;
}

if ((computer.Equals("localhost", StringComparison.OrdinalIgnoreCase)) || (computer.Equals(".", StringComparison.OrdinalIgnoreCase)))
{
Expand Down Expand Up @@ -1576,7 +1636,10 @@ private void DoRenameComputerWsman(string computer, string computerName, string
protected override void ProcessRecord()
{
string targetComputer = ValidateComputerName();
if (targetComputer == null) return;
if (targetComputer == null)
{
return;
}

bool isLocalhost = targetComputer.Equals("localhost", StringComparison.OrdinalIgnoreCase);
if (isLocalhost)
Expand All @@ -1596,7 +1659,10 @@ protected override void ProcessRecord()
/// </summary>
protected override void EndProcessing()
{
if (!_containsLocalHost) return;
if (!_containsLocalHost)
{
return;
}

DoRenameComputerAction("localhost", _newNameForLocalHost, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ private void OutputEvents(string logName)
}
catch (InvalidOperationException e)
{
if (processing) throw;
if (processing)
{
throw;
}

ThrowTerminatingError(new ErrorRecord(
e, // default exception text is OK
"EventLogNotFound",
Expand Down Expand Up @@ -490,7 +494,10 @@ private bool FiltersMatch(EventLogEntry entry)
}
}

if (!entrymatch) return entrymatch;
if (!entrymatch)
{
return entrymatch;
}
}

if (_sources != null)
Expand All @@ -511,7 +518,10 @@ private bool FiltersMatch(EventLogEntry entry)
}
}

if (!sourcematch) return sourcematch;
if (!sourcematch)
{
return sourcematch;
}
}

if (_message != null)
Expand Down Expand Up @@ -545,7 +555,10 @@ private bool FiltersMatch(EventLogEntry entry)
}
}

if (!usernamematch) return usernamematch;
if (!usernamematch)
{
return usernamematch;
}
}

if (_isDateSpecified)
Expand Down Expand Up @@ -582,7 +595,10 @@ private bool FiltersMatch(EventLogEntry entry)
}
}

if (!datematch) return datematch;
if (!datematch)
{
return datematch;
}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ private object InstantiateWebServiceProxy(Assembly assembly)
break;
}

if (proxyType != null) break;
if (proxyType != null)
{
break;
}
}

System.Management.Automation.Diagnostics.Assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@ private void UpdateTypeNames()
// Respect the type shortcut
Type type;
string typeNameInUse = _typeName;
if (LanguagePrimitives.TryConvertTo(_typeName, out type)) { typeNameInUse = type.FullName; }
if (LanguagePrimitives.TryConvertTo(_typeName, out type))
{
typeNameInUse = type.FullName;
}

_inputObject.TypeNames.Insert(0, typeNameInUse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ public string[] ReferencedAssemblies

set
{
if (value != null) { _referencedAssemblies = value; }
if (value != null)
{
_referencedAssemblies = value;
}
}
}

Expand Down Expand Up @@ -867,7 +870,10 @@ private IEnumerable<PortableExecutableReference> GetPortableExecutableReferences
var tempReferences = new List<PortableExecutableReference>(s_autoReferencedAssemblies.Value);
foreach (string assembly in ReferencedAssemblies)
{
if (string.IsNullOrWhiteSpace(assembly)) { continue; }
if (string.IsNullOrWhiteSpace(assembly))
{
continue;
}

string resolvedAssemblyPath = ResolveAssemblyName(assembly, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ private void WaitAndReceiveRunspaceOutput()
// Wait for running script.
_newRunningScriptEvent.Wait();

if (!_debugging) { return; }
if (!_debugging)
{
return;
}

AddDataEventHandlers();

Expand Down Expand Up @@ -503,7 +506,10 @@ private void HandlePowerShellPStreamItem(PSStreamObject streamItem)

private void AddToDebugBlockingCollection(PSStreamObject streamItem)
{
if (!_debugBlockingCollection.IsOpen) { return; }
if (!_debugBlockingCollection.IsOpen)
{
return;
}

if (streamItem != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public sealed class PSRunspaceDebug
/// <param name="runspaceId">Runspace local Id.</param>
public PSRunspaceDebug(bool enabled, bool breakAll, string runspaceName, int runspaceId)
{
if (string.IsNullOrEmpty(runspaceName)) { throw new PSArgumentNullException(nameof(runspaceName)); }
if (string.IsNullOrEmpty(runspaceName))
{
throw new PSArgumentNullException(nameof(runspaceName));
}

this.Enabled = enabled;
this.BreakAll = breakAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ protected override void EndProcessing()
}

object messageSender = null;
if (_sender != null) { messageSender = _sender.BaseObject; }
if (_sender != null)
{
messageSender = _sender.BaseObject;
}

// And then generate the event
WriteObject(Events.GenerateEvent(_sourceIdentifier, messageSender, baseEventArgs, _messageData, true, false));
Expand Down
Loading