Exemple #1
0
        private void Register(StyleCopCore core)
        {
            Dictionary <SourceAnalyzer, List <StyleCopRule> > analyzerRulesDictionary = StyleCopRule.GetRules(core);

            var configurableSeverityItems = new List <Tuple <PsiLanguageType, ConfigurableSeverityItem> >();

            foreach (KeyValuePair <SourceAnalyzer, List <StyleCopRule> > analyzerRule in analyzerRulesDictionary)
            {
                string analyzerName     = analyzerRule.Key.Name;
                string compoundItemName = string.Format(GroupTitleTemplate, analyzerName);

                foreach (StyleCopRule rule in analyzerRule.Value)
                {
                    string ruleName    = rule.RuleID + ": " + SplitCamelCase(rule.Name);
                    string highlightID = GetHighlightID(rule.RuleID);
                    ConfigurableSeverityItem severityItem = new ConfigurableSeverityItem(
                        highlightID,
                        compoundItemName,
                        "StyleCop",
                        ruleName,
                        rule.Description,
                        Severity.WARNING,
                        false,
                        false,
                        null,
                        null);
                    configurableSeverityItems.Add(Tuple.Create((PsiLanguageType)CSharpLanguage.Instance, severityItem));
                }
            }
            this.ConfigurableSeverityItems = configurableSeverityItems;
        }
        private void Register(StyleCopCore core)
        {
            this.registrationLifetimes.Next(
                lifetime =>
            {
                Dictionary <SourceAnalyzer, List <StyleCopRule> > analyzerRulesDictionary = StyleCopRule.GetRules(core);

                // Not the best way of doing this, but better than reflection. Create a "fake" parts catalogue
                // that contains parts representing the attributes that we would specify if we were doing this
                // "properly" and not dynamically based on the rules loaded by StyleCop and any addins (this is
                // compounded by allowing addins to be different per-solution, thanks to the settings subsystem).
                // Adding the catalogue to the global parts catalogue causes ReSharper to automatically evaluate
                // it, and automatically remove it when the lifetime is terminated.
                IPartsCatalogue catalogue = this.CreateFakeCatalogue(analyzerRulesDictionary);
                PartCatalog catalog       = catalogue.WrapLegacy();
                this.partsCatalogueSet.Catalogs.Add(lifetime, catalog, null);
            });
        }