Example #1
0
        // If a rule fails we want to report the failure and then continue on
        // without it. So, if a rule fails we'll remove all the callbacks here
        // so we don't get spammed with errors.
        private void DoRemoveFailedRules(string checkID)
        {
            RuleCallback prototype = new RuleCallback("?", checkID, null, null);

            foreach (KeyValuePair <Type, List <RuleCallback> > entry in m_callbackTable)
            {
                Unused.Value = entry.Value.Remove(prototype);
            }
        }
Example #2
0
        private void DoVisit(object obj)
        {
            List <RuleCallback> callbacks = DoGetCallbacks(obj);                // if store rule name with untyped might be able to profile rules

            m_args[0] = obj;

            for (int i = 0; i < callbacks.Count; ++i)
            {
                RuleCallback rule = callbacks[i];

                Profile.Start(rule.Name);
                try
                {
//					Console.WriteLine("visiting {0} for {1} {2}", rule.Name, obj, obj.GetType());

                    if (m_excluding.IndexOf(rule.CheckID) < 0)
                    {
                        rule.Method.Invoke(rule.Instance, m_args);
                    }
//					Console.WriteLine("   done");
                }
                catch (DllNotFoundException dll)
                {
                    string details = string.Format("Couldn't load {0}", dll.Message);
                    DoRemoveFailedRules(rule.CheckID);
                    DoReportFailure(details, dll);
                }
                catch (Exception e)
                {
                    string details = string.Format("{0} failed visiting {1}.{2}", rule.Name, obj, Environment.NewLine);

                    Exception ee = e;
                    while (ee != null)
                    {
                        if (e.InnerException != null)
                        {
                            details += string.Format("--------- {0} Exception{1}", ee == e ? "Outer" : "Inner", Environment.NewLine);
                        }
                        details += string.Format("{0}", ee.Message + Environment.NewLine);
                        details += string.Format("{0}", ee.StackTrace + Environment.NewLine);

                        ee = ee.InnerException;
                    }

                    Log.InfoLine(this, details);

                    DoRemoveFailedRules(rule.CheckID);
                    DoReportFailure(details, e);
                }
                finally
                {
                    Profile.Stop(rule.Name);
                }
            }
        }
Example #3
0
            public override bool Equals(object rhsObj)
            {
                if (rhsObj == null)
                {
                    return(false);
                }

                if (GetType() != rhsObj.GetType())
                {
                    return(false);
                }

                RuleCallback rhs = (RuleCallback)rhsObj;

                return(CheckID == rhs.CheckID);
            }