From 0a24790d605083e2708901ce51e48d55bd8fe931 Mon Sep 17 00:00:00 2001 From: "Andrew Hall (METAL)" Date: Wed, 10 Jul 2024 14:07:01 -0700 Subject: [PATCH] Fix one case where immutable should have been mutable --- .../Razor/CreateComponentCodeActionResolver.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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()