protected override void ProcessInternal(INamedTypeSymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter) { DelegateConfig config = policyConfig.DelegateConfig; if (!AnyVisibilityMatches(symbol.DeclaredAccessibility, config.VisibilitiesToCheck)) { return; } if (symbol.DelegateInvokeMethod == null) { return; } IDocumentationComment documentation = symbol.GetDocumentationComment(); if (config.SampleDocumentationRequired && string.IsNullOrWhiteSpace(documentation.ExampleText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSampleDocumentation, symbol)); } if (config.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(documentation.SummaryText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol)); } if (config.ResultDocumentationRequired && !symbol.DelegateInvokeMethod.ReturnsVoid && string.IsNullOrWhiteSpace(documentation.ReturnsText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingReturnsDocumentation, symbol)); } if (config.ParameterDocumentationRequired && !symbol.DelegateInvokeMethod.Parameters.IsEmpty) { foreach (IParameterSymbol parameterSymbol in symbol.DelegateInvokeMethod.Parameters) { if (string.IsNullOrWhiteSpace(documentation.GetParameterText(parameterSymbol.Name))) { violationReporter.Report(ViolationFromSymbol(string.Format(ViolationMessage.MissingParameter, parameterSymbol.Name), symbol)); } } } if (config.GenericParameterDocumentationRequired && !symbol.TypeParameters.IsEmpty) { foreach (ITypeParameterSymbol typeParameter in symbol.TypeParameters) { if (string.IsNullOrWhiteSpace(documentation.GetTypeParameterText(typeParameter.Name))) { violationReporter.Report(ViolationFromSymbol(string.Format(ViolationMessage.MissingTypeParameter, typeParameter.Name), symbol)); } } } }
protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter) { IMethodSymbol methodSymbol = (IMethodSymbol)symbol; MethodConfig config = policyConfig.MethodConfig; if (methodSymbol.IsOverride && !config.DocumentOverrides) { return; } if (methodSymbol.MethodKind == MethodKind.ExplicitInterfaceImplementation && !config.ExplicitInterfaceMethodDocumentationRequired) { return; } if (!AnyVisibilityMatches(symbol.DeclaredAccessibility, config.VisibilitiesToCheck) && methodSymbol.MethodKind != MethodKind.ExplicitInterfaceImplementation) { return; } // skip compiler generated methods for which there is no source code if (symbol.IsImplicitlyDeclared) { return; } // skip special method kinds if (!AllowedMethodKinds.Contains(methodSymbol.MethodKind)) { return; } IDocumentationComment documentation = symbol.GetDocumentationComment(); if (config.SampleDocumentationRequired && string.IsNullOrWhiteSpace(documentation.ExampleText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSampleDocumentation, symbol)); } if (config.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(documentation.SummaryText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol)); } if (config.ResultDocumentationRequired && !methodSymbol.ReturnsVoid && string.IsNullOrWhiteSpace(documentation.ReturnsText)) { violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingReturnsDocumentation, symbol)); } if (config.ParameterDocumentationRequired && !methodSymbol.Parameters.IsEmpty) { foreach (IParameterSymbol parameterSymbol in methodSymbol.Parameters) { if (string.IsNullOrWhiteSpace(documentation.GetParameterText(parameterSymbol.Name))) { violationReporter.Report(ViolationFromSymbol(string.Format(ViolationMessage.MissingParameter, parameterSymbol.Name), symbol)); } } } if (config.GenericParameterDocumentationRequired && !methodSymbol.TypeParameters.IsEmpty) { foreach (ITypeParameterSymbol typeParameter in methodSymbol.TypeParameters) { if (string.IsNullOrWhiteSpace(documentation.GetTypeParameterText(typeParameter.Name))) { violationReporter.Report(ViolationFromSymbol(string.Format("Missing documentation for type parameter with name '{0}'", typeParameter.Name), symbol)); } } } }