private async Task<Document> ReplaceDateTimeAsync(Document document, PredefinedTypeSyntax node, CancellationToken cancellationToken) { var semanticModel = await document.GetSemanticModelAsync(cancellationToken); var root = await document.GetSyntaxRootAsync(); var node2 = node.WithKeyword(SyntaxFactory.ParseToken("DateTimeOffset")).WithTrailingTrivia(node.GetTrailingTrivia()); var newRoot = root.ReplaceNode(node, node2); var newDocument = document.WithSyntaxRoot(newRoot); return newDocument; }
private async Task<Document> ReplaceDateAsync(Document document, PredefinedTypeSyntax node, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(); var generator = SyntaxGenerator.GetGenerator(document); var newIdentifierSyntax = generator.IdentifierName("DateTimeOffset").WithTrailingTrivia(node.GetTrailingTrivia()); var newRoot = root.ReplaceNode(node, newIdentifierSyntax); var newDocument = document.WithSyntaxRoot(newRoot); return newDocument; }