Example #1
0
        private void SearchAndEval(ProblemDescriptor descriptor, Action <ProjectIssue> onIssueFound)
        {
            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)
                        {
                            AddIssue(descriptor, string.Format("{0}: {1}", descriptor.description, value), onIssueFound);
                        }

                        // 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);
                var isIssue    = (bool)theMethod.Invoke(m_Helpers, null);
                if (isIssue)
                {
                    AddIssue(descriptor, descriptor.description, onIssueFound);
                }
            }
        }