diff --git a/src/Features/Core/Portable/AddImport/CodeActions/AddImportCodeAction.cs b/src/Features/Core/Portable/AddImport/CodeActions/AddImportCodeAction.cs
index 56f33a95a30324628182c44803fadf39c3cbbcd3..0a0370352ebcd6bac204c6f4e1f67ad270dfdacd 100644
--- a/src/Features/Core/Portable/AddImport/CodeActions/AddImportCodeAction.cs
+++ b/src/Features/Core/Portable/AddImport/CodeActions/AddImportCodeAction.cs
@@ -32,7 +32,7 @@ private abstract class AddImportCodeAction : CodeAction
///
/// The changes to make to to add the import.
///
- protected readonly ImmutableArray TextChanges;
+ private readonly ImmutableArray _textChanges;
protected AddImportCodeAction(
Document originalDocument,
@@ -41,16 +41,16 @@ private abstract class AddImportCodeAction : CodeAction
CodeActionPriority priority)
{
OriginalDocument = originalDocument;
- TextChanges = textChanges;
Title = title;
Tags = tags;
Priority = priority;
+ _textChanges = textChanges;
}
protected async Task GetUpdatedDocumentAsync(CancellationToken cancellationToken)
{
var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
- var newText = oldText.WithChanges(TextChanges);
+ var newText = oldText.WithChanges(_textChanges);
var newDocument = OriginalDocument.WithText(newText);
return newDocument;
diff --git a/src/Features/Core/Portable/AddImport/CodeActions/InstallPackageAndAddImportCodeAction.cs b/src/Features/Core/Portable/AddImport/CodeActions/InstallPackageAndAddImportCodeAction.cs
index 8233587ed905adfaa3f898eb28dad52f81079b67..666244f15f664995221f4f5cfd96e72e4bfdc92c 100644
--- a/src/Features/Core/Portable/AddImport/CodeActions/InstallPackageAndAddImportCodeAction.cs
+++ b/src/Features/Core/Portable/AddImport/CodeActions/InstallPackageAndAddImportCodeAction.cs
@@ -73,8 +73,10 @@ private async Task GetUpdatedSolutionAsync(CancellationToken cancellat
protected override async Task> ComputeOperationsAsync(
CancellationToken cancellationToken)
{
+ var updatedDocument = await GetUpdatedDocumentAsync(cancellationToken).ConfigureAwait(false);
+
var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
- var newText = oldText.WithChanges(TextChanges);
+ var newText = await updatedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);
return ImmutableArray.Create(
new InstallPackageAndAddImportOperation(