Esempio n. 1
0
        private static List <string> GetUsedCementConfigsForProject(string modulePath, string csprojFile)
        {
            var projectPath = Path.GetFullPath(csprojFile);
            var moduleYaml  = Path.Combine(modulePath, Helper.YamlSpecFile);

            if (!File.Exists(moduleYaml))
            {
                return(new List <string>());
            }

            var configurations = new ConfigurationParser(new FileInfo(modulePath)).GetConfigurations();
            var result         = new HashSet <string>();

            foreach (var config in configurations)
            {
                var buildData = new BuildYamlParser(new FileInfo(modulePath)).Get(config);
                foreach (var data in buildData)
                {
                    if (data.Target.IsFakeTarget())
                    {
                        continue;
                    }
                    var slnPath        = Path.Combine(modulePath, data.Target);
                    var solutionParser = new VisualStudioProjectParser(slnPath, new List <string>());
                    var currentConfigs =
                        solutionParser.GetSolutionConfigsByCsproj(projectPath);
                    if (currentConfigs.Contains(data.Configuration))
                    {
                        result.Add(config);
                    }
                }
            }
            return(result.ToList());
        }
Esempio n. 2
0
        public void EnsureEquivalentBuildSections(string path)
        {
            var text            = pathToContentMap[path];
            var parser          = ModuleYamlParserFactory.Get();
            var buildYamlParser = new BuildYamlParser("fake", text);

            var md      = parser.Parse(text);
            var configs = md.AllConfigurations.Keys.ToArray();

            foreach (var config in configs)
            {
                var newBuild = md[config].Builds;
                var oldBuild = buildYamlParser.Get(config);

                var oldBuildIsActuallyEmpty = oldBuild.Count == 1 &&
                                              oldBuild[0].Configuration == null &&
                                              oldBuild[0].Name == string.Empty &&
                                              oldBuild[0].Target == string.Empty &&
                                              oldBuild[0].Parameters.Count == 0;

                if (newBuild != null && !oldBuildIsActuallyEmpty)
                {
                    newBuild.Should().BeEquivalentTo(oldBuild);
                }
            }
        }
Esempio n. 3
0
        private static List <string> GetUsedCementConfigsForSolution(string modulePath, string solutionFile)
        {
            var moduleYaml = Path.Combine(modulePath, Helper.YamlSpecFile);

            if (!File.Exists(moduleYaml))
            {
                return(new List <string>());
            }

            var configurations = new ConfigurationParser(new FileInfo(modulePath)).GetConfigurations();
            var result         = new HashSet <string>();

            foreach (var config in configurations)
            {
                var buildData = new BuildYamlParser(new FileInfo(modulePath)).Get(config);
                foreach (var data in buildData)
                {
                    if (data.Target.IsFakeTarget())
                    {
                        continue;
                    }
                    var dataTargetPath = Path.Combine(modulePath, data.Target);
                    if (dataTargetPath == solutionFile)
                    {
                        result.Add(config);
                    }
                }
            }
            return(result.ToList());
        }
Esempio n. 4
0
        public void OldYamlParsersDoNotThrow(string path)
        {
            var text = pathToContentMap[path];

            var depsSectionParser    = new DepsYamlParser("fake", text);
            var installSectionParser = new InstallYamlParser("fake", text);
            var buildSectionParser   = new BuildYamlParser("fake", text);

            var configs = depsSectionParser.GetConfigurations();

            foreach (var config in configs)
            {
                Assert.DoesNotThrow(() =>
                {
                    depsSectionParser.Get(config);
                    installSectionParser.Get(config);
                    buildSectionParser.Get(config);
                });
            }
        }