当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxNodeAnalysisContext.GetDocumentationMode方法代码示例

本文整理汇总了C#中SyntaxNodeAnalysisContext.GetDocumentationMode方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNodeAnalysisContext.GetDocumentationMode方法的具体用法?C# SyntaxNodeAnalysisContext.GetDocumentationMode怎么用?C# SyntaxNodeAnalysisContext.GetDocumentationMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SyntaxNodeAnalysisContext的用法示例。


在下文中一共展示了SyntaxNodeAnalysisContext.GetDocumentationMode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleEnumMember

        private static void HandleEnumMember(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            EnumMemberDeclarationSyntax enumMemberDeclaration = context.Node as EnumMemberDeclarationSyntax;
            if (enumMemberDeclaration != null)
            {
                if (!XmlCommentHelper.HasDocumentation(enumMemberDeclaration))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, enumMemberDeclaration.Identifier.GetLocation()));
                }
            }
        }
开发者ID:chrfin,项目名称:StyleCopAnalyzers,代码行数:16,代码来源:SA1602EnumerationItemsMustBeDocumented.cs

示例2: HandleEnumMemberDeclaration

            public static void HandleEnumMemberDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings)
            {
                if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
                {
                    return;
                }

                EnumMemberDeclarationSyntax declaration = (EnumMemberDeclarationSyntax)context.Node;
                Accessibility declaredAccessibility = declaration.GetDeclaredAccessibility();
                Accessibility effectiveAccessibility = declaration.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken);
                if (NeedsComment(settings.DocumentationRules, declaration.Kind(), declaration.Parent.Kind(), declaredAccessibility, effectiveAccessibility))
                {
                    if (!XmlCommentHelper.HasDocumentation(declaration))
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                    }
                }
            }
开发者ID:0x084E,项目名称:StyleCopAnalyzers,代码行数:18,代码来源:SA1602EnumerationItemsMustBeDocumented.cs

示例3: HandleTypeDeclaration

        private void HandleTypeDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            BaseTypeDeclarationSyntax declaration = context.Node as BaseTypeDeclarationSyntax;

            bool isNestedInClassOrStruct = this.IsNestedType(declaration);

            if (declaration != null && this.NeedsComment(declaration.Modifiers, isNestedInClassOrStruct ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword))
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:19,代码来源:SA1600ElementsMustBeDocumented.cs

示例4: HandleTypeDeclaration

            public void HandleTypeDeclaration(SyntaxNodeAnalysisContext context)
            {
                if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
                {
                    return;
                }

                BaseTypeDeclarationSyntax declaration = (BaseTypeDeclarationSyntax)context.Node;
                if (declaration.Modifiers.Any(SyntaxKind.PartialKeyword))
                {
                    // Handled by SA1601
                    return;
                }

                Accessibility declaredAccessibility = declaration.GetDeclaredAccessibility(context.SemanticModel, context.CancellationToken);
                Accessibility effectiveAccessibility = declaration.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken);
                if (this.NeedsComment(declaration.Kind(), declaration.Parent.Kind(), declaredAccessibility, effectiveAccessibility))
                {
                    if (!XmlCommentHelper.HasDocumentation(declaration))
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                    }
                }
            }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:24,代码来源:SA1600ElementsMustBeDocumented.cs

示例5: HandleEventFieldDeclaration

            public void HandleEventFieldDeclaration(SyntaxNodeAnalysisContext context)
            {
                if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
                {
                    return;
                }

                EventFieldDeclarationSyntax declaration = (EventFieldDeclarationSyntax)context.Node;
                VariableDeclarationSyntax variableDeclaration = declaration.Declaration;

                Accessibility declaredAccessibility = declaration.GetDeclaredAccessibility(context.SemanticModel, context.CancellationToken);
                Accessibility effectiveAccessibility = declaration.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken);
                if (variableDeclaration != null && this.NeedsComment(declaration.Kind(), declaration.Parent.Kind(), declaredAccessibility, effectiveAccessibility))
                {
                    if (!XmlCommentHelper.HasDocumentation(declaration))
                    {
                        var locations = variableDeclaration.Variables.Select(v => v.Identifier.GetLocation());
                        foreach (var location in locations)
                        {
                            context.ReportDiagnostic(Diagnostic.Create(Descriptor, location));
                        }
                    }
                }
            }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:24,代码来源:SA1600ElementsMustBeDocumented.cs

