/// <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> /// Registers the rules. Do not put the contents of this method in the constructor. /// If you do *sometimes* the StyleCop object won't be loaded be the time you construct it. /// </summary> private void Init() { StyleCopCore core = new StyleCopCore(); core.Initialize(new List <string>(), true); Dictionary <SourceAnalyzer, List <StyleCopRule> > analyzerRulesDictionary = StyleCopRule.GetRules(core); HighlightingSettingsManager highlightManager = HighlightingSettingsManager.Instance; Severity defaultSeverity = highlightManager.GetConfigurableSeverity(DefaultSeverityId, null); this.RegisterRuleConfigurations(highlightManager, analyzerRulesDictionary, defaultSeverity); }