Пример #1
0
        protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            EventConfig config = policyConfig.EventConfig;

            if (symbol.IsOverride && !config.DocumentOverrides)
            {
                return;
            }

            if (symbol.ContainingType != null && symbol.ContainingType.TypeKind == TypeKind.Interface && !config.InterfaceDeclarationDocumentationRequired)
            {
                return;
            }

            if (!symbol.CanBeReferencedByName && !config.ExplicitInterfaceEventDocumentationRequired)
            {
                return;
            }

            if (!AnyVisibilityMatches(symbol.DeclaredAccessibility, config.VisibilitiesToCheck) && symbol.CanBeReferencedByName)
            {
                return;
            }

            IDocumentationComment documentation = symbol.GetDocumentationComment();

            if (config.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(documentation.SummaryText))
            {
                violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol));
            }
        }
Пример #2
0
        protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            if (symbol.Kind != SymbolKind.Namespace)
            {
                throw new ArgumentException(string.Format("symbol is not of kind: Namespace. It's of type: {0}", symbol.Kind));
            }

            ProcessChildren((INamespaceSymbol)symbol, policyConfig, violationReporter);
        }
Пример #3
0
        protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            if (symbol.Kind != SymbolKind.NamedType)
            {
                throw new ArgumentException(string.Format("symbol is not of kind: NamedType. It's of type: {0}", symbol.Kind));
            }

            INamedTypeSymbol namedTypeSymbol = (INamedTypeSymbol)symbol;

            if (namedTypeSymbol.TypeKind != TypeKind)
            {
                throw new ArgumentException(string.Format("symbol is not of typekind: {0}. It's of typekind: {1}", TypeKind, namedTypeSymbol.TypeKind));
            }

            ProcessInternal(namedTypeSymbol, policyConfig, violationReporter);
        }
Пример #4
0
        protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            FieldConfig config = policyConfig.FieldConfig;

            if ((!AnyVisibilityMatches(symbol.DeclaredAccessibility, config.VisibilitiesToCheck) || !symbol.CanBeReferencedByName))
            {
                return;
            }

            IDocumentationComment documentation = symbol.GetDocumentationComment();

            if (config.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(documentation.SummaryText))
            {
                violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol));
            }
        }
Пример #5
0
        protected override void ProcessInternal(INamedTypeSymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            EnumConfig enumConfig = policyConfig.EnumConfig;

            if (!AnyVisibilityMatches(symbol.DeclaredAccessibility, enumConfig.VisibilitiesToCheck))
            {
                return;
            }

            IDocumentationComment classDocumentation = symbol.GetDocumentationComment();

            if (enumConfig.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(classDocumentation.SummaryText))
            {
                violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol));
            }
        }
Пример #6
0
        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));
                    }
                }
            }
        }
Пример #7
0
        protected override void ProcessInternal(INamedTypeSymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
        {
            ClassConfig config = policyConfig.StructConfig;

            if (!AnyVisibilityMatches(symbol.DeclaredAccessibility, config.VisibilitiesToCheck))
            {
                return;
            }

            IDocumentationComment classDocumentation = symbol.GetDocumentationComment();

            if (config.SampleDocumentationRequired && string.IsNullOrWhiteSpace(classDocumentation.ExampleText))
            {
                violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSampleDocumentation, symbol));
            }

            if (config.SummaryDocumentationRequired && string.IsNullOrWhiteSpace(classDocumentation.SummaryText))
            {
                violationReporter.Report(ViolationFromSymbol(ViolationMessage.MissingSummaryDocumentation, symbol));
            }

            if (!symbol.TypeParameters.IsEmpty && config.GenericParameterDocumentationRequired)
            {
                foreach (ITypeParameterSymbol typeParameter in symbol.TypeParameters)
                {
                    if (string.IsNullOrWhiteSpace(classDocumentation.GetTypeParameterText(typeParameter.Name)))
                    {
                        violationReporter.Report(ViolationFromSymbol(string.Format(ViolationMessage.MissingTypeParameter, typeParameter.Name), symbol));
                    }
                }
            }

            ProcessChildren(symbol, policyConfig, violationReporter);
        }
Пример #8
0
 protected abstract void ProcessInternal(INamedTypeSymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter);
Пример #9
0
        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));
                    }
                }
            }
        }
Пример #10
0
 protected override void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
 {
     // intentionally do nothing
 }
Пример #11
0
 void ISymbolProcessor.Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
 {
     Process(symbol, policyConfig, violationReporter);
 }
Пример #12
0
 protected void ProcessChildren(INamespaceOrTypeSymbol namespaceOrTypeSymbol, PolicyConfig policyConfig, IViolationReporter violationReporter)
 {
     foreach (ISymbol childSymbol in namespaceOrTypeSymbol.GetMembers())
     {
         new CodeCommentsFacade().GetSymbolProcessorFactory().CreateSymbolProcessor(childSymbol).Process(childSymbol, policyConfig, violationReporter);
     }
 }
Пример #13
0
 protected abstract void Process(ISymbol symbol, PolicyConfig policyConfig, IViolationReporter violationReporter);