protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { var syntaxTree = context.SyntaxTree; return context.IsGlobalStatementContext || syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) || context.IsMemberDeclarationContext(validModifiers: s_validModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) || context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken); }
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { if (context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken)) { return true; } var token = context.TargetToken; if (token.Kind() == SyntaxKind.OpenBracketToken && token.Parent.IsKind(SyntaxKind.AttributeList)) { if (token.GetAncestor<PropertyDeclarationSyntax>() != null || token.GetAncestor<EventDeclarationSyntax>() != null) { return true; } } return false; }
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken); }
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsMemberAttributeContext(s_validTypeDeclarations, cancellationToken); }
private static bool IsAttributeContext(CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken) || (context.SyntaxTree.IsInteractiveOrScript() && context.IsTypeAttributeContext(cancellationToken)); }