コード例 #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));
            }
        }
コード例 #2
0
ファイル: AnalyzerDetails.cs プロジェクト: espenrl/Arnolyzer
        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));
            }
        }
コード例 #3
0
 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>());
 }
コード例 #4
0
 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>());
 }
コード例 #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));
 }
コード例 #6
0
 private static string CategoryNameLink(AnalyzerCategoryDetails category) => category.Name.Replace(" ", "");
コード例 #7
0
 private static string CreateCategoryPageLink(AnalyzerCategoryDetails category,
                                              Func<string, string> linkCreator)
 {
     return $"* [{category.Name}]({linkCreator(CategoryNameLink(category))})";
 }
コード例 #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;
 }