From 4eb3ae4840ace5d9ba4738d44f073d8c1f2b7080 Mon Sep 17 00:00:00 2001 From: Maria Romero Date: Wed, 9 May 2018 17:47:28 -0700 Subject: [PATCH] remove getProperty reference for Ast objects --- Rules/UseCompatibleTypes.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Rules/UseCompatibleTypes.cs b/Rules/UseCompatibleTypes.cs index 66ef10416..f1fa0fbb5 100644 --- a/Rules/UseCompatibleTypes.cs +++ b/Rules/UseCompatibleTypes.cs @@ -171,20 +171,20 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Types declared by the user (defined within a user-created class). IEnumerable definitionAsts = ast.FindAll(testAst => testAst is TypeDefinitionAst, true); - foreach (Ast item in definitionAsts) + foreach (Ast definition in definitionAsts) { - string customType = item.GetType().GetProperty("Name").GetValue(item).ToString(); - customTypes.Add(customType); + TypeDefinitionAst customType = (TypeDefinitionAst)definition; + customTypes.Add(customType.Name); } // These are namespaces used in the script. This will help getting full type names for types // from ast objects that only give us the type name as a string. We will add these to the // beginning of our known namespaces list so we check those first. IEnumerable useStatementAsts = ast.FindAll(testAst => testAst is UsingStatementAst, true); - foreach (Ast item in useStatementAsts) + foreach (Ast use in useStatementAsts) { - string nspace = item.GetType().GetProperty("Name").GetValue(item).ToString(); - knownNamespaces.Insert(0, nspace + "."); + UsingStatementAst nspace = (UsingStatementAst)use; + knownNamespaces.Insert(0, nspace.Name.Value + "."); } // If we have no types to check, we can exit from this rule.