Skip to content

Commit a406d8f

Browse files
author
Kapil Borle
committed
Fixes to UseToExportFieldsInManifest rule.
1 parent 38b9e99 commit a406d8f

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

Rules/UseToExportFieldsInManifest.cs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,37 @@ private bool HasAcceptableExportField(string key, HashtableAst hast, string scri
9797
extent = null;
9898
foreach (var pair in hast.KeyValuePairs)
9999
{
100-
if (key.Equals(pair.Item1.Extent.Text.Trim(), StringComparison.OrdinalIgnoreCase))
100+
if (pair.Item1 is StringConstantExpressionAst
101+
&& key.Equals((pair.Item1 as StringConstantExpressionAst).Value,
102+
StringComparison.OrdinalIgnoreCase))
101103
{
102-
// checks if the right hand side of the assignment is an array.
103-
var arrayAst = pair.Item2.Find(x => x is ArrayLiteralAst || x is ArrayExpressionAst, true);
104-
if (arrayAst == null)
105-
{
106-
extent = pair.Item2.Extent;
107-
return false;
108-
}
109-
else
104+
//checks for wildcard in the entry.
105+
var elementWithWildcard = pair.Item2.Find(x => x is StringConstantExpressionAst
106+
&& WildcardPattern.ContainsWildcardCharacters((x as StringConstantExpressionAst).Value), false);
107+
108+
if (elementWithWildcard == null)
110109
{
111-
//checks if any entry within the array has a wildcard.
112-
var elementWithWildcard = arrayAst.Find(x => x is StringConstantExpressionAst
113-
&& x.Extent.Text.Contains("*"), false);
114-
if (elementWithWildcard != null)
110+
//checks for $null in the entry.
111+
var nullAst = pair.Item2.Find(x => x is VariableExpressionAst
112+
&& (x as VariableExpressionAst).ToString().Equals("$null", StringComparison.OrdinalIgnoreCase), false);
113+
114+
if (nullAst == null)
115+
{
116+
return true;
117+
}
118+
else
115119
{
116-
extent = elementWithWildcard.Extent;
120+
extent = nullAst.Extent;
117121
return false;
118-
}
119-
return true;
122+
}
120123
}
124+
else
125+
{
126+
extent = elementWithWildcard.Extent;
127+
return false;
128+
}
121129
}
130+
122131
}
123132
return true;
124133
}

0 commit comments

Comments
 (0)