public Solution ReadSolution(VerifiedFile slnFile) { var projectLines = slnFile.ReadAllLines() .Select(line => TryParseProjectLine(line)) .Where(line => line != null) .ToArray(); var projects = projectLines.Select(line => { var file = slnFile.GetRelativeFileOrDefault(line.RelativePath); if (file != null) { return(_projectReader.ReadProject(file)); } else { return(null); } }) .Where(p => p != null) .ToArray(); var sln = new Solution(slnFile, projects, projectLines); return(sln); }
public PackagesConfig(VerifiedFile file, INugetReferenceReader nugetReader) { _packagesConfigFile = file; _xml = new DotNetXMLDoc(_packagesConfigFile); Packages = nugetReader.ExtractPackages(_xml).ToArray(); }
public Solution(VerifiedFile slnFile, Project[] projects, ProjectLine[] projectLines) { _slnFile = slnFile; Projects = projects; ProjectLines = projectLines; PackagesDirectory = slnFile.Directory.GetRelativeFolder("packages"); }
public Project(VerifiedFile csProjFile, IProjectReader projectReader) { _csProjFile = csProjFile; _xml = new DotNetXMLDoc(csProjFile); DotNetVersion = projectReader.ExtractDotNetVersion(_xml); ProjectReferences = projectReader.ExtractProjectReferences(_xml).ToArray(); FileReferences = projectReader.ExtractFileReferences(_xml).ToArray(); AssemblyName = projectReader.ExtractAssemblyName(_xml); }
public CommandOutput Execute(CommandLineArgs arg) { var output = new CommandOutput(); var slnFile = VerifiedFile.GetFileIfExisting(arg.SolutionFile); if (slnFile == null) { output.Messages.Add(new SmartStringBuilder() .AppendFatal("Unable to find solution ") .AppendHighlighted(arg.SolutionFile)); return(output); } int previousProblemCount = int.MaxValue; while (true) { var solution = _solutionReader.ReadSolution(slnFile); var problems = _problemDetector.DetectAllSolutionProblems(solution); output.DetectedProblems.Clear(); output.DetectedProblems.AddRange(problems); if (problems.Length >= previousProblemCount) { output.Messages.Add(new SmartStringBuilder() .Append("Unable to solve ") .AppendHighlighted(problems.Length) .Append(" problems")); return(output); } previousProblemCount = problems.Length; var result = problems .Select(p => _correctorService.TryCorrectProblem(p)) .FirstOrDefault(p => p.Resolution != Resolution.NoActionTaken); if (result != null && result.Resolution == Resolution.FailedToSolve) { output.Messages.Add(new SmartStringBuilder() .AppendFatal("Error trying to solve problem: ") .AppendHighlighted(result.Problem.GetType().Name)); return(output); } else if (result != null && result.Resolution == Resolution.Solved) { output.CorrectedProblems.Add(result.Problem); } } }
public DotNetXMLDoc(VerifiedFile csProjFile) { File = csProjFile; _document = new XmlDocument(); _document.Load(csProjFile.FullName); var xmlns = _document.DocumentElement.GetAttribute("xmlns"); if (!string.IsNullOrEmpty(xmlns)) { _namespaceManager = new XmlNamespaceManager(_document.NameTable); _namespaceManager.AddNamespace("tu", xmlns); } }
public CommandOutput Execute(CommandLineArgs arg) { var output = new CommandOutput(); var slnFile = VerifiedFile.GetFileIfExisting(arg.SolutionFile); if (slnFile == null) { output.Messages.Add(new SmartStringBuilder() .AppendFatal("Unable to find solution ") .AppendHighlighted(arg.SolutionFile)); return(output); } var solution = _solutionReader.ReadSolution(slnFile); var problems = _problemDetector.DetectAllSolutionProblems(solution); foreach (var problem in problems) { output.DetectedProblems.Add(problem); } return(output); }
public VerifiedFile TryVerify() { return(VerifiedFile.GetFileIfExisting(_file.FullName)); }
public Project ReadProject(VerifiedFile file) { return(new Project(file, this)); }
public Project ReadProject(VerifiedFile file) { var project = new Project(file, this); return(project); }
public SolutionGraph BuildGraph(VerifiedFile csProjFile) { return(BuildGraph(_projectReader.ReadProject(csProjFile))); }