示例6: HandleIndexerDeclaration

            public void HandleIndexerDeclaration(SyntaxNodeAnalysisContext context)
            {
                if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
                {
                    return;
                }

                IndexerDeclarationSyntax declaration = (IndexerDeclarationSyntax)context.Node;

                Accessibility declaredAccessibility = declaration.GetDeclaredAccessibility(context.SemanticModel, context.CancellationToken);
                Accessibility effectiveAccessibility = declaration.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken);
                if (this.NeedsComment(declaration.Kind(), declaration.Parent.Kind(), declaredAccessibility, effectiveAccessibility))
                {
                    if (!XmlCommentHelper.HasDocumentation(declaration))
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.ThisKeyword.GetLocation()));
                    }
                }
            }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:19,代码来源:SA1600ElementsMustBeDocumented.cs

示例7: HandleMethodDeclaration

        private void HandleMethodDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            MethodDeclarationSyntax declaration = context.Node as MethodDeclarationSyntax;
            SyntaxKind defaultVisibility = SyntaxKind.PrivateKeyword;

            if (this.IsInterfaceMemberDeclaration(declaration) || declaration.ExplicitInterfaceSpecifier != null)
            {
                defaultVisibility = SyntaxKind.PublicKeyword;
            }

            if (declaration != null && this.NeedsComment(declaration.Modifiers, defaultVisibility))
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:23,代码来源:SA1600ElementsMustBeDocumented.cs

示例8: HandleEventFieldDeclaration

        private void HandleEventFieldDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            EventFieldDeclarationSyntax declaration = context.Node as EventFieldDeclarationSyntax;
            SyntaxKind defaultVisibility = SyntaxKind.PrivateKeyword;

            if (this.IsInterfaceMemberDeclaration(declaration))
            {
                defaultVisibility = SyntaxKind.PublicKeyword;
            }

            var variableDeclaration = declaration?.Declaration;

            if (variableDeclaration != null && this.NeedsComment(declaration.Modifiers, defaultVisibility))
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    var locations = variableDeclaration.Variables.Select(v => v.Identifier.GetLocation());
                    foreach (var location in locations)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, location));
                    }
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:29,代码来源:SA1600ElementsMustBeDocumented.cs

示例9: HandleFieldDeclaration

        private void HandleFieldDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            FieldDeclarationSyntax declaration = context.Node as FieldDeclarationSyntax;
            var variableDeclaration = declaration?.Declaration;

            if (variableDeclaration != null && this.NeedsComment(declaration.Modifiers, SyntaxKind.PrivateKeyword))
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    var locations = variableDeclaration.Variables.Select(v => v.Identifier.GetLocation());
                    foreach (var location in locations)
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, location));
                    }
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:22,代码来源:SA1600ElementsMustBeDocumented.cs

示例10: HandleDestructorDeclaration

        private void HandleDestructorDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            DestructorDeclarationSyntax declaration = context.Node as DestructorDeclarationSyntax;

            if (declaration != null)
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:17,代码来源:SA1600ElementsMustBeDocumented.cs

示例11: HandleConstructorDeclaration

        private void HandleConstructorDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            ConstructorDeclarationSyntax declaration = context.Node as ConstructorDeclarationSyntax;

            if (declaration != null && this.NeedsComment(declaration.Modifiers, SyntaxKind.PrivateKeyword))
            {
                if (!XmlCommentHelper.HasDocumentation(declaration))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.Identifier.GetLocation()));
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:17,代码来源:SA1600ElementsMustBeDocumented.cs

示例12: HandleMethodDeclaration

        private void HandleMethodDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.GetDocumentationMode() != DocumentationMode.Diagnose)
            {
                return;
            }

            MethodDeclarationSyntax methodDeclaration = context.Node as MethodDeclarationSyntax;
            if (methodDeclaration != null)
            {
                if (methodDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword))
                {
                    if (!XmlCommentHelper.HasDocumentation(methodDeclaration))
                    {
                        context.ReportDiagnostic(Diagnostic.Create(Descriptor, methodDeclaration.Identifier.GetLocation()));
                    }
                }
            }
        }
开发者ID:iaingalloway,项目名称:StyleCopAnalyzers,代码行数:19,代码来源:SA1601PartialElementsMustBeDocumented.cs


注:本文中的SyntaxNodeAnalysisContext.GetDocumentationMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。