示例#1
0
        public static AdhocWorkspace WithFakeDocument(
            this AdhocWorkspace workspace,
            string name,
            string filePath,
            string text)
        {
            if (workspace.CurrentSolution.ProjectIds.Count == 0)
            {
                workspace.WithFakeProject(
                    "FakeProject",
                    "FakeProjectAssembly");
            }

            workspace.AddDocument(DocumentInfo.Create(
                                      id:         DocumentId.CreateNewId(workspace.CurrentSolution.ProjectIds[0]),
                                      name:       name,
                                      filePath:   filePath,
                                      loader:     TextLoader.From(TextAndVersion.Create(
                                                                      version:    VersionStamp.Default,
                                                                      text:       SourceText.From(text)))));

            return(workspace);
        }