public AnalysisResult Analyze(string previousAssembly, string currentAssembly, string proposedVersionNumber)
        {
            var differ = new DiffAssemblies();

            var previous = new FileQuery(previousAssembly);
            var current = new FileQuery(currentAssembly);

            var differences = differ.Execute(new List<FileQuery>
            {
                previous
            }, 
            new List<FileQuery>
            {
                current
            });

            var rule = new BreakingChangeRule();

            var breakingChange = rule.Detect(differences);

            if (breakingChange)
            {
                var semVer = SemVersion.Parse(proposedVersionNumber);

                var decidedVersionNumber = semVer.Change(semVer.Major + 1, 0, 0);

                proposedVersionNumber = decidedVersionNumber.ToString();
            }

            return new AnalysisResult
            {
                BreakingChangesDetected = breakingChange,
                VersionNumber = proposedVersionNumber
            };
        }
        public void WhenICompareTheTwoAssembliesAndValidateTheRules()
        {
            var differ = new DiffAssemblies();

            var previous = new FileQuery(ScenarioContext.Current.Get<string>("PreviousAssembly"));
            var newAssembly = new FileQuery(ScenarioContext.Current.Get<string>("NewAssembly"));

            var differences = differ.Execute(new List<FileQuery> { previous }, new List<FileQuery> { newAssembly });
            var rule = new BreakingChangeRule();

            var result = rule.Detect(differences);

            ScenarioContext.Current.Set(result, "Results");
        }
        /// <summary>
        ///     Downloads the pdbs from the symbol server.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="symbolServer">The symbol server name.</param>
        /// <param name="downloadDir">The download directory. Can be null.</param>
        /// <returns>
        ///     true if all symbols could be downloaded. False otherwise.
        /// </returns>
        public bool DownloadPdbs(FileQuery query, string symbolServer, string downloadDir)
        {
            using (var t = new Tracer(myType, "DownloadPdbs"))
            {
                var lret = SymChkExecutor.bCanStartSymChk;
                var currentFailCount = this.FailedPdbs.Count;

                var fileQueue = query.EnumerateFiles;
                var aggregator = new BlockingQueueAggregator<string>(fileQueue);

                Action<string> downLoadPdbThread = (string fileName) =>
                {
                    var pdbFileName = GetPdbNameFromBinaryName(fileName);

                    // delete old pdb to ensure that the new matching pdb is really downloaded. Symchk does not replace existing but not matching pdbs.
                    try
                    {
                        File.Delete(pdbFileName);
                    }
                    catch
                    {
                    }

                    if (!this.Executor.DownLoadPdb(fileName, symbolServer, downloadDir))
                    {
                        lock (this.FailedPdbs)
                        {
                            this.FailedPdbs.Add(Path.GetFileName(fileName));
                        }
                    }
                    else
                    {
                        lock (this.FailedPdbs)
                        {
                            this.SucceededPdbCount++;
                        }
                    }
                };

                var dispatcher = new WorkItemDispatcher<string>(this.myDownLoadThreadCount, downLoadPdbThread, "Pdb Downloader", aggregator, WorkItemOptions.AggregateExceptions);

                try
                {
                    dispatcher.Dispose();
                }
                catch (AggregateException ex)
                {
                    t.Error(ex, "Got error during pdb download");
                    lret = false;
                }

                if (this.FailedPdbs.Count > currentFailCount)
                {
                    t.Warning("The failed pdb count has increased by {0}", this.FailedPdbs.Count - currentFailCount);
                    lret = false;
                }

                return lret;
            }
        }
 public bool DownloadPdbs(FileQuery query, string symbolServer)
 {
     return this.DownloadPdbs(query, symbolServer, null);
 }