예제 #1
0
 private void retrieveProjectRefs()
 {
     foreach (var project in this.Entities <VcProjectEntity>().Where(x => x.Valid))
     {
         foreach (var reference in project.Root.Items.Where(x => x.ItemType == "ProjectReference"))
         {
             var refPath    = Path.GetFullPath(Path.Combine(project.Root.DirectoryPath, reference.Include));
             var refProject = this.FindEntity <VcProjectEntity>(refPath);
             if (refProject == null)
             {
                 Context.AddDefect(new Defect_ProjectRefBroken(reference.Location, refPath));
             }
             else if (LinksFrom(project).Any(x => x.To == refProject))
             {
                 Context.AddDefect(new Defect_ProjectRefDuplicate(reference.Location, refPath));
             }
             else
             {
                 var link = new VcProjectReference {
                     From = project, To = refProject
                 };
                 var refGuidElement = reference.Metadata.FirstOrDefault(x => x.Name == "Project");
                 if (refGuidElement != null)
                 {
                     validateGuid(refGuidElement.Value, project.PathFromBase, refGuidElement.Location.Line);
                     link.Id   = refGuidElement.Value.Trim();
                     link.Line = refGuidElement.Location.Line;
                 }
                 AddLink(link);
             }
         }
     }
 }
예제 #2
0
 private void retrieveSolutionRefs()
 {
     foreach (var solution in this.Entities <SolutionEntity>().Where(x => x.Valid))
     {
         foreach (var projectInSolution in solution.Solution.ProjectsInOrder)
         {
             if (projectInSolution.ProjectType == SolutionProjectType.KnownToBeMSBuildFormat)
             {
                 var refPath = projectInSolution.AbsolutePath;
                 if (Utils.FileExtensionIs(refPath, ".vcxproj"))
                 {
                     var refProject = this.FindEntity <VcProjectEntity>(refPath);
                     if (refProject == null)
                     {
                         Context.AddDefect(new Defect_SolutiontRefBroken(solution.PathFromBase, refPath));
                     }
                     else if (LinksFrom(solution).Any(x => x.To == refProject))
                     {
                         Context.AddDefect(new Defect_SolutionRefDuplicate(solution.PathFromBase, refProject.PathFromBase));
                     }
                     else
                     {
                         validateGuid(projectInSolution.ProjectGuid, solution.PathFromBase);
                         var link = new VcProjectReference {
                             From = solution, To = refProject
                         };
                         link.Id = projectInSolution.ProjectGuid;
                         AddLink(link);
                     }
                 }
             }
         }
     }
 }