Exemplo n.º 1
0
        private CheckDepsResult GetCheckDepsResult(List <ReferenceWithCsproj> csprojRefs)
        {
            var depsInstalls   = depsRefsCollector.GetRefsFromDeps();
            var noYamlInstall  = new SortedSet <string>(depsInstalls.NotFoundInstallSection);
            var inDeps         = new SortedSet <string>();
            var notUsedDeps    = new SortedSet <string>();
            var configOverhead = new SortedSet <string>();

            foreach (var installData in depsInstalls.FoundReferences)
            {
                notUsedDeps.Add(installData.ModuleName);

                foreach (var d in installData.Artifacts)
                {
                    inDeps.Add(d);
                }
                bool isOverhead = true;
                foreach (var d in installData.MainConfigBuildFiles)
                {
                    if (csprojRefs.Any(r => r.Reference.ToLower() == d.ToLower()))
                    {
                        isOverhead = false;
                    }
                }
                if (isOverhead)
                {
                    configOverhead.Add(installData.ModuleName);
                }
            }

            var lowerInDeps = inDeps.Select(r => r.ToLower()).ToList();
            var notInDeps   = csprojRefs
                              .Where(r => !lowerInDeps.Contains(r.Reference.ToLower()))
                              .Where(r => GetModuleName(r.Reference) != moduleName)
                              .ToList();

            var innerRefs = csprojRefs
                            .Where(r => GetModuleName(r.Reference) == moduleName)
                            .Where(r => !r.Reference.ToLower().Contains("\\packages\\"))
                            .ToList();
            var allInstalls = new HashSet <string>(
                InstallHelper.GetAllInstallFiles().Select(Path.GetFileName));

            notInDeps.AddRange(innerRefs.Where(i => allInstalls.Contains(Path.GetFileName(i.Reference))));

            foreach (var r in csprojRefs)
            {
                var moduleName = GetModuleName(r.Reference);
                notUsedDeps.Remove(moduleName);
            }

            DeleteMsBuild(notUsedDeps);
            DeleteMsBuild(configOverhead);
            return(new CheckDepsResult(notUsedDeps, notInDeps, noYamlInstall, configOverhead));
        }
Exemplo n.º 2
0
        private CheckDepsResult GetCheckDepsResult(List <ReferenceWithCsproj> csprojRefs)
        {
            var depsInstalls   = depsRefsCollector.GetRefsFromDeps();
            var noYamlInstall  = new SortedSet <string>(depsInstalls.NotFoundInstallSection);
            var inDeps         = new SortedSet <string>();
            var notUsedDeps    = new SortedSet <string>();
            var configOverhead = new SortedSet <string>();

            foreach (var installData in depsInstalls.FoundReferences)
            {
                notUsedDeps.Add(installData.ModuleName);

                foreach (var d in installData.Artifacts)
                {
                    inDeps.Add(d);
                }
                bool isOverhead = true;
                foreach (var d in installData.MainConfigBuildFiles)
                {
                    if (csprojRefs.Any(r => r.Reference.ToLower() == d.ToLower()))
                    {
                        isOverhead = false;
                    }
                }
                if (isOverhead)
                {
                    configOverhead.Add(installData.ModuleName);
                }
            }

            var lowerInDeps = inDeps.Select(r => r.ToLower()).ToList();
            var notInDeps   = csprojRefs.Where(r => !lowerInDeps.Contains(r.Reference.ToLower())).ToList();

            foreach (var r in csprojRefs)
            {
                var moduleName = r.Reference.Split('\\')[0];
                notUsedDeps.Remove(moduleName);
            }

            DeleteMsBuild(notUsedDeps);
            DeleteMsBuild(configOverhead);
            return(new CheckDepsResult(notUsedDeps, notInDeps, noYamlInstall, configOverhead));
        }