Exemplo n.º 1
0
        public AnalyzerDetails(string className, 
                               AnalyzerCategoryDetails category,
                               DefaultState defaultState,
                               DiagnosticSeverity severity,
                               string titleResourceName,
                               string descriptionResourceName,
                               string messageFormatResourceName,
                               IList<Type> suppressionAttributes)
        {
            var decomposedDetails = DecomposeDetailsFromClassName(className);
            var code = decomposedDetails.Item1;
            Name = decomposedDetails.Item2;
            NameWithCode = $"{decomposedDetails.Item3} - {Name}";
            Category = category;
            _defaultState = defaultState;
            Severity = severity;
            SuppressionAttributes = suppressionAttributes;

            Title = LocalizableStringFactory.LocalizableResourceString(titleResourceName);
            Description = LocalizableStringFactory.LocalizableResourceString(descriptionResourceName);
            MessageFormat = LocalizableStringFactory.LocalizableResourceString(messageFormatResourceName);
            DiagnosticId = Title.ToString().Replace("-", "");

            if (Title.ToString() != code)
            {
                throw new ArgumentException($@"Title resource value isn't of the correct format: should be {code}",
                                            nameof(titleResourceName));
            }
        }
Exemplo n.º 2
0
        public AnalyzerDetails(string className,
                               AnalyzerCategoryDetails category,
                               DefaultState defaultState,
                               DiagnosticSeverity severity,
                               string titleResourceName,
                               string descriptionResourceName,
                               string messageFormatResourceName,
                               IList <Type> suppressionAttributes)
        {
            var decomposedDetails = DecomposeDetailsFromClassName(className);
            var code = decomposedDetails.Item1;

            Name                  = decomposedDetails.Item2;
            NameWithCode          = $"{decomposedDetails.Item3} - {Name}";
            Category              = category;
            _defaultState         = defaultState;
            Severity              = severity;
            SuppressionAttributes = suppressionAttributes;

            Title         = LocalizableStringFactory.LocalizableResourceString(titleResourceName);
            Description   = LocalizableStringFactory.LocalizableResourceString(descriptionResourceName);
            MessageFormat = LocalizableStringFactory.LocalizableResourceString(messageFormatResourceName);
            DiagnosticId  = Title.ToString().Replace("-", "");

            if (Title.ToString() != code)
            {
                throw new ArgumentException($@"Title resource value isn't of the correct format: should be {code}", nameof(titleResourceName));
            }
        }
 public NamedItemSuppresionAttributeDetails(string className,
                                            AnalyzerCategoryDetails category,
                                            DefaultState defaultState,
                                            DiagnosticSeverity severity,
                                            string titleResourceName,
                                            string descriptionResourceName,
                                            string messageFormatResourceName)
 {
     _analyzerDetails = new AnalyzerDetails(className,
                                            category,
                                            defaultState,
                                            severity,
                                            titleResourceName,
                                            descriptionResourceName,
                                            messageFormatResourceName,
                                            new List <Type>());
 }
 public NamedItemSuppresionAttributeDetails(string className, 
                        AnalyzerCategoryDetails category,
                        DefaultState defaultState,
                        DiagnosticSeverity severity,
                        string titleResourceName,
                        string descriptionResourceName,
                        string messageFormatResourceName)
 {
     _analyzerDetails = new AnalyzerDetails(className,
                                            category,
                                            defaultState,
                                            severity,
                                            titleResourceName,
                                            descriptionResourceName,
                                            messageFormatResourceName,
                                            new List<Type>());
 }
Exemplo n.º 5
0
 public static string ProcessCategoryTemplateText(string template,
                                                  AnalyzerCategoryDetails category,
                                                  IEnumerable<AnalyzerDetails> implementedAnalyzersDetails,
                                                  IEnumerable<AnalyzerDetails> plannedAnalyzerDetails,
                                                  string headerTemplate,
                                                  Func<string, string> linkCreator)
 {
     return template.Replace("%NAME%", category.Name)
                    .Replace("%HEADER%", ProcessHeaderTemplate(headerTemplate, category.Name))
                    .Replace("%DESCRIPTION%", category.Description)
                    .Replace("%IMPLEMENTED-LIST%",
                             GenerateSpecificAnalyzerLinksList(implementedAnalyzersDetails,
                                                               category,
                                                               "implemented yet",
                                                               linkCreator))
                    .Replace("%PLANNED-LIST%",
                             GenerateSpecificAnalyzerLinksList(plannedAnalyzerDetails,
                                                               category,
                                                               "planned",
                                                               linkCreator));
 }
Exemplo n.º 6
0
 private static string CategoryNameLink(AnalyzerCategoryDetails category) => category.Name.Replace(" ", "");
Exemplo n.º 7
0
 private static string CreateCategoryPageLink(AnalyzerCategoryDetails category,
                                              Func<string, string> linkCreator)
 {
     return $"* [{category.Name}]({linkCreator(CategoryNameLink(category))})";
 }
Exemplo n.º 8
0
 private static string GenerateSpecificAnalyzerLinksList(IEnumerable<AnalyzerDetails> analyzersDetails,
                                                         AnalyzerCategoryDetails category,
                                                         string description,
                                                         Func<string, string> linkCreator)
 {
     var links = GenerateAnalyzerLinksList(analyzersDetails,
                                           cat => cat.Name == category.Name,
                                           cat => "",
                                           linkCreator);
     return links == "" ? $"There are no analyzers {description} for this category." : links;
 }