Beispiel #1
0
        private async Task<Document> MakePrivateDeclarationAsync(Document document, FieldDeclarationSyntax declaration, CancellationToken c)
        {
            var accessToken = declaration.ChildTokens()
                .SingleOrDefault(token => token.Kind() == SyntaxKind.PublicKeyword);

            var privateAccessToken = SyntaxFactory.Token(SyntaxKind.PrivateKeyword);

            var root = await document.GetSyntaxRootAsync(c);
            var newRoot = root.ReplaceToken(accessToken, privateAccessToken);

            return document.WithSyntaxRoot(newRoot);

        }
 private static bool IsStatic(FieldDeclarationSyntax fieldDeclaration)
 {
     return fieldDeclaration.ChildTokens().Any(token => token.Kind() == SyntaxKind.StaticKeyword);
 }
 private static bool IsReadonly(FieldDeclarationSyntax fieldDeclaration)
 {
     return fieldDeclaration.ChildTokens().Any(token => token.Kind() == SyntaxKind.ReadOnlyKeyword);
 }
 private static SyntaxToken[] GetAccessTokenFor(FieldDeclarationSyntax fieldDeclaration, SyntaxKind syntaxKind)
 {
     return fieldDeclaration.ChildTokens().Where(token => token.Kind() == syntaxKind).ToArray();
 }