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 @@ -409,7 +409,10 @@ private static TypeInfoDataBase LoadFromFileHelper(
continue;
}

if (etwEnabled) RunspaceEventSource.Log.ProcessFormatFileStart(file.FullPath);
if (etwEnabled)
{
RunspaceEventSource.Log.ProcessFormatFileStart(file.FullPath);
}

if (!ProcessBuiltin(file, db, expressionFactory, logEntries, ref success))
{
Expand All @@ -428,15 +431,21 @@ private static TypeInfoDataBase LoadFromFileHelper(
{
string mshsnapinMessage = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, info.psSnapinName, entry.message);
info.errors.Add(mshsnapinMessage);
if (entry.failToLoadFile) { file.FailToLoadFile = true; }
if (entry.failToLoadFile)
{
file.FailToLoadFile = true;
}
}
}
// now aggregate the entries...
logEntries.AddRange(loader.LogEntries);
}
}

if (etwEnabled) RunspaceEventSource.Log.ProcessFormatFileStop(file.FullPath);
if (etwEnabled)
{
RunspaceEventSource.Log.ProcessFormatFileStop(file.FullPath);
}
}

// add any sensible defaults to the database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,19 @@ private static string AddToPath(string basePath, string pathToAdd, int insertPos
if (insertPosition == -1) // append subPathToAdd to the end
{
bool endsWithPathSeparator = false;
if (result.Length > 0) endsWithPathSeparator = (result[result.Length - 1] == Path.PathSeparator);
if (result.Length > 0)
{
endsWithPathSeparator = (result[result.Length - 1] == Path.PathSeparator);
}

if (endsWithPathSeparator)
{
result.Append(subPathToAdd);
}
else
{
result.Append(Path.PathSeparator + subPathToAdd);
}
}
else if (insertPosition > result.Length)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,10 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)

