private async Task <IEnumerable <CodeActionOperation> > CreateAddDocumentAndUpdateUsingsOrImportsOperationsAsync( Project projectToBeUpdated, Project triggeringProject, string documentName, SyntaxNode root, string includeUsingsOrImports, IList <string> containers, SourceCodeKind sourceCodeKind, CancellationToken cancellationToken) { // TODO(cyrusn): make sure documentId is unique. var documentId = DocumentId.CreateNewId(projectToBeUpdated.Id, documentName); var updatedSolution = projectToBeUpdated.Solution.AddDocument(DocumentInfo.Create( documentId, documentName, containers, sourceCodeKind)); updatedSolution = updatedSolution.WithDocumentSyntaxRoot(documentId, root, PreservationMode.PreserveIdentity); // Update the Generating Document with a using if required if (includeUsingsOrImports != null) { updatedSolution = await _service.TryAddUsingsOrImportToDocumentAsync(updatedSolution, null, _semanticDocument.Document, _state.SimpleName, includeUsingsOrImports, cancellationToken).ConfigureAwait(false); } // Add reference of the updated project to the triggering Project if they are 2 different projects updatedSolution = AddProjectReference(projectToBeUpdated, triggeringProject, updatedSolution); return(new CodeActionOperation[] { new ApplyChangesOperation(updatedSolution), new OpenDocumentOperation(documentId) }); }