public DocumentId AddSubmission(DocumentId previousDocumentId, DocumentId nextDocumentId) { var project = workspace.AddProject(CreateSubmissionProjectInfo()); // AdhocWorkspace.AddDocument will add text as SourceCodeKind.Regular // not Script, so we need to do this the long way here... var documentId = DocumentId.CreateNewId(project.Id, project.Name); workspace.AddDocument(DocumentInfo.Create(documentId, project.Name, null, SourceCodeKind.Script)); workspace.OpenDocument(documentId); ConfigureSubmission(project.Id, previousDocumentId); if (nextDocumentId != null) { var nextProject = GetProject(nextDocumentId); workspace.RemoveProjectReferences(nextProject.Id); workspace.RemoveMetadataReferences(nextProject.Id); workspace.AddProjectReference(nextProject.Id, new ProjectReference(project.Id)); } return(documentId); }
public DocumentId AddSubmission(SourceText buffer, DocumentId previousDocumentId, DocumentId nextDocumentId) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } var project = workspace.AddProject(CreateSubmissionProjectInfo()); // AdhocWorkspace.AddDocument will add text as SourceCodeKind.Regular // not Script, so we need to do this the long way here... var documentId = DocumentId.CreateNewId(project.Id, project.Name); var loader = TextLoader.From(TextAndVersion.Create(buffer, VersionStamp.Create())); workspace.AddDocument(DocumentInfo.Create(documentId, project.Name, null, SourceCodeKind.Script, loader)); workspace.OpenDocument(documentId); ConfigureSubmission(project.Id, previousDocumentId); if (nextDocumentId != null) { var nextProject = GetProject(nextDocumentId); workspace.RemoveProjectReferences(nextProject.Id); workspace.RemoveMetadataReferences(nextProject.Id); workspace.AddProjectReference(nextProject.Id, new ProjectReference(project.Id)); } return(documentId); }