private void ProcessCmdletArguments(object value, Action<string> onEachArgument)
{
if (value == null) return;
if (value == null)
{
return;
}

var commandName = value as string;
if (commandName != null)
Expand Down
12 changes: 10 additions & 2 deletions src/System.Management.Automation/engine/parser/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,18 @@ internal static bool ContainsLineAndColumn(this IScriptExtent extent, int line,
{
if (extent.StartLineNumber == line)
{
if (column == 0) return true;
if (column == 0)
{
return true;
}

if (column >= extent.StartColumnNumber)
{
if (extent.EndLineNumber != extent.StartLineNumber) return true;
if (extent.EndLineNumber != extent.StartLineNumber)
{
return true;
}

return (column < extent.EndColumnNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ public override AstVisitAction VisitForEachStatement(ForEachStatementAst forEach

public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst)
{
if (tryStatementAst.CatchClauses.Count <= 1) return AstVisitAction.Continue;
if (tryStatementAst.CatchClauses.Count <= 1)
{
return AstVisitAction.Continue;
}

for (int i = 0; i < tryStatementAst.CatchClauses.Count - 1; ++i)
{
Expand All @@ -550,7 +553,10 @@ public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst
break;
}

if (block2.IsCatchAll) continue;
if (block2.IsCatchAll)
{
continue;
}

foreach (TypeConstraintAst typeLiteral1 in block1.CatchTypes)
{
Expand Down Expand Up @@ -1689,7 +1695,11 @@ private static void CheckGet(Parser parser, FunctionMemberAst functionMemberAst,
/// <param name="hasTest">True if it is a Test method with qualified return type and signature; otherwise, false.</param>
private static void CheckTest(FunctionMemberAst functionMemberAst, ref bool hasTest)
{
if (hasTest) return;
if (hasTest)
{
return;
}

hasTest = (functionMemberAst.Name.Equals("Test", StringComparison.OrdinalIgnoreCase) &&
functionMemberAst.Parameters.Count == 0 &&
functionMemberAst.ReturnType != null &&
Expand All @@ -1702,7 +1712,11 @@ private static void CheckTest(FunctionMemberAst functionMemberAst, ref bool hasT
/// <param name="hasSet">True if it is a Set method with qualified return type and signature; otherwise, false.</param>
private static void CheckSet(FunctionMemberAst functionMemberAst, ref bool hasSet)
{
if (hasSet) return;
if (hasSet)
{
return;
}

hasSet = (functionMemberAst.Name.Equals("Set", StringComparison.OrdinalIgnoreCase) &&
functionMemberAst.Parameters.Count == 0 &&
functionMemberAst.IsReturnTypeVoid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ private static Type LookForTypeInAssemblies(TypeName typeName,
foreach (Assembly assembly in assemblies)
{
// Skip the assemblies that we already searched and found no matching type.
if (searchedAssemblies.Contains(assembly)) { continue; }
if (searchedAssemblies.Contains(assembly))
{
continue;
}

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,31 @@ protected override void EndProcessing()
{
_needToCheckForWaitingJobs = true;
if (_pendingJobs.Count > 0)
{
jobsPending = true;
}
}

if (Wait && jobsPending)
{
_waitForJobs.WaitOne();
}

if (_warnInvalidState)
{
WriteWarning(RemotingErrorIdStrings.ResumeJobInvalidJobState);
}

foreach (var e in _errorsToWrite)
{
WriteError(e);
}

foreach (var j in _allJobsToResume)
{
WriteObject(j);
}

if (_warnInvalidState) WriteWarning(RemotingErrorIdStrings.ResumeJobInvalidJobState);
foreach (var e in _errorsToWrite) WriteError(e);
foreach (var j in _allJobsToResume) WriteObject(j);
base.EndProcessing();
}

Expand Down Expand Up @@ -267,7 +283,11 @@ public void Dispose()
/// <param name="disposing"></param>
protected void Dispose(bool disposing)
{
if (!disposing) return;
if (!disposing)
{
return;
}

foreach (var pair in _cleanUpActions)
{
pair.Key.ResumeJobCompleted -= pair.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ protected override void ProcessRecord()

foreach (Job job in jobsToStop)
{
if (this.Stopping) return;
if (this.Stopping)
{
return;
}

if (job.IsFinishedState(job.JobStateInfo.State))
{
continue;
Expand Down Expand Up @@ -280,7 +284,11 @@ public void Dispose()
/// <param name="disposing"></param>
protected void Dispose(bool disposing)
{
if (!disposing) return;
if (!disposing)
{
return;
}

foreach (var pair in _cleanUpActions)
{
pair.Key.StopJobCompleted -= pair.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,31 @@ protected override void EndProcessing()
{
_needToCheckForWaitingJobs = true;
if (_pendingJobs.Count > 0)
{
haveToWait = true;
}
}

if (haveToWait)
{
_waitForJobs.WaitOne();
}

if (_warnInvalidState)
{
WriteWarning(RemotingErrorIdStrings.SuspendJobInvalidJobState);
}

foreach (var e in _errorsToWrite)
{
WriteError(e);
}

foreach (var j in _allJobsToSuspend)
{
WriteObject(j);
}

if (_warnInvalidState) WriteWarning(RemotingErrorIdStrings.SuspendJobInvalidJobState);
foreach (var e in _errorsToWrite) WriteError(e);
foreach (var j in _allJobsToSuspend) WriteObject(j);
base.EndProcessing();
}

Expand Down Expand Up @@ -361,7 +377,11 @@ public void Dispose()
/// <param name="disposing"></param>
protected void Dispose(bool disposing)
{
if (!disposing) return;
if (!disposing)
{
return;
}

foreach (var pair in _cleanUpActions)
{
pair.Key.SuspendJobCompleted -= pair.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,17 @@ private static void GetIdentifierInfo(string message, out Guid jobInstanceId, ou
jobInstanceId = Guid.Empty;
computerName = string.Empty;

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

string[] parts = message.Split(':', 3);

if (parts.Length != 3) return;
if (parts.Length != 3)
{
return;
}

if (!Guid.TryParse(parts[0], out jobInstanceId))
jobInstanceId = Guid.Empty;
Expand Down Expand Up @@ -456,7 +463,11 @@ internal static string CreateInformationalMessage(Guid instanceId, string messag

internal static ErrorRecord AddSourceTagToError(ErrorRecord errorRecord, Guid sourceId)
{
if (errorRecord == null) return null;
if (errorRecord == null)
{
return null;
}

errorRecord.ErrorDetails ??= new ErrorDetails(string.Empty);
errorRecord.ErrorDetails.RecommendedAction = CreateInformationalMessage(sourceId, errorRecord.ErrorDetails.RecommendedAction);
return errorRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ private void HandlePowerShellInvocationStateChanged(object sender,
if (LocalPowerShell.RunningExtraCommands)
{
// If completed successfully then allow extra commands to run.
if (state == PSInvocationState.Completed) { return; }
if (state == PSInvocationState.Completed)
{
return;
}

// For failed or stopped state, extra commands cannot run and
// we allow this command invocation to finish.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ private void ReallyCompile(bool optimize)
TelemetryAPI.ReportScriptTelemetry((Ast)_ast, !optimize, sw.ElapsedMilliseconds);
}
#endif
if (etwEnabled) ParserEventSource.Log.CompileStop();
if (etwEnabled)
{
ParserEventSource.Log.CompileStop();
}
}

private void PerformSecurityChecks()
Expand Down Expand Up @@ -2054,7 +2057,10 @@ public static string Match(string text)
if (++longestPossiblePattern >= 4)
{
var result = CheckForMatches(runningHash, longestPossiblePattern);
if (result != null) return result;
if (result != null)
{
return result;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,10 @@ private static void FindAndProcessHandler(Type[] types, int[] ranks,
int handler = FindMatchingHandlerByType(exception.GetType(), types);

// If no handler was found, return without changing the current result.
if (handler == -1) { return; }
if (handler == -1)
{
return;
}

// New handler was found.
// - If new-rank is less than current-rank -- meaning the new handler is more specific,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public CultureInfo[] UICulture

set
{
if (value == null) return;
if (value == null)
{
return;
}

_language = new string[value.Length];
for (int index = 0; index < value.Length; index++)
{
Expand Down Expand Up @@ -443,7 +447,10 @@ internal void Process(IEnumerable<string> moduleNames, IEnumerable<ModuleSpecifi
/// <param name="modules">Module objects given by the user.</param>
internal void Process(IEnumerable<PSModuleInfo> modules)
{
if (modules == null || !modules.Any()) { return; }
if (modules == null || !modules.Any())
{
return;
}

var helpModules = new Dictionary<Tuple<string, Version>, UpdatableHelpModuleInfo>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,10 @@ internal UpdatableHelpInfo CreateHelpInfo(string xml, string moduleName, Guid mo
}
catch (XmlException e)
{
if (ignoreValidationException) { return null; }
if (ignoreValidationException)
{
return null;
}

throw new UpdatableHelpSystemException(HelpInfoXmlValidationFailure,
e.Message, ErrorCategory.InvalidData, null, e);
Expand Down
Loading