本文整理汇总了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()));
}
}
}
示例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()));
}
}
}
示例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()));
}
}
}
示例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()));
}
}
}
示例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));
}
}
}
}
示例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()));
}
}
}
示例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()));
}
}
}
示例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));
}
}
}
}
示例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));
}
}
}
}
示例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()));
}
}
}
示例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()));
}
}
}
示例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()));
}
}
}
}