示例#1
0
    static CompareSet GetExplicitAssembliesToCompare(string[] args)
    {
        var sourceIndex = Array.FindIndex(args, arg => arg == "--source");

        if (sourceIndex < 0)
        {
            throw new ApiComparerArgumentException("No target assemblies specified, please use --source {asm1};{asm2}...");
        }

        var targetIndex = Array.FindIndex(args, arg => arg == "--target");

        if (targetIndex < 0)
        {
            throw new ApiComparerArgumentException("No target assemblies specified, please use --target {asm1};{asm2}...");
        }

        var source = args[sourceIndex + 1];

        AssemblyGroup leftAsmGroup;

        string leftVersion;

        var compareName = "Custom";

        if (source.StartsWith("nuget:"))
        {
            var nugetName = source.Replace("nuget:", "").Trim();


            compareName = nugetName;

            var feeds = GetFeedsToUse(args);

            var nugetBrowser = new NuGetBrowser(feeds);

            var version = nugetBrowser.GetAllVersions(nugetName, args.Contains("--include-prerelease")).Max();

            var nugetDownloader = new NuGetDownloader(nugetName, feeds);

            leftVersion = version.ToString();

            leftAsmGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(leftVersion));
        }
        else
        {
            leftVersion = "TBD-Left";

            leftAsmGroup = new AssemblyGroup(source.Split(';').Select(Path.GetFullPath).ToList());
        }

        return(new CompareSet
        {
            Name = compareName,
            RightAssemblyGroup = new AssemblyGroup(args[targetIndex + 1].Split(';').Select(Path.GetFullPath).ToList()),
            LeftAssemblyGroup = leftAsmGroup,
            Versions = new VersionPair(leftVersion, "TBD-Right")
        });
    }
示例#2
0
    static IEnumerable <CompareSet> GetAllPackageVersions(List <string> feeds, string package, ICompareStrategy compareStrategy)
    {
        var browser = new NuGetBrowser(feeds);

        Console.Out.Write("Loading version history for {0}", package);

        var allVersions = browser.GetAllVersions(package);

        Console.Out.WriteLine(" - done");

        var semverCompliantVersions = allVersions.Where(v => v.Version.Major > 0)
                                      .ToList();

        return(compareStrategy.GetVersionsToCompare(semverCompliantVersions)
               .Select(pair => CreateCompareSet(feeds, package, pair))
               .ToList());
    }
示例#3
0
    static IEnumerable<CompareSet> GetAllNuGetVersions(string package, ICompareStrategy compareStrategy)
    {
        var browser = new NuGetBrowser(new List<string> { "https://www.nuget.org/api/v2" });

        Console.Out.Write("Loading version history for {0}", package);

        var allVersions = browser.GetAllVersions(package);

        Console.Out.WriteLine(" - done");

        var semverCompliantVersions = allVersions.Where(v => v.Version.Major > 0)
            .ToList();

        return compareStrategy.GetVersionsToCompare(semverCompliantVersions)
            .Select(pair => CreateCompareSet(package, pair))
            .ToList();
    }
示例#4
0
    private static CompareSet GetExplicitAssembliesToCompare(string[] args)
    {
        var sourceIndex = Array.FindIndex(args, arg => arg == "--source");

        if (sourceIndex < 0)
        {
            throw new Exception("No target assemblies specified, please use --source {asm1};{asm2}...");
        }

        var targetIndex = Array.FindIndex(args, arg => arg == "--target");

        if (targetIndex < 0)
        {
            throw new Exception("No target assemblies specified, please use --target {asm1};{asm2}...");
        }

        var source = args[sourceIndex + 1];

        AssemblyGroup leftAsmGroup;

        string leftVersion;

        var compareName = "Custom";

        if (source.StartsWith("nuget:"))
        {

            var nugetName = source.Replace("nuget:", "").Trim();

            compareName = nugetName;

            var feeds = GetFeedsToUse(args);

            var nugetBrowser = new NuGetBrowser(feeds);

            var version = nugetBrowser.GetAllVersions(nugetName,args.Contains("--include-prerelease")).Max();

            var nugetDownloader = new NuGetDownloader(nugetName, feeds);

            leftVersion = version.ToString();

            leftAsmGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(leftVersion));
        }
        else
        {
            leftVersion = "TBD-Left";

            leftAsmGroup = new AssemblyGroup(source.Split(';').Select(Path.GetFullPath).ToList());
        }

        return new CompareSet
        {
            Name = compareName,
            RightAssemblyGroup = new AssemblyGroup(args[targetIndex + 1].Split(';').Select(Path.GetFullPath).ToList()),
            LeftAssemblyGroup = leftAsmGroup,
            Versions = new VersionPair(leftVersion, "TBD-Right")

        };
    }