private void CountLines(Solution solution, CodeMetricsOptions options, CancellationToken cancellationToken) { WriteLine($"Count logical lines for solution '{solution.FilePath}'", ConsoleColor.Cyan, Verbosity.Minimal); IEnumerable <Project> projects = FilterProjects(solution, Options); Stopwatch stopwatch = Stopwatch.StartNew(); ImmutableDictionary <ProjectId, CodeMetricsInfo> codeMetrics = WorkspaceCodeMetrics.CountLinesInParallel(projects, CodeMetricsCounterFactory.GetLogicalLinesCounter, options, cancellationToken); stopwatch.Stop(); if (codeMetrics.Count > 0) { WriteLine(Verbosity.Normal); WriteLine("Logical lines of code by project:", Verbosity.Normal); WriteLinesOfCode(solution, codeMetrics); } WriteLine(Verbosity.Minimal); WriteMetrics( codeMetrics.Sum(f => f.Value.CodeLineCount), codeMetrics.Sum(f => f.Value.WhitespaceLineCount), codeMetrics.Sum(f => f.Value.CommentLineCount), codeMetrics.Sum(f => f.Value.PreprocessorDirectiveLineCount), codeMetrics.Sum(f => f.Value.TotalLineCount)); WriteLine(Verbosity.Minimal); WriteLine($"Done counting logical lines for solution '{solution.FilePath}' in {stopwatch.Elapsed:mm\\:ss\\.ff}", Verbosity.Normal); }
private static async Task CountLinesAsync(Project project, CodeMetricsCounter counter, CodeMetricsOptions options, CancellationToken cancellationToken) { WriteLine($"Count logical lines for '{project.Name}'", ConsoleColor.Cyan, Verbosity.Minimal); Stopwatch stopwatch = Stopwatch.StartNew(); CodeMetricsInfo codeMetrics = await WorkspaceCodeMetrics.CountLinesAsync(project, counter, options, cancellationToken); stopwatch.Stop(); WriteLine(Verbosity.Minimal); WriteMetrics( codeMetrics.CodeLineCount, codeMetrics.WhitespaceLineCount, codeMetrics.CommentLineCount, codeMetrics.PreprocessorDirectiveLineCount, codeMetrics.TotalLineCount); WriteLine(Verbosity.Minimal); WriteLine($"Done counting logical lines for '{project.FilePath}' in {stopwatch.Elapsed:mm\\:ss\\.ff}", Verbosity.Normal); }