Ejemplo n.º 1
0
 /// <summary>
 /// Get any regex entries that match no packages.  Such entries are stale.
 /// </summary>
 internal static List<Regex> GetStaleRegex(GenerateData generateData, RepoData repoData)
 {
     return generateData
         .Packages
         .Where(r => repoData.FloatingPackages.All(p => !r.IsMatch(p.Name)))
         .ToList();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the subset of packages which match the specified filter for the generated file.
 /// </summary>
 internal static List<NuGetPackage> GetFilteredPackages(GenerateData generateData, RepoData repoData)
 {
     // Fixed packages are never included in generated output.  Doing so would create conflicts because it's
     // possible for two versions to exist for the same package.  Take for example System.Collections.Immuatble
     // which is both fixed and floating in Roslyn.
     return repoData
         .FloatingPackages
         .Where(x => generateData.Packages.Any(y => y.IsMatch(x.Name)))
         .ToList();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the subset of packages which match the specified filter for the generated file.
 /// </summary>
 internal static List<NuGetPackage> GetFilteredPackages(GenerateData generateData, RepoData repoData)
 {
     // Only fixed packages with 'generate names' are included in generated output. Doing
     // otherwise would create conflicts because it's possible for two versions to exist
     // for the same package.  Take for example System.Collections.Immuatble which is both
     // fixed and floating in Roslyn.
     var fixedWithGenerate = repoData
         .FixedPackages
         .Where(x => x.GenerateNameOpt != null);
     return repoData
         .FloatingPackages
         .Concat(fixedWithGenerate)
         .OrderBy(x => x.Name)
         .Where(x => generateData.Packages.Any(y => y.IsMatch(x.Name)))
         .ToList();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Verify the packages listed in project.json are well formed.  Packages should all either have the same version or 
        /// be explicitly fixed in the config file.
        /// </summary>
        private bool VerifyProjectJsonContents(TextWriter writer, out RepoData repoData)
        {
            writer.WriteLine($"Verifying project.json contents");

            List<NuGetPackageConflict> conflicts;
            repoData = RepoData.Create(_repoConfig, _sourcesPath, out conflicts);
            if (conflicts?.Count > 0)
            { 
                foreach (var conflict in conflicts)
                {
                    writer.WriteLine($"Error! Package {conflict.PackageName} has different versions:");
                    writer.WriteLine($"\t{conflict.Original.FileName} at {conflict.Original.NuGetPackage.Version}");
                    writer.WriteLine($"\t{conflict.Conflict.FileName} at {conflict.Conflict.NuGetPackage.Version}");
                    writer.WriteLine($"The versions must be the same or one must be explicitly listed as fixed in RepoData.json");
                }

                return false;
            }

            return true;
        }
Ejemplo n.º 5
0
        private bool VerifyGeneratedFiles(TextWriter writer, RepoData repoData)
        {
            var allGood = true;
            writer.WriteLine($"Verifying generated files");
            if (_repoConfig.MSBuildGenerateData.HasValue)
            {
                var data = _repoConfig.MSBuildGenerateData.Value;
                var packages = GenerateUtil.GetFilteredPackages(data, repoData);

                // Need to verify the contents of the generated file are correct.
                var fileName = new FileName(_sourcesPath, data.RelativeFilePath);
                var actualContent = File.ReadAllText(fileName.FullPath, GenerateUtil.Encoding);
                var expectedContent = GenerateUtil.GenerateMSBuildContent(packages);
                if (actualContent != expectedContent)
                {
                    writer.WriteLine($"{fileName.RelativePath} does not have the expected contents");
                    allGood = false;
                }

                if (!allGood)
                {
                    writer.WriteLine($@"Generated contents out of date. Run ""RepoUtil.change"" to correct");
                    return false;
                }

                // Verify none of the regex entries are stale.
                var staleRegexList = GenerateUtil.GetStaleRegex(data, repoData);
                foreach (var regex in staleRegexList)
                {
                    writer.WriteLine($"Regex {regex} matches no packages");
                    allGood = false;
                }
            }

            return allGood;
        }
Ejemplo n.º 6
0
        private static bool TryParseCommand(string[] args, ref int index, out CreateCommand func)
        {
            func = null;

            if (index >= args.Length)
            {
                Console.WriteLine("Need a command to run");
                return false;
            }

            var name = args[index];
            switch (name)
            {
                case "verify":
                    func = (c, s) => new VerifyCommand(c, s);
                    break;
                case "view":
                    func = (c, s) => new ViewCommand(c, s);
                    break;
                case "consumes":
                    func = (c, s) => new ConsumesCommand(RepoData.Create(c, s));
                    break;
                case "change":
                    func = (c, s) => new ChangeCommand(RepoData.Create(c, s));
                    break;
                case "produces":
                    func = (c, s) => new ProducesCommand(c, s);
                    break;
                default:
                    Console.Write($"Command {name} is not recognized");
                    return false;
            }

            index++;
            return true;
        }
Ejemplo n.º 7
0
 internal ChangeCommand(RepoData repoData)
 {
     _repoData = repoData;
 }
Ejemplo n.º 8
0
 internal ChangeCommand(RepoData repoData, string generateDir)
 {
     _repoData          = repoData;
     _generateDirectory = generateDir;
 }
Ejemplo n.º 9
0
 internal ChangeCommand(RepoData repoData)
 {
     _repoData = repoData;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Get the subset of packages which match the specified filter for the generated file.
 /// </summary>
 internal static List <NuGetPackage> GetFilteredPackages(GenerateData generateData, RepoData repoData)
 {
     // Fixed packages are never included in generated output.  Doing so would create conflicts because it's
     // possible for two versions to exist for the same package.  Take for example System.Collections.Immuatble
     // which is both fixed and floating in Roslyn.
     return(repoData
            .FloatingPackages
            .Where(x => generateData.Packages.Any(y => y.IsMatch(x.Name)))
            .ToList());
 }
Ejemplo n.º 11
0
 internal ConsumesCommand(RepoData repoData)
 {
     _repoData = repoData;
 }
Ejemplo n.º 12
0
 internal ConsumesCommand(RepoData repoData)
 {
     _repoData = repoData;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Get the subset of packages which match the specified filter for the generated file.
        /// </summary>
        internal static List <NuGetPackage> GetFilteredPackages(GenerateData generateData, RepoData repoData)
        {
            // Only fixed packages with 'generate names' are included in generated output. Doing
            // otherwise would create conflicts because it's possible for two versions to exist
            // for the same package.  Take for example System.Collections.Immuatble which is both
            // fixed and floating in Roslyn.
            var fixedWithGenerate = repoData
                                    .FixedPackages
                                    .Where(x => x.GenerateNameOpt != null);

            return(repoData
                   .FloatingPackages
                   .Concat(fixedWithGenerate)
                   .OrderBy(x => x.Name)
                   .Where(x => generateData.Packages.Any(y => y.IsMatch(x.Name)))
                   .ToList());
        }
Ejemplo n.º 14
0
 internal ChangeCommand(RepoData repoData, string generateDir)
 {
     _repoData = repoData;
     _generateDirectory = generateDir;
 }