Beispiel #1
0
 public static IEnumerable <Option <Project> > GetAllProjectsInSln(string slnPath)
 {
     using var sln = new Sln(slnPath, SlnItems.Projects);
     return(sln.Result.ProjectItems.Select(x =>
     {
         var fullPath = Path.GetFullPath(x.fullPath.Replace('\\', '/'));
         return ProjectsFactory.MapCsProj(GetProjectNameFromPath(fullPath), fullPath);
     }));
 }
Beispiel #2
0
        private static IEnumerable <Project> FindReferencesRec(IEnumerable <Project> projects, Project project)
        {
            var projectsList = projects.ToList();
            Func <string, IEnumerable <string> > getDependenciesPaths = NodeFinder.GetProjectReferencePaths;
            Func <IEnumerable <string>, IEnumerable <Option <Project> > > mapPathsToProjects = x =>
                                                                                               x.Map(y => ProjectsFactory.MapCsProj(ProjectsScanner.GetProjectNameFromPath(y), y));
            var getProjectDependencies = compose(getDependenciesPaths, mapPathsToProjects);

            var dependenciesMap = projectsList.ToDictionary(x => x, x => getProjectDependencies(x.Path));

            var referencedBy = dependenciesMap.Where(x => x.Value.Any(y => y.Match(z => z == project, false)))
                               .Select(x => x.Key).ToList();

            return(referencedBy.Any()
                ? referencedBy.ConcatFast(referencedBy.SelectMany(x => FindReferencesRec(projectsList, x))).Distinct()
                : Enumerable.Empty <Project>());
        }