Esempio n. 1
0
        private bool ProcessMultiLineComments(SyntaxNodeAnalysisContext context, List <SyntaxTrivia> multiLineComments)
        {
            var multiLineCommentViolationFound = false;

            if (multiLineComments?.Count > 0)
            {
                foreach (var multiLineComment in multiLineComments)
                {
                    var content = multiLineComment.ToFullString();
                    if (RegexManager.MatchFound($@"\/[*]((.)*\n){{{MaxNoOfLinesForComments},}}", content))
                    {
                        DiagnosticsManager.CreateCommentsTooLongDiagnostic(context, multiLineComment.GetLocation(), Rule, Message);
                        multiLineCommentViolationFound = true;
                        break;
                    }
                }
            }
            return(multiLineCommentViolationFound);
        }
Esempio n. 2
0
 private void ProcessSingleLineComments(SyntaxNodeAnalysisContext context, List <SyntaxTrivia> singleLineComments, string declarationBodyText = null)
 {
     if (singleLineComments?.Count > 0)
     {
         if (!string.IsNullOrWhiteSpace(declarationBodyText) && RegexManager.MatchFound($@"((\s)*\/\/(.)*(\n)*){{{MaxNoOfLinesForComments},}}", declarationBodyText))
         {
             foreach (var singleLineComment in singleLineComments)
             {
                 DiagnosticsManager.CreateCommentsTooLongDiagnostic(context, singleLineComment.GetLocation(), Rule, Message);
             }
         }
         else if (singleLineComments.Count > MaxNoOfLinesForComments)
         {
             foreach (var singleLineComment in singleLineComments)
             {
                 DiagnosticsManager.CreateCommentsTooLongDiagnostic(context, singleLineComment.GetLocation(), Rule, Message);
             }
         }
     }
 }