Exemple #1
0
        /// <summary>
        /// Gets the rules from XML.
        /// </summary>
        /// <param name="rulesNode">
        /// The rules node.
        /// </param>
        /// <returns>
        /// The StyleCop rules defined in the <see cref="XmlNode"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Rule Has No Name Attribute.
        /// </exception>
        private static List <StyleCopRule> GetRulesFromXml(XmlNode rulesNode)
        {
            List <StyleCopRule> rules = new List <StyleCopRule>();

            foreach (XmlNode node in rulesNode.ChildNodes)
            {
                switch (node.Name)
                {
                case "RuleGroup":
                {
                    List <StyleCopRule> groupRules = GetRuleGroupRules(node);
                    rules.AddRange(groupRules);
                }

                break;

                case "Rule":
                {
                    StyleCopRule rule = GetRule(node);
                    rules.Add(rule);
                }

                break;
                }
            }

            return(rules);
        }
        /// <summary>
        /// Adds the highlights.
        /// </summary>
        private void AddHighlights()
        {
            StyleCopCore core = new StyleCopCore();

            core.Initialize(new List <string>(), true);

            Dictionary <SourceAnalyzer, List <StyleCopRule> > analyzerRulesDictionary = StyleCopRule.GetRules(core);

            HighlightingSettingsManager highlightManager = HighlightingSettingsManager.Instance;

            AddDefaultOption();

            Severity defaultSeverity = highlightManager.GetConfigurableSeverity(DefaultSeverityId, null);

            this.RegisterRuleConfigurations(highlightManager, analyzerRulesDictionary, defaultSeverity);
        }