Skip to content

Commit e3c35d9

Browse files
author
Maria Romero
committed
remove getProperty reference for Ast objects
1 parent bd3bbb9 commit e3c35d9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Rules/UseCompatibleTypes.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
171171

172172
// Types declared by the user (defined within a user-created class).
173173
IEnumerable<Ast> definitionAsts = ast.FindAll(testAst => testAst is TypeDefinitionAst, true);
174-
foreach (Ast item in definitionAsts)
174+
foreach (Ast definition in definitionAsts)
175175
{
176-
string customType = item.GetType().GetProperty("Name").GetValue(item).ToString();
177-
customTypes.Add(customType);
176+
TypeDefinitionAst customType = (TypeDefinitionAst)definition;
177+
customTypes.Add(customType.Name);
178178
}
179179

180180
// These are namespaces used in the script. This will help getting full type names for types
181181
// from ast objects that only give us the type name as a string. We will add these to the
182182
// beginning of our known namespaces list so we check those first.
183183
IEnumerable<Ast> useStatementAsts = ast.FindAll(testAst => testAst is UsingStatementAst, true);
184-
foreach (Ast item in useStatementAsts)
184+
foreach (Ast use in useStatementAsts)
185185
{
186-
string nspace = item.GetType().GetProperty("Name").GetValue(item).ToString();
187-
knownNamespaces.Insert(0, nspace + ".");
186+
UsingStatementAst nspace = (UsingStatementAst)use;
187+
knownNamespaces.Insert(0, nspace.Name.Value + ".");
188188
}
189189

190190
// If we have no types to check, we can exit from this rule.

0 commit comments

Comments
 (0)