private Solution(string filename, string text) { _filename = filename; var items = text.SplitOnNewLine(); var reader = new SolutionReader(this); items.Each(reader.Read); }
public void ReadSolution() { if (IsDisposed) { return; } SkipWhitespace(); string line = Reader.ReadLine(); // Check if (line == Header) { while (Reader.Peek() != -1) { SkipToNextToken(); line = Reader.ReadLine(); List <string> tokens = new List <string>(); using (var reader = new SolutionReader(new StringReader(line.Trim()))) { string token = reader.ReadToken(); while (token != null) { tokens.Add(token); reader.SkipToNextToken(); token = reader.ReadToken(); } } } } }
private void sourceAddFromSol_Click(object sender, EventArgs e) { if (BuildingFileTB.Text != "") { FileInfo info = new FileInfo(BuildingFileTB.Text); if (info.Exists) { SolutionReader sol = new SolutionReader(); sol.Open(info.FullName); List <string> files = sol.GetAbsolutePaths(); if (files.Count > 0) { foreach (string file in files) { currentTool.SourceFiles.Add(new Deployable(file)); } (SourcesGridView.DataSource as BindingSource).ResetBindings(false); } } else { Logger.Log(info.FullName + " does not exists !", LogSeverities.Error); } } else { Logger.Log("Please fill the Building file field to load files from solution !", LogSeverities.Error); } }
public void Setup() { _ioSubstitute = Substitute.For <ISystemIO>(); _solutionFileParserSubstitute = Substitute.For <ISolutionFileParser>(); _solutionFactorySubstitute = Substitute.For <ISolutionFactory>(); _reader = new SolutionReader(_ioSubstitute, _solutionFactorySubstitute, _solutionFileParserSubstitute); }
/// <summary> /// Initialises a new instance of the <see cref="UpdateSolutionHandler"/> class. /// </summary> public UpdateSolutionSummaryExecutor(SolutionReader solutionReader, SolutionSummaryUpdater solutionSummaryUpdater, IMapper mapper) { _solutionReader = solutionReader; _solutionSummaryUpdater = solutionSummaryUpdater; _mapper = mapper; }
public UpdateSolutionFeaturesExecutor( SolutionReader solutionReader, SolutionFeaturesUpdater solutionFeaturesUpdater, IMapper mapper) { this.solutionReader = solutionReader; this.solutionFeaturesUpdater = solutionFeaturesUpdater; this.mapper = mapper; }
public UpdateSolutionSummaryExecutor( SolutionReader solutionReader, SolutionSummaryUpdater solutionSummaryUpdater, IMapper mapper) { this.solutionReader = solutionReader; this.solutionSummaryUpdater = solutionSummaryUpdater; this.mapper = mapper; }
public void CanReadNumberOfProjectsInSolution(string relativeSlnPath, int expectedProjects) { var slnPath = TestPaths.GetVerifiedFileRelativeToProjectDir(relativeSlnPath); var service = new SolutionReader(new EmptyProjectReader()); var sln = service.ReadSolution(slnPath); Assert.AreEqual(expectedProjects, sln.Projects.Length); }
public void Should_read_projects() { var projects = new SolutionReader(Path.Combine("TestResources", "VSSolutionFile.sln")).ReadProjects(); Assert.That(projects.Count, Is.EqualTo(3)); Assert.That(projects[0].File, Is.EqualTo(Path.GetFullPath(Path.Combine(Path.Combine("TestResources", "OpenIDE"), "OpenIDE.csproj")))); Assert.That(projects[1].File, Is.EqualTo(Path.GetFullPath(Path.Combine(Path.Combine("TestResources", "OpenIDE.Tests"), "OpenIDE.Tests.csproj")))); Assert.That(projects[2].File, Is.EqualTo(Path.GetFullPath(Path.Combine(Path.Combine("TestResources", "oi"), "oi.csproj")))); }
public void EnsureCanParseSolutionFile() { var slnText = TestData.LoadSampleSolutionText(); var solutionReader = new SolutionReader(); var projects = solutionReader.ReadText(slnText); Assert.AreEqual(5, projects.Count()); }
private static void Export(string solutionPath, string translationsXlsx) { Console.WriteLine("Reading solution resources..."); var resourceList = new SolutionReader().GetSolutionResources(solutionPath); Console.WriteLine($"Exporting to xlsx file: {Path.GetFileName(translationsXlsx)}"); var excelWriter = new ExcelWriter(); excelWriter.WriteXlsx(translationsXlsx, resourceList); }
public void EnsureParserCanConvertProject() { // Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Home.Data", "Home.Data\Home.Data.csproj", "{5FA136EB-B352-4087-B5C1-A93B3EFD853D}" var testProject = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Home.Data\", \"Home.Data\\Home.Data.csproj\", \"{5FA136EB-B352-4087-B5C1-A93B3EFD853D}\""; var solutionReader = new SolutionReader(); var project = solutionReader.ConvertToProject(testProject); Assert.AreEqual("Home.Data\\Home.Data.csproj", project.SolutionRelativePath); Assert.AreEqual("Home.Data", project.Name); Assert.AreEqual("5FA136EB-B352-4087-B5C1-A93B3EFD853D", project.Id.ToString().ToUpper()); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Use C# solution full file path as first parameter"); } string solutionFilePath = args[0]; var graph = SolutionReader.Parse(solutionFilePath); DotLangGraphRenderer.Render(graph); }
public void CanIdentifyMissingProjectFiles(string relativeSlnPath, string missingProjectName) { var slnPath = TestPaths.GetVerifiedFileRelativeToProjectDir(relativeSlnPath); var service = new SolutionReader(new EmptyProjectReader()); var sln = service.ReadSolution(slnPath); var missingProjectDetector = new MissingProjectDetector(); var problem = missingProjectDetector.DetectProblems(sln).FirstOrDefault() as MissingProject; Assert.AreEqual(missingProjectName, problem.Project.Name); }
public static void Main(string[] args) { PrintGreeting(); if (args.Length == 0) { PrintUsage(); Environment.Exit(0); } string slnFile = Path.GetFullPath(args[0]); if (!File.Exists(slnFile)) { Console.WriteLine("Specified parameter is expected to be an existing Visual Studio solution file."); Console.WriteLine("Parameter: {0}", args[0]); Environment.Exit(-1); } Console.WriteLine("Analyzing solution {0}", slnFile); Console.WriteLine(); ISolution solution = SolutionReader.Read(slnFile); List <IIssue> issues = new List <IIssue>(); foreach (IRule rule in RulesRepository.GetAllRules()) { issues.AddRange(rule.Apply(solution)); } if (issues.Count == 0) { Console.WriteLine("No issues were found."); } else { string lastFile = null; foreach (IIssue issue in issues.OrderBy(x => x.File)) { if (lastFile != issue.File) { Console.WriteLine("File: {0}", issue.File); lastFile = issue.File; } Console.WriteLine("[{0}] {1}", issue.Code, issue.Text); } Environment.ExitCode = -1; } }
public void EnsureParserCanPullOutAllProjectRows() { var slnText = TestData.LoadSampleSolutionText(); var solutionReader = new SolutionReader(); var projects = solutionReader.ParseOutProjects(slnText); Assert.AreEqual(5, projects.Count()); foreach (var project in projects) { Assert.IsTrue(project.StartsWith("Project")); } }
public void ReadsSolutionFileSuccessfully() { var testFile = @"TestFiles/Solutions/sampleSolution.testsln"; var logger = new DummyLogger { MinimumLogLevel = LogLevel.Warning }; var reader = new SolutionReader(); reader.Read(testFile, logger); //Should be no warnings or errors Assert.IsFalse(logger.LogEntries.Any()); }
private static void Merge(string solutionPath, string translationsXlsx) { Console.WriteLine("Reading solution resources..."); var solutionResources = new SolutionReader().GetSolutionResources(solutionPath); Console.WriteLine("Reading xlsx resources..."); var excelReader = ExcelReader.CreateReader(translationsXlsx); var xlsxResources = excelReader.ReadXlsx(); Console.WriteLine("Merging resources..."); var resources = new ResourceMerger().MergeResources(solutionResources, xlsxResources); Console.WriteLine($"Writing resources to file: {Path.GetFileName(translationsXlsx)}"); var excelWriter = new ExcelWriter(); excelWriter.WriteXlsx(translationsXlsx, resources); }
public void Execute([NotNull] string solutionFile, [NotNull] string basePath) { if (solutionFile.IsAssigned()) { _solutionReader = new SolutionReader(Path.Combine(basePath, solutionFile)); _solutionReader.Execute(); } _projectReader = new ProjectReader(basePath); var projectNames = _solutionReader.IsAssigned() ? _solutionReader.GetFullProjectNames() : _projectReader.GetFullProjectNames(); _projectReader .Execute(projectNames) .ExtendProjectsWithSolutionProjects(_solutionReader?.Solution?.SolutionProjects) .ExtendProjectsWithBinaryReferences(); if (!_projectReader.SdkProjects.Any(x => x.BinaryReferencedProjects.Any())) { "All clear.".WriteLine(); return; } if (solutionFile.IsAssigned()) { $"Projects referencing other projects as a binary file in solution '{solutionFile}':".WriteLine(); } else { "Projects referencing other projects as a binary file:".WriteLine(); } foreach (var sdkProject in _projectReader.SdkProjects) { foreach (var binaryReferencedProject in sdkProject.BinaryReferencedProjects) { $"\tproject = {sdkProject.FileName}".WriteLine(); $"\t\treference = {binaryReferencedProject.AssemblyName}.dll".WriteLine(); } } }
private void buttonSolutionFile_Click(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Solution files (*.sln)|*.sln"; if (dialog.ShowDialog() == DialogResult.OK) { this.textSolutionFile.Text = dialog.FileName; if (File.Exists(this.textSolutionFile.Text)) { SolutionReader reader = new SolutionReader(); var solution = reader.Read(this.textSolutionFile.Text); if (solution.FileVersion == SolutionFileVersion.VisualStudio2008) { this.radioVersion2008.Checked = true; } else if (solution.FileVersion == SolutionFileVersion.VisualStudio2010) { this.radioVersion2010.Checked = true; } else if (solution.FileVersion == SolutionFileVersion.VisualStudio2012) { this.radioVersion2012.Checked = true; } string settingsPath = Path.ChangeExtension(this.textSolutionFile.Text, SolutionOptions.FileExtension); if (File.Exists(settingsPath)) { var options = LoadSettings(settingsPath); AssignOptionsToControls(options); this.checkSaveSettings.Checked = true; } } } ValidateControls(); }
public void Execute([NotNull] string solutionFile, [NotNull] string basePath) { if (solutionFile.IsAssigned()) { _solutionReader = new SolutionReader(Path.Combine(basePath, solutionFile)); _solutionReader.Execute(); } _projectReader = new ProjectReader(basePath); var projectNames = _solutionReader.IsAssigned() ? _solutionReader.GetFullProjectNames() : _projectReader.GetFullProjectNames(); _projectReader .Execute(projectNames) .ExtendProjectsWithProjectReferences() .ExtendProjectsWithAllSubProjectReferences() .ExtendProjectsWithAllRedundantProjectReferences(); var projectsWithRedundantReferences = _projectReader .SdkProjects .Where(x => x.RedundantReferencedProjects.Any()) .ToList(); var tab = new string(' ', 4); if (!projectsWithRedundantReferences.Any()) { "No redundant project references found.".WriteLine(); return; } using var sw = new StreamWriter(@".\redundant.txt"); if (solutionFile.IsAssigned()) { $"Redundant project references in solution '{solutionFile}':".WriteLine(); } else { "Redundant project references:".WriteLine(); } foreach (var projectWithRedundantReferences in projectsWithRedundantReferences) { var line = $@"{projectWithRedundantReferences.FileName.TrimStartIgnoreCase(basePath)}".WriteLine(); sw.WriteLine(line); foreach (var redundantReferencedProject in projectWithRedundantReferences.RedundantReferencedProjects) { line = $@"{tab} - {redundantReferencedProject.FileName.TrimStartIgnoreCase(basePath)}".WriteLine(); sw.WriteLine(line); } } "See => 'redundant.txt'".WriteLine(); }
public void When_file_does_not_exist_it_should_return_empty_list() { var projects = new SolutionReader("NonExisting.sln").ReadProjects(); Assert.That(projects.Count, Is.EqualTo(0)); }
/// <summary> /// Initialises a new instance of the <see cref="UpdateSolutionHandler"/> class. /// </summary> public UpdateSolutionFeaturesExecutor(SolutionReader solutionReader, SolutionFeaturesUpdater solutionFeaturesUpdater, IMapper mapper) { _solutionReader = solutionReader; _solutionFeaturesUpdater = solutionFeaturesUpdater; _mapper = mapper; }
public SubmitSolutionForReviewHandler(SolutionReader solutionReader, ISolutionRepository solutionRepository) { this.solutionReader = solutionReader; this.solutionRepository = solutionRepository; }
public GetSolutionByIdHandler(SolutionReader solutionReader, IMapper mapper) { this.solutionReader = solutionReader; this.mapper = mapper ?? throw new System.ArgumentNullException(nameof(mapper)); }