Skip to content

Commit bcdef95

Browse files
committed
Merge pull request #484 from PowerShell/development
Take Development to Master for next release
2 parents 2df55e0 + 31de911 commit bcdef95

25 files changed

+534
-202
lines changed
File renamed without changes.

Engine/Generic/AvoidCmdletGeneric.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4545

4646
if (cmdletNameAndAliases.Contains(cmdAst.GetCommandName(), StringComparer.OrdinalIgnoreCase))
4747
{
48-
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
48+
yield return new DiagnosticRecord(GetError(fileName), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName);
4949
}
5050
}
5151
}
@@ -97,5 +97,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
9797
/// </summary>
9898
/// <returns></returns>
9999
public abstract RuleSeverity GetSeverity();
100+
101+
/// <summary>
102+
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
103+
/// </summary>
104+
/// <returns></returns>
105+
public abstract DiagnosticSeverity GetDiagnosticSeverity();
100106
}
101107
}

Engine/Generic/AvoidParameterGeneric.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4444
{
4545
if (ParameterCondition(cmdAst, ceAst))
4646
{
47-
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName, cmdAst.GetCommandName());
47+
yield return new DiagnosticRecord(GetError(fileName, cmdAst), cmdAst.Extent, GetName(), GetDiagnosticSeverity(), fileName, cmdAst.GetCommandName());
4848
}
4949
}
5050
}
@@ -102,6 +102,16 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
102102
/// <returns>The source type of the rule.</returns>
103103
public abstract SourceType GetSourceType();
104104

105+
/// <summary>
106+
/// RuleSeverity: Returns the severity of the rule.
107+
/// </summary>
108+
/// <returns></returns>
105109
public abstract RuleSeverity GetSeverity();
110+
111+
/// <summary>
112+
/// DiagnosticSeverity: Returns the severity of the rule of type DiagnosticSeverity
113+
/// </summary>
114+
/// <returns></returns>
115+
public abstract DiagnosticSeverity GetDiagnosticSeverity();
106116
}
107117
}

Engine/Helper.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Helper
3232

3333
private CommandInvocationIntrinsics invokeCommand;
3434
private IOutputWriter outputWriter;
35+
private Object getCommandLock = new object();
3536

3637
#endregion
3738

@@ -100,9 +101,9 @@ internal set
100101
/// </summary>
101102
private Dictionary<Ast, VariableAnalysis> VariableAnalysisDictionary;
102103

103-
private string[] functionScopes = new string[] { "global:", "local:", "script:", "private:" };
104+
private string[] functionScopes = new string[] { "global:", "local:", "script:", "private:"};
104105

105-
private string[] variableScopes = new string[] { "global:", "local:", "script:", "private:", "variable:", ":" };
106+
private string[] variableScopes = new string[] { "global:", "local:", "script:", "private:", "variable:", ":"};
106107

107108
#endregion
108109

@@ -419,7 +420,8 @@ private string NameWithoutScope(string name, string[] scopes)
419420
foreach (string scope in scopes)
420421
{
421422
// trim the scope part
422-
if (name.IndexOf(scope) == 0)
423+
if (name.IndexOf(scope, StringComparison.OrdinalIgnoreCase) == 0)
424+
423425
{
424426
return name.Substring(scope.Length);
425427
}
@@ -567,7 +569,10 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanThreePositio
567569
/// <returns></returns>
568570
public CommandInfo GetCommandInfo(string name, CommandTypes commandType = CommandTypes.Alias | CommandTypes.Cmdlet | CommandTypes.Configuration | CommandTypes.ExternalScript | CommandTypes.Filter | CommandTypes.Function | CommandTypes.Script | CommandTypes.Workflow)
569571
{
570-
return this.invokeCommand.GetCommand(name, commandType);
572+
lock (getCommandLock)
573+
{
574+
return this.invokeCommand.GetCommand(name, commandType);
575+
}
571576
}
572577

573578
/// <summary>
@@ -3022,4 +3027,4 @@ public object VisitUsingExpression(UsingExpressionAst usingExpressionAst)
30223027
return null;
30233028
}
30243029
}
3025-
}
3030+
}

0 commit comments

Comments
 (0)