diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/Razor/CreateComponentCodeActionResolver.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/Razor/CreateComponentCodeActionResolver.cs index 4e1433f88e..aa08bd57a5 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/Razor/CreateComponentCodeActionResolver.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/CodeActions/Razor/CreateComponentCodeActionResolver.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Extensions; using Microsoft.AspNetCore.Razor.Language.Syntax; using Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Models; +using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.VisualStudio.LanguageServer.Protocol; @@ -60,9 +61,10 @@ internal sealed class CreateComponentCodeActionResolver(IDocumentContextFactory Host = string.Empty, }.Uri; - ImmutableArray> documentChanges = [new CreateFile() { Uri = newComponentUri }]; + using var documentChanges = new PooledArrayBuilder>(); + documentChanges.Add(new CreateFile() { Uri = newComponentUri }); - TryAddNamespaceDirective(codeDocument, newComponentUri, documentChanges); + TryAddNamespaceDirective(codeDocument, newComponentUri, ref documentChanges.AsRef()); return new WorkspaceEdit() { @@ -70,7 +72,7 @@ internal sealed class CreateComponentCodeActionResolver(IDocumentContextFactory }; } - private static void TryAddNamespaceDirective(RazorCodeDocument codeDocument, Uri newComponentUri, ImmutableArray> documentChanges) + private static void TryAddNamespaceDirective(RazorCodeDocument codeDocument, Uri newComponentUri, ref PooledArrayBuilder> documentChanges) { var syntaxTree = codeDocument.GetSyntaxTree(); var namespaceDirective = syntaxTree.Root.DescendantNodes()