private static void OptimizeCollection(ProjectDetailRepository projectRepository, ISet <ProjectLinkObject> references)
        {
            var projectsToRemove = new HashSet <ProjectLinkObject>();
            var projectsToAdd    = new HashSet <ProjectLinkObject>();

            foreach (var reference in references)
            {
                if (reference.IsOutOfSolution)
                {
                    string name = Path.GetFileNameWithoutExtension(reference.FullPath);

                    var projects = projectRepository.GetByName(name);

                    if (projects.Count == 0)
                    {
                        // Just leave it as is
                    }
                    else if (projects.Count == 1)
                    {
                        var projectLinkObject = new ProjectLinkObject(projects.First());

                        _ = projectsToRemove.Add(reference);
                        _ = projectsToAdd.Add(projectLinkObject);
                    }
                    else
                    {
                        throw new ArgumentException(string.Format("More than one project has the same name '{0}'", name));
                    }
                }
            }

            references.ExceptWith(projectsToRemove);
            references.UnionWith(projectsToAdd);
        }
Пример #2
0
 public InvestigationLink(ProjectLinkObject parent, ProjectLinkObject project)
 {
     Parent            = parent;
     FullPath          = project.FullPath;
     Guid              = project.Id;
     IsOutOfSolution   = project.IsOutOfSolution;
     IsProjectLoadable = File.Exists(FullPath);
 }
        private static ISet <ProjectLinkObject> GetProjectReferences(string projectPath, ProjectFile projectFile)
        {
            var projectDirectory = new FileInfo(projectPath).Directory;

            var projectReferences       = projectFile.SelectNodes(@"/msb:Project/msb:ItemGroup/msb:ProjectReference");
            var projectReferenceObjects = new HashSet <ProjectLinkObject>();

            foreach (XmlElement reference in projectReferences)
            {
                string subProjectPath = Path.GetFullPath(Path.Combine(projectDirectory.FullName, reference.GetAttribute("Include")));
                var    id             = new Guid(reference.SelectSingleNode("msb:Project", projectFile.nsManager).InnerText);

                var projectLinkObject = new ProjectLinkObject(subProjectPath, id);

                _ = projectReferenceObjects.Add(projectLinkObject);
            }

            return(projectReferenceObjects);
        }
        private static ISet <ProjectLinkObject> GetRawLibrariesReferencesInNode(XmlNodeList references, ISet <string> libsToIgnore)
        {
            var projectReferenceObjects = new HashSet <ProjectLinkObject>();

            foreach (XmlElement reference in references)
            {
                var libraryNames = new HashSet <string>(reference.InnerText.Split(';').ToList());

                libraryNames.ExceptWith(libsToIgnore);
                _ = libraryNames.Remove("");

                foreach (string libraryName in libraryNames)
                {
                    var projectLinkObject = ProjectLinkObject.MakeOutOfSolutionLink(libraryName);

                    _ = projectReferenceObjects.Add(projectLinkObject);
                }
            }

            return(projectReferenceObjects);
        }
Пример #5
0
 public static InvestigationLink MakeOutOfSolution(ProjectLinkObject parent, string fullPath)
 {
     return(new InvestigationLink {
         Parent = parent, FullPath = fullPath, IsOutOfSolution = true
     });
 }