public IEnumerable <string> TryGetSourcePaths(string sourcePath) { if (!Directory.Exists(sourcePath)) { return(null); } var files = Directory.GetFiles(sourcePath); var solutionFilePath = TryGetSolutionFilePath(sourcePath, files); if (solutionFilePath != null) { return(_solutionFilePathProvider .TryGetSourcePaths(solutionFilePath)); } var projectFilePath = TryGetProjectFilePath(sourcePath, files); if (projectFilePath != null) { return(_projectFilePathProvider .TryGetSourcePaths(projectFilePath)); } return(new[] { sourcePath }); }
public IReadOnlyCollection <string> GetProjectPaths(string sourcePath) { var pathCandidates = new[] { _solutionFilePathProvider.TryGetSourcePaths(sourcePath), _projectFilePathProvider.TryGetSourcePaths(sourcePath), _projectDirectoryPathProvider.TryGetSourcePaths(sourcePath) }; var paths = pathCandidates .Where(x => x?.Any() ?? false) .Select(x => x.ToList()) .FirstOrDefault(); if (paths == null) { throw new FileNotFoundException( $"No directory or file found at path '{sourcePath}'."); } return(paths); }