Пример #1
0
 public static string ProcessAnalyzerTemplateText(string template,
                                                  AnalyzerDetails details,
                                                  ImplementationStatus status,
                                                  ExtraWordsContents extraWords,
                                                  string headerTemplate,
                                                  Func <string, string> linkCreator)
 {
     return(template.Replace("%HEADER%", ProcessHeaderTemplate(headerTemplate, details.NameWithCode))
            .Replace("%NAME%", details.Name)
            .Replace("%NAME-AND-CODE%", details.NameWithCode)
            .Replace("%STATUS%", status == Implemented ? "Implemented" : "Planned for a future release")
            .Replace("%CODE%", details.Title.ToString())
            .Replace("%ID%", details.DiagnosticId)
            .Replace("%DESCRIPTION%", details.Description.ToString())
            .Replace("%CATEGORY%", details.Category.Name)
            .Replace("%CATEGORY-LINK%", $"{linkCreator(CategoryNameLink(details.Category))}")
            .Replace("%SEVERITY%", details.SeverityText)
            .Replace("%ENABLED-BY_DEFAULT%", details.EnabledByDefault ? "Yes" : "No")
            .Replace("%CAUSE-WORDS%", extraWords.Cause)
            .Replace("%PRE-CODEFIX-WORDS%", extraWords.PreCodeFix)
            .Replace("%POST-CODEFIX-WORDS%", extraWords.PostCodeFix)
            .Replace("%PRE-SUPPRESSION-WORDS%", extraWords.PreSuppression)
            .Replace("%POST-SUPPRESSION-WORDS%", extraWords.PostSuppression)
            .Replace("%CODEFIXES%", GenerateCodeFixMessage(status))
            .Replace("%SUPPRESSIONS%", GenerateSuppressionMessage(details.SuppressionAttributes, status)));
 }
Пример #2
0
 public static string ProcessAnalyzerTemplateText(string template, 
                                                  AnalyzerDetails details,
                                                  ImplementationStatus status,
                                                  ExtraWordsContents extraWords,
                                                  string headerTemplate,
                                                  Func<string, string> linkCreator)
 {
     return template.Replace("%HEADER%", ProcessHeaderTemplate(headerTemplate, details.NameWithCode))
                    .Replace("%NAME%", details.Name)
                    .Replace("%NAME-AND-CODE%", details.NameWithCode)
                    .Replace("%STATUS%", status == Implemented ? "Implemented" : "Planned for a future release")
                    .Replace("%CODE%", details.Title.ToString())
                    .Replace("%ID%", details.DiagnosticId)
                    .Replace("%DESCRIPTION%", details.Description.ToString())
                    .Replace("%CATEGORY%", details.Category.Name)
                    .Replace("%CATEGORY-LINK%", $"{linkCreator(CategoryNameLink(details.Category))}")
                    .Replace("%SEVERITY%", details.SeverityText)
                    .Replace("%ENABLED-BY_DEFAULT%", details.EnabledByDefault ? "Yes" : "No")
                    .Replace("%CAUSE-WORDS%", extraWords.Cause)
                    .Replace("%PRE-CODEFIX-WORDS%", extraWords.PreCodeFix)
                    .Replace("%POST-CODEFIX-WORDS%", extraWords.PostCodeFix)
                    .Replace("%PRE-SUPPRESSION-WORDS%", extraWords.PreSuppression)
                    .Replace("%POST-SUPPRESSION-WORDS%", extraWords.PostSuppression)
                    .Replace("%CODEFIXES%", GenerateCodeFixMessage(status))
                    .Replace("%SUPPRESSIONS%", GenerateSuppressionMessage(details.SuppressionAttributes, status));
 }
Пример #3
0
        public void TestRunReport_NoImplementations()
        {
            var impl = new ImplementationStatus[]
            {
            };

            DoTest(impl,
                   expectedSubstrings: new[] { "Найдено багов: 0 из 0" },
                   notExpectedSubstrings: new[] { "Найдено секретных багов" });
        }
Пример #4
0
        private static string GenerateSuppressionMessage(IList <Type> suppressionAttributes,
                                                         ImplementationStatus status)
        {
            if (status == Planned)
            {
                return("Not yet implemented.");
            }

            return(suppressionAttributes.Any()
                ? $"This rule can be suppressed using the following attributes: {DescribeEachAttribute(suppressionAttributes)}"
                : "This rule cannot be suppressed.");
        }
        private static void GenerateAnalyzerDocuments(IEnumerable <AnalyzerDetails> analyzersDetails,
                                                      ImplementationStatus status,
                                                      DocumentationTarget target,
                                                      string headerTemplate,
                                                      Func <string, string> linkCreator)
        {
            var template = File.ReadAllText(@"..\..\DocumentationTemplates\AnalyzerTemplate.md");

            foreach (var details in analyzersDetails)
            {
                var analyzerName = details.DiagnosticId;
                Console.WriteLine($@"Generating {analyzerName}.md");

                var extraWords        = CreateExtraWordsSet(analyzerName);
                var processedContents =
                    ProcessAnalyzerTemplateText(template, details, status, extraWords, headerTemplate, linkCreator);

                File.WriteAllText($"{DocumentPath(target)}{analyzerName}.md", processedContents);
            }
        }
Пример #6
0
        private static string GenerateSuppressionMessage(IList<Type> suppressionAttributes,
                                                         ImplementationStatus status)
        {
            if (status == Planned) return "Not yet implemented.";

            return suppressionAttributes.Any()
                ? $"This rule can be suppressed using the following attributes: {DescribeEachAttribute(suppressionAttributes)}"
                : "This rule cannot be suppressed.";
        }
Пример #7
0
 private static string GenerateCodeFixMessage(ImplementationStatus status) =>
     status == Planned
         ? "Not yet implemented."
         : "There currently aren't any implemented code-fixes for this rule.";
        private static void GenerateAnalyzerDocuments(IEnumerable<AnalyzerDetails> analyzersDetails,
                                                      ImplementationStatus status,
                                                      DocumentationTarget target,
                                                      string headerTemplate,
                                                      Func<string, string> linkCreator)
        {
            var template = File.ReadAllText(@"..\..\DocumentationTemplates\AnalyzerTemplate.md");
            foreach (var details in analyzersDetails)
            {
                var analyzerName = details.DiagnosticId;
                Console.WriteLine($@"Generating {analyzerName}.md");

                var extraWords = CreateExtraWordsSet(analyzerName);
                var processedContents =
                    ProcessAnalyzerTemplateText(template, details, status, extraWords, headerTemplate, linkCreator);

                File.WriteAllText($"{DocumentPath(target)}{analyzerName}.md", processedContents);
            }
        }
Пример #9
0
 private static string GenerateCodeFixMessage(ImplementationStatus status) =>
 status == Planned
         ? "Not yet implemented."
         : "There currently aren't any implemented code-fixes for this rule.";