Ejemplo n.º 1
0
 public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
 {
     if (node.Equals(this.fieldDeclaration))
     {
         // Remove field declaration from current location
         return(null);
     }
     return(base.VisitFieldDeclaration(node));
 }
Ejemplo n.º 2
0
            public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
            {
                if (analysedDeclaration is FieldDeclaration fd && node.Equals(fd.FullField))
                {
                    var variables = node.Declaration.Variables;
                    if (variables.Count == 1)
                    {
                        return(null);
                    }

                    return(node.WithDeclaration(node.Declaration.WithVariables(variables.Remove(fd.Variable))));
                }

                return(base.VisitFieldDeclaration(node));
            }
            public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node)
            {
                FieldDeclarationSyntax processedNode = (FieldDeclarationSyntax)base.VisitFieldDeclaration(node);

                if (node.Equals(this.fieldDeclaration))
                {
                    // Replace all access modifiers with private
                    SyntaxTokenList fieldModifiers = Syntax.TokenList(processedNode.Modifiers.Where(n => !IsAccessModifier(n)))
                                                     .Add(Syntax.Token(SyntaxKind.PrivateKeyword));

                    processedNode = processedNode.WithModifiers(fieldModifiers)
                                    .WithAdditionalAnnotations(CodeAnnotations.Formatting);
                }

                return(processedNode);
            }