public void Run(string solutionPathName, string projectFilterRegex = null) { if (String.IsNullOrWhiteSpace(solutionPathName)) { throw new ArgumentNullException("solutionPathName"); } var solutionPath = Path.GetDirectoryName(solutionPathName); var solutionName = Path.GetFileName(solutionPathName); Console.WriteLine("Running"); var reader = new ProjectReader(solutionPath, solutionName); Console.WriteLine(String.Format("Reading files for the solution {0} (path {1})", solutionName, solutionPath)); var regexProjectFilter = !String.IsNullOrWhiteSpace(projectFilterRegex) ? new Regex(projectFilterRegex, RegexOptions.IgnoreCase) : null; var model = regexProjectFilter == null?reader.Read() : reader.Read(p => regexProjectFilter.IsMatch(p.Name)); Console.WriteLine(String.Format("Loaded '{0}' project(s); '{1}' symbol(s)", model.SolutionNamespaces.Count(), model.Symbols.Count())); Console.WriteLine("Building dependency tree"); new ReferenceBuilder().Build(model); Console.WriteLine("Collecting indirect references"); var final = new DependencyAnalyzer().SelectIndirectReferences(model); Console.WriteLine("Writing a report file"); var report = new Reporter().PrintFromToEndpoints(final); Console.WriteLine(); Console.WriteLine(report); }
public void Analyze(Solution solution) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (solution.ProjectPaths == null) { return; } var projectReader = new ProjectReader(NoopLogger.Instance); foreach (var projectPath in solution.ProjectPaths) { if (!projectPath.ProjectFile.Exists) { if (this._options.Diagnostics.Contains(DiagnosticSet.W002)) { this._reporter.Report( W002MissingProjectFileDiagnostic.CreateResult(projectPath, solution), this._reporter.DefaultOptions); } continue; } var project = projectReader.Read(projectPath.ProjectFile); Analyze(project); } }
public List <Project> GetProjects( ProjectReader reader) { List <string> fileNames = GetFileNames(MIPPEN_FILE_SEARCH_TERM); List <Project> projects = new List <Project>(); DataLakeFileSystemClient fileSystemClient = serviceClient.GetFileSystemClient(fileSystemName); foreach (var fileName in fileNames) { // Get file contents DataLakeFileClient fileClient = fileSystemClient.GetFileClient(fileName); // Try to get a project Project project; using (var stream = fileClient.OpenRead()) { project = reader.Read(stream); } if (project is not null) { projects.Add(project); } } return(projects); }
static void Main(string[] args) { //Load a project ProjectReader rdr = new ProjectReader(); FileStream St = new FileStream("Project.mpp", FileMode.Open); Project prj = rdr.Read(St); St.Close(); //Link the tasks TaskLink tsklnk = new TaskLink(prj.RootTask.Children[0] as Aspose.Tasks.Task, prj.RootTask.Children[1] as Aspose.Tasks.Task, TaskLinkType.FinishToStart); prj.AddTaskLink(tsklnk); tsklnk = new TaskLink(prj.RootTask.Children[1] as Aspose.Tasks.Task, prj.RootTask.Children[2] as Aspose.Tasks.Task, TaskLinkType.FinishToStart); prj.AddTaskLink(tsklnk); tsklnk = new TaskLink(prj.RootTask.Children[2] as Aspose.Tasks.Task, prj.RootTask.Children[3] as Aspose.Tasks.Task, TaskLinkType.FinishToStart); prj.AddTaskLink(tsklnk); tsklnk = new TaskLink(prj.RootTask.Children[3] as Aspose.Tasks.Task, prj.RootTask.Children[4] as Aspose.Tasks.Task, TaskLinkType.FinishToStart); prj.AddTaskLink(tsklnk); tsklnk = new TaskLink(prj.RootTask.Children[1] as Aspose.Tasks.Task, prj.RootTask.Children[4] as Aspose.Tasks.Task, TaskLinkType.FinishToStart); prj.AddTaskLink(tsklnk); //Display links among the tasks ArrayList allinks = new ArrayList(prj.TaskLinks); foreach (TaskLink tasklnk in allinks) { Console.WriteLine("From ID = " + tasklnk.PredTask.Id + "=>To ID = " + tasklnk.SuccTask.Id); Console.WriteLine("________________________________________"); } //Save the project prj.Save("Project1.mpp", Aspose.Tasks.Saving.SaveFileFormat.MPP); }
public Project ProcessProjectFile(FileInfo file, Solution solution, ProjectReference reference = null) { if (!Validate(file, logger)) { return(null); } var project = projectReader.Read(file); if (project == null) { return(null); } if (reference?.ProjectName != null) { project.ProjectName = reference.ProjectName; } if (!project.Valid) { logger.LogWarning("Project {ProjectName} is marked as invalid, skipping...", project.ProjectName ?? project.FilePath.Name); return(null); } project.CodeFileExtension = ProjectFileMappings[file.Extension]; project.Solution = solution; foreach (var transform in conversionOptions.PreDefaultTransforms) { transform.Transform(project); } foreach (var transform in transformationSet.IterateTransformations(logger, conversionOptions)) { if (project.IsModernProject && transform is ILegacyOnlyProjectTransformation && !conversionOptions.ForceDefaultTransforms.Contains(transform.GetType().Name)) { continue; } if (!project.IsModernProject && transform is IModernOnlyProjectTransformation && !conversionOptions.ForceDefaultTransforms.Contains(transform.GetType().Name)) { continue; } transform.Transform(project); } foreach (var transform in conversionOptions.PostDefaultTransforms) { transform.Transform(project); } return(project); }
public void EnsureCanParseProjectFile() { var projectText = TestData.LoadSampleProjectText(); var projectReader = new ProjectReader(); var dependencies = projectReader.Read(projectText); Assert.AreEqual(2, dependencies.ProjectDependencyPaths.Count()); Assert.AreEqual(@"..\Home.Common\Home.Common.csproj", dependencies.ProjectDependencyPaths.ElementAt(0)); }
static void Main(string[] args) { //Load MPP file using project reader ProjectReader reader = new ProjectReader(); Project project = reader.Read("Project.mpp"); //Load all tasks ArrayList allTasks = new ArrayList(project.RootTask.Children); //Loop through each task and read information related to tasks foreach (Aspose.Tasks.Task task in allTasks) { Console.WriteLine("Reading Task " + task.Name); Console.WriteLine("\nID: " + task.Id); Console.WriteLine("Start: " + task.Start); Console.WriteLine("Finish: " + task.Finish); Console.WriteLine("\n===========================\n"); //Read any other information you need } //Loop through each resource and read information related to resources foreach (Resource resource in project.Resources) { string resourceType = null; switch (resource.Type) { case ResourceType.Material: resourceType = "Material"; break; case ResourceType.Work: resourceType = "Work"; break; default: resourceType = "Cost"; break; } Console.WriteLine("Reading Resource " + resource.Name); Console.WriteLine("\nID: " + resource.Id); Console.WriteLine("Type: " + resourceType); Console.WriteLine("\n===========================\n"); //Read any other information you need } Console.ReadLine(); }
private void ReadAsync_v0_2_NoClosingFrontMatter_ReturnsNull() { string filePath = @"Assets\ProjectFiles\v0_2_incorrect_front_matter.md"; ProjectParser parser = new ProjectParser(); ProjectReader sut = new ProjectReader(parser); Models.v0_2.Project actual; using (Stream stream = File.OpenRead(filePath)) { actual = sut.Read(stream); } Assert.Null(actual); }
private void ReadAsync_v0_2_CorrectFrontMatterWithAdditonalVariables_ReturnsNull() { string filePath = @"Assets\ProjectFiles\v0_2_correct_front_matter_additional_variables.md"; ProjectParser parser = new ProjectParser(); ProjectReader sut = new ProjectReader(parser); Models.v0_2.Project actual; using (Stream stream = File.OpenRead(filePath)) { actual = sut.Read(stream); } Assert.NotNull(actual); Assert.Equal("TestProject", actual.Name); Assert.Equal("# Heading", actual.Description); }
public List <Project> GetProjects( ProjectReader reader) { List <Google.Apis.Drive.v3.Data.File> files = GetFiles( MIPPEN_FILE_SEARCH_TERM, true, ".md"); List <Project> projects = new List <Project>(); foreach (var file in files) { string fileString; //Option 1 Project project; using (MemoryStream ms = new MemoryStream()) { var fileRequest = service.Files.Get(file.Id); fileRequest.Download(ms); fileString = Encoding.UTF8.GetString(ms.ToArray()); // Google's API threw an error when passing the stream directly to Read() (also used ExecuteAsStream()) byte[] byteArray = Encoding.UTF8.GetBytes(fileString); MemoryStream stream = new MemoryStream(byteArray); project = reader.Read(stream); } /* Option 2 ( * Project project; * var fileRequest = service.Files.Get(file.Id); * using (var stream = fileRequest.ExecuteAsStream()) * { * project = reader.Read(stream); * } */ if (project is not null) { projects.Add(project); } } return(projects); }
public void SetUp() { r1 = MockRepository.GenerateStub <IDependencyStrategy>(); r2 = MockRepository.GenerateStub <IDependencyStrategy>(); d1 = new Dependency("FubuCore", "1.0.0.215"); d2 = new Dependency("Bottles", "1.0.0.212"); var project = new Project("MyProject.csproj"); r1.Stub(x => x.Matches(project)).Return(false); r2.Stub(x => x.Matches(project)).Return(true); r2.Stub(x => x.Read(project)).Return(new[] { d1, d2 }); theReader = new ProjectReader(new[] { r1, r2 }); theProject = theReader.Read("MyProject.csproj"); }
static void Main(string[] args) { //Open project file string fileName = "Project.mpp"; ProjectReader reader = new ProjectReader(); Project project = reader.Read(fileName); // Get the critical path ArrayList criticalPath = new ArrayList(project.GetCriticalPath()); // Enumerate the tasks in the critical path foreach (Aspose.Tasks.Task task in criticalPath) { Console.WriteLine(task.Id + " " + task.Name); Console.WriteLine(task.Start); Console.WriteLine(task.Finish + "\n"); } }
private void ReadAsync_v0_2_CorrectFrontMatter_ReturnsNull() { string filePath = @"Assets\ProjectFiles\v0_2_correct_front_matter.md"; ProjectParser parser = new ProjectParser(); ProjectReader sut = new ProjectReader(parser); Models.v0_2.Project actual; using (Stream stream = File.OpenRead(filePath)) { actual = sut.Read(stream); } Assert.NotNull(actual); Assert.Equal("TestProject", actual.Name); Assert.Equal("# Heading", actual.Description); Assert.Equal(DateTime.Parse("2022-05-12T23:37:22.6390000Z"), actual.LastModified); Assert.Equal("Incomplete", actual.ProjectStatus); }
static void Main(string[] args) { ProjectReader reader = new ProjectReader(); Project project = reader.Read("Project.mpp"); Aspose.Tasks.Task task = new Aspose.Tasks.Task("Task1"); task.ActualStart = DateTime.Parse("23-Aug-2012"); //Set duration in hours task.Duration = new TimeSpan(24, 0, 0); task.DurationFormat = TimeUnitType.Day; project.RootTask.Children.Add(task); //Recalculate task IDs project.CalcTaskIds(); project.CalcTaskUids(); //Save the Project as XML project.Save("OutputProject.xml", Aspose.Tasks.Saving.SaveFileFormat.XML); }
public void Analyze(Solution solution) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (solution.ProjectPaths == null) { return; } var projectReader = new ProjectReader(NoopLogger.Instance); foreach (var projectPath in solution.ProjectPaths) { if (!projectPath.ProjectFile.Exists) { this._reporter.Report(new[] { new DiagnosticResult { Code = "W002", Message = $"Referenced project file '{projectPath.Include}' was not found at '{projectPath.ProjectFile.FullName}'.", Location = new DiagnosticLocation { Source = solution.FilePath } } }, this._reporter.DefaultOptions); continue; } var project = projectReader.Read(projectPath.ProjectFile); Analyze(project); } }
public List <Project> GetProjects( ProjectReader reader) { var files = GetFileNames(MIPPEN_FILE_SEARCH_TERM); List <Project> projects = new List <Project>(); foreach (var file in files) { Project project; using (var stream = File.OpenRead(file)) { project = reader.Read(stream); } if (project is not null) { projects.Add(project); } } return(projects); }
private async Task OnInputFileProjectChange( InputFileChangeEventArgs e) { isLoading = true; if (e.FileCount != 1) { return; } try { ProjectReader projectReader = new ProjectReader( new ProjectParser()); // TODO: Figure out how to pass e.File.OpenReadStream() to projectReader without it failing string fileString; using (var sr = new StreamReader(e.File.OpenReadStream(), Encoding.UTF8)) { fileString = await sr.ReadToEndAsync(); } var project = projectReader.Read(fileString); State.UpdateProjectEdit(this, project); //await ProjectChanged.InvokeAsync(this.Project); } catch { // TODO: Indicate error state } finally { isLoading = false; await InvokeAsync(StateHasChanged); } }
public List <Project> GetProjects( ProjectReader reader) { List <Project> projects = new List <Project>(); try { var remaining = new Queue <ShareDirectoryClient>(); remaining.Enqueue(shareClient.GetDirectoryClient(this.path)); while (remaining.Count > 0) { ShareDirectoryClient dir = remaining.Dequeue(); foreach (ShareFileItem item in dir.GetFilesAndDirectories()) { if (item.IsDirectory) { remaining.Enqueue(dir.GetSubdirectoryClient(item.Name)); } else if (item.Name.Contains(MIPPEN_FILE_SEARCH_TERM)) { Console.WriteLine($" In {dir.Uri.AbsolutePath} found {item.Name}"); ShareFileClient file = dir.GetFileClient(item.Name); ShareFileDownloadInfo fileContents = file.Download(); Project project; using (var stream = fileContents.Content) { project = reader.Read(stream); } if (project is not null) { projects.Add(project); } //string fileString; //using (MemoryStream ms = new MemoryStream()) //{ // fileContents.Content.CopyTo(ms); // fileString = Encoding.UTF8.GetString(ms.ToArray()); //} // //Project project = new Project() //{ // Name = file.Name.Replace(MIPPEN_FILE_EXTENSION, ""), // Description = fileString //}; } } } Console.WriteLine($"Found a total of {projects.Count} files"); } catch (Exception e) { Console.WriteLine($"An error ocurred: {e}"); } return(projects); }