Skip to content

Commit a8ea91b

Browse files
author
Kapil Borle
committed
Merge pull request #474 from kilasuit/development
Fixes scope name comparison. Fixes #473
2 parents 890cd12 + 14d8a2e commit a8ea91b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Engine/Helper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ internal set
101101
/// </summary>
102102
private Dictionary<Ast, VariableAnalysis> VariableAnalysisDictionary;
103103

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

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

108108
#endregion
109109

@@ -420,7 +420,8 @@ private string NameWithoutScope(string name, string[] scopes)
420420
foreach (string scope in scopes)
421421
{
422422
// trim the scope part
423-
if (name.IndexOf(scope) == 0)
423+
if (name.IndexOf(scope, StringComparison.OrdinalIgnoreCase) == 0)
424+
424425
{
425426
return name.Substring(scope.Length);
426427
}
@@ -3026,4 +3027,4 @@ public object VisitUsingExpression(UsingExpressionAst usingExpressionAst)
30263027
return null;
30273028
}
30283029
}
3029-
}
3030+
}

Tests/Rules/GoodCmdlet.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ function global:Get-SimpleFunc*
223223

224224
}
225225

226+
function Local:Get-SimpleFunc*
227+
{
228+
229+
}
230+
231+
function PRIVATE:Get-SimpleFunc*
232+
{
233+
234+
}
235+
236+
function ScRiPt:Get-SimpleFunc*
237+
{
238+
239+
}
240+
226241
<#
227242
.Synopsis
228243
Short description

0 commit comments

Comments
 (0)