protected override async Task <IEnumerable <CodeActionOperation> > ComputeOperationsAsync(CancellationToken cancellationToken) { var service = _document.Project.Solution.Workspace.Services.GetService <IMetadataService>(); var resolvedPath = _lazyResolvedPath.Value; var reference = service.GetReference(resolvedPath, MetadataReferenceProperties.Assembly); // First add the "using/import" directive in the code. (SyntaxNode node, Document document) = await _reference.ReplaceNameNodeAsync( _node, _document, cancellationToken).ConfigureAwait(false); var newDocument = await _reference.provider.AddImportAsync( node, _reference.SearchResult.NameParts, document, _placeSystemNamespaceFirst, cancellationToken).ConfigureAwait(false); // Now add the actual assembly reference. var newProject = newDocument.Project; newProject = newProject.WithMetadataReferences( newProject.MetadataReferences.Concat(reference)); var operation = new ApplyChangesOperation(newProject.Solution); return(SpecializedCollections.SingletonEnumerable <CodeActionOperation>(operation)); }