Пример #1
0
        // Graph Viewer: https://dreampuf.github.io/GraphvizOnline
        public async Task <int> ExecuteHandler(FileInfo solution, bool verbose, CancellationToken token)
        {
            Globals.Verbose = verbose;

            await _analyzer.LoadSolution(solution.FullName, token);

            _console.Out.VerboseWriteLine();

            var graph = _analyzer.GetGraph();

            string graphString = $"digraph G {{{Environment.NewLine}" + string.Join(Environment.NewLine, graph.Where(g => g.Item2.Any()).OrderBy(g => g.Item1.Project).Select(g => $"  \"{g.Item1.Project}\" -> {{ {string.Join(" ", g.Item2.OrderBy(i => i.Project).Select(i => $"\"{i.Project}\""))} }}")) + $"{Environment.NewLine}}}";

            _console.Out.WriteLine(graphString);

            return(0);
        }
Пример #2
0
        public async Task <int> ExecuteHandler(FileInfo solution, bool verbose, CancellationToken token)
        {
            Globals.Verbose = verbose;

            await _analyzer.LoadSolution(solution.FullName, token);

            _console.Out.VerboseWriteLine();

            var projects = _analyzer.GetTopologicallySortedProjects();

            foreach (var project in projects)
            {
                _console.Out.VerboseWrite($"{project.Distance}\t");
                _console.Out.WriteLine(project.Project);
            }

            return(0);
        }
Пример #3
0
        public async Task <int> ExecuteHandler(FileInfo solution, string fromCommit, bool verbose, bool distance, CancellationToken token, bool suppressOutput = false)
        {
            Globals.Verbose       = verbose;
            Globals.PrintDistance = distance;

            // Always process changes relative to the HEAD. Any other commit would require checking that version out to read the solution.
            string toCommit = "HEAD";

            var repositoryValidation = ValidateRepository(fromCommit, toCommit);

            if (!repositoryValidation.IsValid)
            {
                _console.Error.WriteLine(repositoryValidation.FailureReason);
            }

            // Determine which files have changed. If there aren't any changes there's no need to run a potentially expensive solution analysis.
            _console.Out.VerboseWriteLine($"Between commits {fromCommit} {toCommit}");
            _diff.ExecuteHandler(fromCommit, toCommit, suppressOutput);
            var changedFiles = _diff.Result;

            if (!changedFiles.Any())
            {
                return(0);
            }

            string changedFilesOutput = $"      modified:   {string.Join($"{Environment.NewLine}      modified:   ", changedFiles)}";

            _console.Out.VerboseWriteLine($"{changedFiles.Count} modified files found");
            _console.Out.VerboseWriteLine(changedFilesOutput);

            await _analyzer.LoadSolution(solution.FullName, token);

            _console.Out.VerboseWriteLine();
            _console.Out.VerboseWriteLine($"Loaded solution file {solution.Name}");

            var changedProjects = _analyzer.FindContainingProjects(changedFiles);

            if (!changedProjects.Any())
            {
                if (!suppressOutput || Globals.Verbose)
                {
                    _console.Out.WriteLine("0 modified projects found. No output will be written");
                }

                return(0);
            }

            var dependentProjects = _analyzer.FindDependentProjects(changedProjects);

            if (!dependentProjects.Any())
            {
                if (!suppressOutput || Globals.Verbose)
                {
                    _console.Out.WriteLine("0 dependent projects found. No output will be written");
                }

                return(0);
            }

            _console.Out.VerboseWriteLine($"{dependentProjects.Count} dependent projects found");
            _console.Out.VerboseWriteLine();

            if (!suppressOutput || Globals.Verbose)
            {
                foreach (var dependentProject in dependentProjects)
                {
                    if (Globals.PrintDistance)
                    {
                        _console.Out.Write($"{dependentProject.Distance}\t");
                    }

                    _console.Out.WriteLine(dependentProject.Assembly);
                }
            }

            Results.AddRange(dependentProjects);

            return(0);
        }