private async Task<Document> EnableQueryAsync(Document document, MethodDeclarationSyntax node, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(); var newMethod = node.WithoutLeadingTrivia().WithAttributeLists(node.AttributeLists.Add(SyntaxFactory.AttributeList( SyntaxFactory.SingletonSeparatedList<AttributeSyntax>( SyntaxFactory.Attribute( SyntaxFactory.IdentifierName("EnableQuery")))))).WithLeadingTrivia(node.GetLeadingTrivia()); var newRoot = root.ReplaceNode(node, newMethod); var newDocument = document.WithSyntaxRoot(newRoot); return newDocument; }