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
5 changes: 4 additions & 1 deletion src/System.Management.Automation/engine/COM/ComTypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ private void Initialize()
for (int i = 0; i < typeattr.cFuncs; i++)
{
COM.FUNCDESC funcdesc = GetFuncDesc(_typeinfo, i);
if (funcdesc.memid == DISPID_NEWENUM) { NewEnumInvokeKind = funcdesc.invkind; }
if (funcdesc.memid == DISPID_NEWENUM)
{
NewEnumInvokeKind = funcdesc.invkind;
}

if ((funcdesc.wFuncFlags & 0x1) == 0x1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ internal DynamicMetaObject Invoke()

private static void AddNotNull(List<ParameterExpression> list, ParameterExpression var)
{
if (var != null) list.Add(var);
if (var != null)
{
list.Add(var);
}
}

private Expression CreateScope(Expression expression)
Expand Down
84 changes: 68 additions & 16 deletions src/System.Management.Automation/engine/PSVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,20 @@ public SemanticVersion(int major, int minor, int patch, string preReleaseLabel,
{
if (!string.IsNullOrEmpty(preReleaseLabel))
{
if (!Regex.IsMatch(preReleaseLabel, LabelUnitRegEx)) throw new FormatException(nameof(preReleaseLabel));
if (!Regex.IsMatch(preReleaseLabel, LabelUnitRegEx))
{
throw new FormatException(nameof(preReleaseLabel));
}

PreReleaseLabel = preReleaseLabel;
}

if (!string.IsNullOrEmpty(buildLabel))
{
if (!Regex.IsMatch(buildLabel, LabelUnitRegEx)) throw new FormatException(nameof(buildLabel));
if (!Regex.IsMatch(buildLabel, LabelUnitRegEx))
{
throw new FormatException(nameof(buildLabel));
}

BuildLabel = buildLabel;
}
Expand All @@ -415,7 +421,10 @@ public SemanticVersion(int major, int minor, int patch, string label)
if (!string.IsNullOrEmpty(label))
{
var match = Regex.Match(label, LabelRegEx);
if (!match.Success) throw new FormatException(nameof(label));
if (!match.Success)
{
throw new FormatException(nameof(label));
}

PreReleaseLabel = match.Groups["preLabel"].Value;
BuildLabel = match.Groups["buildLabel"].Value;
Expand All @@ -433,9 +442,20 @@ public SemanticVersion(int major, int minor, int patch, string label)
/// </exception>
public SemanticVersion(int major, int minor, int patch)
{
if (major < 0) throw PSTraceSource.NewArgumentException(nameof(major));
if (minor < 0) throw PSTraceSource.NewArgumentException(nameof(minor));
if (patch < 0) throw PSTraceSource.NewArgumentException(nameof(patch));
if (major < 0)
{
throw PSTraceSource.NewArgumentException(nameof(major));
}

if (minor < 0)
{
throw PSTraceSource.NewArgumentException(nameof(minor));
}

if (patch < 0)
{
throw PSTraceSource.NewArgumentException(nameof(patch));
}

Major = major;
Minor = minor;
Expand Down Expand Up @@ -477,8 +497,15 @@ public SemanticVersion(int major) : this(major, 0, 0) { }
/// </exception>
public SemanticVersion(Version version)
{
if (version == null) throw PSTraceSource.NewArgumentNullException(nameof(version));
if (version.Revision > 0) throw PSTraceSource.NewArgumentException(nameof(version));
if (version == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(version));
}

if (version.Revision > 0)
{
throw PSTraceSource.NewArgumentException(nameof(version));
}

Major = version.Major;
Minor = version.Minor;
Expand Down Expand Up @@ -565,8 +592,15 @@ public static implicit operator Version(SemanticVersion semver)
/// <exception cref="OverflowException"></exception>
public static SemanticVersion Parse(string version)
{
if (version == null) throw PSTraceSource.NewArgumentNullException(nameof(version));
if (version == string.Empty) throw new FormatException(nameof(version));
if (version == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(version));
}

if (version == string.Empty)
{
throw new FormatException(nameof(version));
}

var r = new VersionResult();
r.Init(true);
Expand Down Expand Up @@ -886,9 +920,15 @@ private static int ComparePreLabel(string preLabel1, string preLabel2)
// Numeric identifiers always have lower precedence than non-numeric identifiers.
// A larger set of pre-release fields has a higher precedence than a smaller set,
// if all of the preceding identifiers are equal.
if (string.IsNullOrEmpty(preLabel1)) { return string.IsNullOrEmpty(preLabel2) ? 0 : 1; }
if (string.IsNullOrEmpty(preLabel1))
{
return string.IsNullOrEmpty(preLabel2) ? 0 : 1;
}

if (string.IsNullOrEmpty(preLabel2)) { return -1; }
if (string.IsNullOrEmpty(preLabel2))
{
return -1;
}

var units1 = preLabel1.Split('.');
var units2 = preLabel2.Split('.');
Expand All @@ -905,16 +945,28 @@ private static int ComparePreLabel(string preLabel1, string preLabel2)

if (isNumber1 && isNumber2)
{
if (number1 != number2) { return number1 < number2 ? -1 : 1; }
if (number1 != number2)
{
return number1 < number2 ? -1 : 1;
}
}
else
{
if (isNumber1) { return -1; }
if (isNumber1)
{
return -1;
}

if (isNumber2) { return 1; }
if (isNumber2)
{
return 1;
}

int result = string.CompareOrdinal(ac, bc);
if (result != 0) { return result; }
if (result != 0)
{
return result;
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/System.Management.Automation/engine/PseudoParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,20 @@ internal bool IsDisabled()
{
if (!hasSeenExpAttribute && attr is ExperimentalAttribute expAttribute)
{
if (expAttribute.ToHide) { return true; }
if (expAttribute.ToHide)
{
return true;
}

hasSeenExpAttribute = true;
}
else if (attr is ParameterAttribute paramAttribute)
{
hasParameterAttribute = true;
if (paramAttribute.ToHide) { continue; }
if (paramAttribute.ToHide)
{
continue;
}

hasEnabledParamAttribute = true;
}
Expand Down
19 changes: 16 additions & 3 deletions src/System.Management.Automation/engine/SessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,27 @@ internal SessionStateEntryVisibility CheckApplicationVisibility(string applicati

private static SessionStateEntryVisibility checkPathVisibility(List<string> list, string path)
{
if (list == null || list.Count == 0) return SessionStateEntryVisibility.Private;
if (string.IsNullOrEmpty(path)) return SessionStateEntryVisibility.Private;
if (list == null || list.Count == 0)
{
return SessionStateEntryVisibility.Private;
}

if (string.IsNullOrEmpty(path))
{
return SessionStateEntryVisibility.Private;
}

if (list.Contains("*"))
{
return SessionStateEntryVisibility.Public;
}

if (list.Contains("*")) return SessionStateEntryVisibility.Public;
foreach (string p in list)
{
if (string.Equals(p, path, StringComparison.OrdinalIgnoreCase))
{
return SessionStateEntryVisibility.Public;
}

if (WildcardPattern.ContainsWildcardCharacters(p))
{
Expand Down
22 changes: 18 additions & 4 deletions src/System.Management.Automation/engine/SessionStateScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ internal PSVariable SetVariable(string name, object value, bool asValue, bool fo
bool varExists = TryGetVariable(name, origin, true, out variable);

// Initialize the private variable dictionary if it's not yet
if (_variables == null) { GetPrivateVariables(); }
if (_variables == null)
{
GetPrivateVariables();
}

if (!asValue && variableToSet != null)
{
Expand Down Expand Up @@ -1639,9 +1642,14 @@ internal void AddType(string name, Type type)

internal Type LookupType(string name)
{
if (TypeTable == null) return null;
if (TypeTable == null)
{
return null;
}

Type result;
TypeTable.TryGetValue(name, out result);

return result;
}

Expand Down Expand Up @@ -1682,12 +1690,18 @@ private static FunctionInfo CreateFunction(string name, ScriptBlock function, Fu

// Then use the creation constructors - workflows don't get here because the workflow info
// is created during compilation.
else if (function.IsFilter) { newValue = new FilterInfo(name, function, options, context, helpFile); }
else if (function.IsFilter)
{
newValue = new FilterInfo(name, function, options, context, helpFile);
}
else if (function.IsConfiguration)
{
newValue = new ConfigurationInfo(name, function, options, context, helpFile, function.IsMetaConfiguration());
}
else newValue = new FunctionInfo(name, function, options, context, helpFile);
else
{
newValue = new FunctionInfo(name, function, options, context, helpFile);
}

return newValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,16 @@ public static bool IsConstant(Ast ast, out object constantValue, bool forAttribu

public object VisitStatementBlock(StatementBlockAst statementBlockAst)
{
if (statementBlockAst.Traps != null) return false;
if (statementBlockAst.Statements.Count > 1) return false;
if (statementBlockAst.Traps != null)
{
return false;
}

if (statementBlockAst.Statements.Count > 1)
{
return false;
}

var pipeline = statementBlockAst.Statements.FirstOrDefault();
return pipeline != null && (bool)pipeline.Accept(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ internal static void Dispatch(
/// </summary>
private static bool IsRunspacePushed(PSHost host)
{
if (!(host is IHostSupportsInteractiveSession host2)) { return false; }
if (!(host is IHostSupportsInteractiveSession host2))
{
return false;
}

// IsRunspacePushed can throw (not implemented exception)
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ private bool CheckForDebuggableJob()
foreach (var cJob in _job.ChildJobs)
{
debuggableJobFound = GetJobDebuggable(cJob);
if (debuggableJobFound) { break; }
if (debuggableJobFound)
{
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,10 @@ internal static IReadOnlyCollection<PSHostProcessInfo> GetAppDomainNamesFromProc
}
}

if (!found) { continue; }
if (!found)
{
continue;
}
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ private List<Job> FindChildJobs(List<Job> jobList)
{
foreach (Job childJob in job.ChildJobs)
{
if (childJob.JobStateInfo.State != ChildJobState) continue;
if (childJob.JobStateInfo.State != ChildJobState)
{
continue;
}

matches.Add(childJob);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ protected override void ProcessRecord()
}

// If runspace is null then the error record has already been written and we can exit.
if (remoteRunspace == null) { return; }
if (remoteRunspace == null)
{
return;
}

// If the runspace is in a disconnected state try to connect.
bool runspaceConnected = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,10 @@ private void ConnectSessionToHost(PSSession session, PSRemotingJob job = null)
{
Job childJob = job.ChildJobs[0];
job.ConnectJobs();
if (CheckForDebugMode(session, true)) { return; }
if (CheckForDebugMode(session, true))
{
return;
}

do
{
Expand Down Expand Up @@ -921,7 +924,10 @@ private void ConnectSessionToHost(PSSession session, PSRemotingJob job = null)

pipelineConnectedEvent = null;

if (CheckForDebugMode(session, true)) { return; }
if (CheckForDebugMode(session, true))
{
return;
}

// Wait for remote command to complete, while writing any available data.
while (!_remotePipeline.Output.EndOfPipeline)
Expand Down Expand Up @@ -1100,7 +1106,10 @@ private void ConnectSessionToJob(PSSession session, PSRemotingJob job = null)
}
}

if (CheckForDebugMode(session, true)) { return; }
if (CheckForDebugMode(session, true))
{
return;
}

// Write the job object to output.
WriteObject(job);
Expand Down
Loading