protected override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node) { var callsTruthiness = node.DescendentNodes().OfType<InvocationExpressionSyntax>() .Select(i => i.Expression).OfType<IdentifierNameSyntax>() .Any(a => a.PlainName == "__Truthy"); var allMethods = node.DescendentNodes().OfType<MethodDeclarationSyntax>().ToList(); if (callsTruthiness) { SyntaxList<MemberDeclarationSyntax> newMembers = Syntax.List(node.Members.Union(new[] { TruthyMethod })); return node.Update(node.Attributes, node.Modifiers, node.Keyword, node.Identifier, node.TypeParameterListOpt, node.BaseListOpt, node.ConstraintClauses, node.OpenBraceToken, newMembers, node.CloseBraceToken, node.SemicolonTokenOpt); } return base.VisitClassDeclaration(node); }
protected override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node) { var callsTruthiness = node.DescendentNodes().OfType <InvocationExpressionSyntax>() .Select(i => i.Expression).OfType <IdentifierNameSyntax>() .Any(a => a.PlainName == "__Truthy"); var allMethods = node.DescendentNodes().OfType <MethodDeclarationSyntax>().ToList(); if (callsTruthiness) { SyntaxList <MemberDeclarationSyntax> newMembers = Syntax.List(node.Members.Union(new[] { TruthyMethod })); return(node.Update(node.Attributes, node.Modifiers, node.Keyword, node.Identifier, node.TypeParameterListOpt, node.BaseListOpt, node.ConstraintClauses, node.OpenBraceToken, newMembers, node.CloseBraceToken, node.SemicolonTokenOpt)); } return(base.VisitClassDeclaration(node)); }