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 @@ -2259,19 +2259,40 @@ private string GenerateNewPSSessionOption()
WSManConnectionInfo wsmanConnectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as WSManConnectionInfo;
if (wsmanConnectionInfo != null)
{
if (!wsmanConnectionInfo.UseCompression) { result.Append("-NoCompression "); }
if (!wsmanConnectionInfo.UseCompression)
{
result.Append("-NoCompression ");
}

if (wsmanConnectionInfo.NoEncryption) { result.Append("-NoEncryption "); }
if (wsmanConnectionInfo.NoEncryption)
{
result.Append("-NoEncryption ");
}

if (wsmanConnectionInfo.NoMachineProfile) { result.Append("-NoMachineProfile "); }
if (wsmanConnectionInfo.NoMachineProfile)
{
result.Append("-NoMachineProfile ");
}

if (wsmanConnectionInfo.UseUTF16) { result.Append("-UseUTF16 "); }
if (wsmanConnectionInfo.UseUTF16)
{
result.Append("-UseUTF16 ");
}

if (wsmanConnectionInfo.SkipCACheck) { result.Append("-SkipCACheck "); }
if (wsmanConnectionInfo.SkipCACheck)
{
result.Append("-SkipCACheck ");
}

if (wsmanConnectionInfo.SkipCNCheck) { result.Append("-SkipCNCheck "); }
if (wsmanConnectionInfo.SkipCNCheck)
{
result.Append("-SkipCNCheck ");
}

if (wsmanConnectionInfo.SkipRevocationCheck) { result.Append("-SkipRevocationCheck "); }
if (wsmanConnectionInfo.SkipRevocationCheck)
{
result.Append("-SkipRevocationCheck ");
}

if (wsmanConnectionInfo.MaximumReceivedDataSizePerCommand.HasValue)
{
Expand Down
31 changes: 25 additions & 6 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,10 @@ public override PSHostUserInterface UI
/// </summary>
public void PushRunspace(Runspace newRunspace)
{
if (_runspaceRef == null) { return; }
if (_runspaceRef == null)
{
return;
}

RemoteRunspace remoteRunspace = newRunspace as RemoteRunspace;
Dbg.Assert(remoteRunspace != null, "Expected remoteRunspace != null");
Expand Down Expand Up @@ -744,7 +747,10 @@ public Runspace Runspace
{
get
{
if (this.RunspaceRef == null) { return null; }
if (this.RunspaceRef == null)
{
return null;
}

return this.RunspaceRef.Runspace;
}
Expand All @@ -759,7 +765,10 @@ internal LocalRunspace LocalRunspace
return RunspaceRef.OldRunspace as LocalRunspace;
}

if (RunspaceRef == null) { return null; }
if (RunspaceRef == null)
{
return null;
}

return RunspaceRef.Runspace as LocalRunspace;
}
Expand Down Expand Up @@ -964,7 +973,11 @@ public override PSObject PrivateData
{
get
{
if (ui == null) return null;
if (ui == null)
{
return null;
}

return _consoleColorProxy ??= PSObject.AsPSObject(new ConsoleColorProxy(ui));
}
}
Expand Down Expand Up @@ -1514,7 +1527,10 @@ private uint DoRunspaceLoop(
RunspaceCreationEventArgs args = new RunspaceCreationEventArgs(initialCommand, skipProfiles, staMode, configurationName, configurationFilePath, initialCommandArgs);
CreateRunspace(args);

if (ExitCode == ExitCodeInitFailure) { break; }
if (ExitCode == ExitCodeInitFailure)
{
break;
}

if (!_noExit)
{
Expand Down Expand Up @@ -2228,7 +2244,10 @@ private void OnExecutionSuspended(object sender, DebuggerStopEventArgs e)
{
// Check local runspace internalHost to see if debugging is enabled.
LocalRunspace localrunspace = LocalRunspace;
if ((localrunspace != null) && !localrunspace.ExecutionContext.EngineHostInterface.DebuggerEnabled) { return; }
if ((localrunspace != null) && !localrunspace.ExecutionContext.EngineHostInterface.DebuggerEnabled)
{
return;
}

_debuggerStopEventArgs = e;
InputLoop baseLoop = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,10 @@ private void HandleCommandLineDynamicParameters(out ParameterBindingException ou
}
catch (Exception e) // Catch-all OK, this is a third-party callout
{
if (e is ProviderInvocationException) { throw; }
if (e is ProviderInvocationException)
{
throw;
}

ParameterBindingException bindingException =
new ParameterBindingException(
Expand Down Expand Up @@ -3321,7 +3324,11 @@ private bool BindPipelineParametersPrivate(PSObject inputToOperateOn)
if (needToPrioritizeOneSpecificParameterSet && i == 0)
{
// If the prioritized set can be bound successfully, there is no need to do the second round binding
if (_currentParameterSetFlag == _parameterSetToBePrioritizedInPipelineBinding) break;
if (_currentParameterSetFlag == _parameterSetToBePrioritizedInPipelineBinding)
{
break;
}

validParameterSets = _currentParameterSetFlag & (~_parameterSetToBePrioritizedInPipelineBinding);
}
}
Expand Down Expand Up @@ -4379,7 +4386,10 @@ public override bool ContainsKey(object key)
throw PSTraceSource.NewArgumentNullException(nameof(key));
}

if (!(key is string strKey)) { return false; }
if (!(key is string strKey))
{
return false;
}

string keyAfterTrim = strKey.Trim();
return base.ContainsKey(keyAfterTrim);
Expand Down Expand Up @@ -4448,9 +4458,15 @@ public override object this[object key]
{
get
{
if (key == null) { throw PSTraceSource.NewArgumentNullException(nameof(key)); }
if (key == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(key));
}

if (!(key is string strKey)) { return null; }
if (!(key is string strKey))
{
return null;
}

string keyAfterTrim = strKey.Trim();
return base[keyAfterTrim];
Expand All @@ -4473,7 +4489,10 @@ public override void Remove(object key)
throw PSTraceSource.NewArgumentNullException(nameof(key));
}

if (!(key is string strKey)) { return; }
if (!(key is string strKey))
{
return;
}

string keyAfterTrim = strKey.Trim();
if (base.ContainsKey(keyAfterTrim))
Expand Down
23 changes: 19 additions & 4 deletions src/System.Management.Automation/engine/ComInterop/VariantArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,25 @@ internal static MemberExpression GetStructField(ParameterExpression variantArray
internal static Type GetStructType(int args)
{
Debug.Assert(args >= 0);
if (args <= 1) return typeof(VariantArray1);
if (args <= 2) return typeof(VariantArray2);
if (args <= 4) return typeof(VariantArray4);
if (args <= 8) return typeof(VariantArray8);
if (args <= 1)
{
return typeof(VariantArray1);
}

if (args <= 2)
{
return typeof(VariantArray2);
}

if (args <= 4)
{
return typeof(VariantArray4);
}

if (args <= 8)
{
return typeof(VariantArray8);
}

int size = 1;
while (args > size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,10 @@ internal static ExperimentalFeature[] GetExperimentalFeature(string manifestPath
foreach (Hashtable feature in features)
{
string featureName = feature["Name"] as string;
if (string.IsNullOrEmpty(featureName)) { continue; }
if (string.IsNullOrEmpty(featureName))
{
continue;
}

if (ExperimentalFeature.IsModuleFeatureName(featureName, moduleName))
{
Expand Down
10 changes: 8 additions & 2 deletions src/System.Management.Automation/engine/Modules/PSModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ public Dictionary<string, FunctionInfo> ExportedFunctions
// If the module is not binary, it may also have functions...
if (DeclaredFunctionExports != null)
{
if (DeclaredFunctionExports.Count == 0) { return exports; }
if (DeclaredFunctionExports.Count == 0)
{
return exports;
}

foreach (string fn in DeclaredFunctionExports)
{
Expand Down Expand Up @@ -707,7 +710,10 @@ public Dictionary<string, CmdletInfo> ExportedCmdlets

if (DeclaredCmdletExports != null)
{
if (DeclaredCmdletExports.Count == 0) { return exports; }
if (DeclaredCmdletExports.Count == 0)
{
return exports;
}

foreach (string fn in DeclaredCmdletExports)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ namespace System.Management.Automation.Interpreter {
internal partial class DynamicInstructionN {
internal static Type GetDynamicInstructionType(Type delegateType) {
Type[] argTypes = delegateType.GetGenericArguments();
if (argTypes.Length == 0) return null;
if (argTypes.Length == 0)
{
return null;
}

Type genericType;
Type[] newArgTypes = argTypes.Skip(1).ToArray();
switch (newArgTypes.Length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public bool Matches(Type exceptionType)

public bool IsBetterThan(ExceptionHandler other)
{
if (other == null) return true;
if (other == null)
{
return true;
}

Debug.Assert(StartIndex == other.StartIndex && EndIndex == other.EndIndex, "we only need to compare handlers for the same try block");
return HandlerStartIndex < other.HandlerStartIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,10 @@ internal static bool TrueForAll<T>(this IEnumerable<T> collection, Predicate<T>

foreach (T item in collection)
{
if (!predicate(item)) return false;
if (!predicate(item))
{
return false;
}
}

return true;
Expand Down
10 changes: 8 additions & 2 deletions src/System.Management.Automation/engine/remoting/client/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,11 +1011,17 @@ protected virtual void DoUnloadJobStreams()
/// </summary>
public void LoadJobStreams()
{
if (_jobStreamsLoaded) return;
if (_jobStreamsLoaded)
{
return;
}

lock (syncObject)
{
if (_jobStreamsLoaded) return;
if (_jobStreamsLoaded)
{
return;
}

_jobStreamsLoaded = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ internal static void SaveJobId(Guid instanceId, int id, string typeName)
{
lock (s_syncObject)
{
if (s_jobIdsForReuse.ContainsKey(instanceId)) return;
if (s_jobIdsForReuse.ContainsKey(instanceId))
{
return;
}

s_jobIdsForReuse.Add(instanceId, new KeyValuePair<int, string>(id, typeName));
}
}
Expand Down Expand Up @@ -587,7 +591,11 @@ private List<Job2> GetFilteredJobs(
}
#pragma warning restore 56500

if (jobs == null) continue;
if (jobs == null)
{
continue;
}

allJobs.AddRange(jobs);
}
}
Expand Down Expand Up @@ -752,7 +760,10 @@ private Job2 GetJobThroughId<T>(Guid guid, int id, Cmdlet cmdlet, bool writeErro
WriteErrorOrWarning(writeErrorOnException, cmdlet, exception, "JobSourceAdapterGetJobByInstanceIdError", sourceAdapter);
}

if (job == null) continue;
if (job == null)
{
continue;
}

if (writeObject)
{
Expand Down Expand Up @@ -928,12 +939,20 @@ internal bool RemoveJob(Job2 job, Cmdlet cmdlet, bool writeErrorOnException, boo

// sourceAdapter.GetJobByInstanceId() threw unknown exception.
_tracer.TraceException(exception);
if (throwExceptions) throw;
if (throwExceptions)
{
throw;
}

WriteErrorOrWarning(writeErrorOnException, cmdlet, exception, "JobSourceAdapterGetJobError", sourceAdapter);
}
#pragma warning restore 56500

if (foundJob == null) continue;
if (foundJob == null)
{
continue;
}

jobFound = true;
RemoveJobIdForReuse(foundJob);

Expand All @@ -951,7 +970,11 @@ internal bool RemoveJob(Job2 job, Cmdlet cmdlet, bool writeErrorOnException, boo
// sourceAdapter.RemoveJob() threw unknown exception.

_tracer.TraceException(exception);
if (throwExceptions) throw;
if (throwExceptions)
{
throw;
}

WriteErrorOrWarning(writeErrorOnException, cmdlet, exception, "JobSourceAdapterRemoveJobError", sourceAdapter);
}
#pragma warning restore 56500
Expand Down
Loading