protected override IEnumerable <Diagnostic> AnalyzeField(IFieldSymbol symbol, string commentXml) { if (commentXml.IsNullOrWhiteSpace()) { return(Enumerable.Empty <Diagnostic>()); } var symbolName = symbol.Name; if (symbolName.EndsWith(Constants.DependencyPropertyFieldSuffix, StringComparison.OrdinalIgnoreCase) is false) { return(Enumerable.Empty <Diagnostic>()); } var propertyName = symbolName.WithoutSuffix(Constants.DependencyPropertyFieldSuffix); var containingType = symbol.ContainingType; if (containingType.GetMembersIncludingInherited <IPropertySymbol>().All(_ => _.Name != propertyName)) { // it's an unknown dependency property return(Enumerable.Empty <Diagnostic>()); } List <Diagnostic> results = null; var containingTypeFullName = containingType.ToString(); // loop over phrases for summaries and values ValidatePhrases(symbol, CommentExtensions.GetSummaries(commentXml), () => Phrases(Constants.Comments.DependencyPropertyFieldSummaryPhrase, containingTypeFullName, propertyName), Constants.XmlTag.Summary, ref results); ValidatePhrases(symbol, CommentExtensions.GetValue(commentXml), () => Phrases(Constants.Comments.DependencyPropertyFieldValuePhrase, containingTypeFullName, propertyName), Constants.XmlTag.Value, ref results); return(results ?? Enumerable.Empty <Diagnostic>()); }
protected IEnumerable <Diagnostic> AnalyzeSummaries(ISymbol symbol, string commentXml) { if (commentXml.IsNullOrWhiteSpace()) { return(Enumerable.Empty <Diagnostic>()); } var summaries = CommentExtensions.GetSummaries(commentXml); return(summaries.Any() ? AnalyzeSummary(symbol, summaries) : Enumerable.Empty <Diagnostic>()); }
protected override IEnumerable <Diagnostic> AnalyzeMethod(IMethodSymbol symbol, string commentXml) { if (commentXml.IsNullOrWhiteSpace()) { return(Enumerable.Empty <Diagnostic>()); } var summaries = CommentExtensions.GetSummaries(commentXml); var results = summaries.Any() && summaries.All(_ => _ != SummaryPhrase) ? new List <Diagnostic>(1) { Issue(symbol, SummaryPhrase) } : null; // check for parameter foreach (var parameter in symbol.Parameters) { var comment = parameter.GetComment(commentXml); switch (comment) { case null: case ParameterPhrase: continue; } if (results is null) { results = new List <Diagnostic>(1); } results.Add(Issue(parameter, ParameterPhrase)); } return(results ?? Enumerable.Empty <Diagnostic>()); }