in ClrHeapAllocationsAnalyzer/AvoidAllocationWithArrayEmptyCodeFix.cs [162:173]
private async Task<Document> Transform(Document contextDocument, SyntaxNode node, TypeSyntax typeArgument, CancellationToken cancellationToken)
{
var noAllocation = SyntaxFactory.ParseExpression($"Array.Empty<{typeArgument}>()");
var newNode = ReplaceExpression(node, noAllocation);
if (newNode == null)
{
return contextDocument;
}
var syntaxRootAsync = await contextDocument.GetSyntaxRootAsync(cancellationToken);
var newSyntaxRoot = syntaxRootAsync.ReplaceNode(node.Parent, newNode);
return contextDocument.WithSyntaxRoot(newSyntaxRoot);
}