void SearchAndEval(ProblemDescriptor p, System.Reflection.Assembly[] assemblies, ProjectReport projectReport) { if (string.IsNullOrEmpty(p.customevaluator)) { // try all assemblies. Need to find a way to only evaluate on the right assembly foreach (var assembly in assemblies) { try { var value = MethodEvaluator.Eval(assembly.Location, p.type, "get_" + p.method, new System.Type[0] { }, new object[0] { }); if (value.ToString() == p.value) { projectReport.AddIssue(new ProjectIssue { description = p.description, category = IssueCategory.ProjectSettings, descriptor = p }); // stop iterating assemblies break; } } catch (Exception) { // this is safe to ignore } } } else { Type helperType = m_Helpers.GetType(); MethodInfo theMethod = helperType.GetMethod(p.customevaluator); bool isIssue = (bool)theMethod.Invoke(m_Helpers, null); if (isIssue) { projectReport.AddIssue(new ProjectIssue { description = p.description, category = IssueCategory.ProjectSettings, descriptor = p }); } } }
ProjectIssue SearchAndEval(ProblemDescriptor descriptor) { if (string.IsNullOrEmpty(descriptor.customevaluator)) { var paramTypes = new Type[] {}; var args = new object[] {}; var found = false; // do we actually need to look in all assemblies? Maybe we can find a way to only evaluate on the right assembly foreach (var assembly in m_Assemblies) { try { var value = MethodEvaluator.Eval(assembly.Location, descriptor.type, "get_" + descriptor.method, paramTypes, args); if (value.ToString() == descriptor.value) { return(NewIssue(descriptor, descriptor.description)); } // Eval did not throw exception so we can stop iterating assemblies found = true; break; } catch (Exception) { // this is safe to ignore } } if (!found) { Debug.Log(descriptor.method + " not found in any assembly"); } } else { var helperType = m_Helpers.GetType(); var theMethod = helperType.GetMethod(descriptor.customevaluator); if ((bool)theMethod.Invoke(m_Helpers, null)) { return(NewIssue(descriptor, descriptor.description)); } } return(null); }
private void SearchAndEval(ProblemDescriptor descriptor, ProjectReport projectReport) { if (string.IsNullOrEmpty(descriptor.customevaluator)) { // do we actually need to look in all assemblies? Maybe we can find a way to only evaluate on the right assembly foreach (var assembly in m_Assemblies) { try { var value = MethodEvaluator.Eval(assembly.Location, descriptor.type, "get_" + descriptor.method, new System.Type[0] { }, new object[0] { }); if (value.ToString() == descriptor.value) { AddIssue(descriptor, string.Format("{0}: {1}", descriptor.description, value), projectReport); // stop iterating assemblies break; } } catch (Exception) { // this is safe to ignore } } } else { Type helperType = m_Helpers.GetType(); MethodInfo theMethod = helperType.GetMethod(descriptor.customevaluator); bool isIssue = (bool)theMethod.Invoke(m_Helpers, null); if (isIssue) { AddIssue(descriptor, descriptor.description, projectReport); } } }