private Document AddDocumentToProject(string filePath, string language, string projectName) { var project = CurrentSolution.Projects.FirstOrDefault( p => p.Name == projectName && p.Language == language ); if (project == null) { var projectInfo = ProjectInfo.Create( ProjectId.CreateNewId(), VersionStamp.Create(), projectName, projectName, language ); OnProjectAdded(projectInfo); project = CurrentSolution.GetRequiredProject(projectInfo.Id); } var docInfo = DocumentInfo.Create( DocumentId.CreateNewId(project.Id), name: Path.GetFileName(filePath), loader: new FileTextLoader(filePath, null), filePath: filePath ); OnDocumentAdded(docInfo); return(CurrentSolution.GetDocument(docInfo.Id) !); }