public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; IProject project; if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project)) { return; } Debug.Assert(project != null); var analysisResult = ProjectAnalysisUtils.RunAnalysisShowProgressOnConsole(project); Console.WriteLine("Begin Compute and Store Trend Metrics Values"); // LogTrendMetrics() is an extension method declared by NDepend.Analysis.ExtensionMethodsProjectAnalysis // Two overloads are available: // void LogTrendMetrics(this IAnalysisResult analysisResult, DateTime logDateTime) // void LogTrendMetrics(this IAnalysisResult analysisResult, ICompareContext compareContext, DateTime logDateTime) analysisResult.LogTrendMetrics(DateTime.Now); // <- Here any past or future date can be used! Console.WriteLine("End Compute and Store Trend Metrics Values"); // // Also, from trendStore, any metric value can be persisted, with any date. // //var trendStore = project.Trend.TrendStoreDirectory.GetTrendStoreFromDirectory(); //trendStore.SaveMetricValues(DateTime.Now, new [] { // new MetricValue(new Metric("Metric1", "Unit1"), 1.0f), // new MetricValue(new Metric("Metric2", "Unit2"), 2.0f), //}); // // The method RemoveMetricValues() can also be used to remove all metric values logged at a certain date. // The date equality is defined by the same dated second, no matter the number of miliseconds. //trendStore.RemoveMetricValues(DateTime.Now); }
public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; IProject project; if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project)) { return; } // Get the trend store object var trendStore = project.Trend.TrendStoreDirectory.GetTrendStoreFromDirectory(); var years = trendStore.GetYearsContainingValuesDescending(); if (!years.Any()) { Console.WriteLine("No trend values stored for the project {" + project.Properties.Name + "}."); return; } var lastYear = years.Last(); var yearsStringBuilder = new StringBuilder(); foreach (var year in years) { yearsStringBuilder.Append(year.ToString()); if (lastYear != year) { yearsStringBuilder.Append(", "); } } Console.WriteLine("The project {" + project.Properties.Name + "} has trend values stored for years " + yearsStringBuilder.ToString()); // Load all values in one call var historyData = trendStore.Load(years); var metricHistory = historyData.MetricsHistories.First().Value; // Only list the trend values for the first metric Console.WriteLine("Trend values for the metric {" + metricHistory.Metric.Name + "}"); var unit = metricHistory.Metric.Unit; foreach (var datedValue in metricHistory.DatedValuesDescending) { Console.WriteLine(datedValue.Date.ToString() + " " + datedValue.Value.ToString() + " " + unit); } }
public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; IProject project; if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project)) { return; } // Fetch analysis results reference for the choosen project var analysisResultRefs = project.GetAvailableAnalysisResultsRefs(); // Need at least 2 analysis results if (analysisResultRefs.Count < 2) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Cannot find at least 2 historic analysis results for the project {" + project.Properties.Name + "}"); return; } bool showAll = false; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; // Sort by analysis date ascending analysisResultRefs = analysisResultRefs.OrderBy(analysisResultRef => analysisResultRef.Date).ToReadOnlyClonedList(); // TODO --> use .NET 4 System.Windows.Forms.DataVisualization.dll (if available), to plot chart?? // // For each analysisResultRef found for this project // foreach (var analysisResultRef in analysisResultRefs) { var analysisResult = ProjectAnalysisUtils.LoadAnalysisShowProgressOnConsole(analysisResultRef); Console.WriteLine(); Console.WriteLine("Analysis result produced on " + analysisResultRef.Date); // // -->If you wish to follow the evolution of a particular code element (a type for example) // just retrieve the IType in each code base by type.FullName // var type = codeBase.Types.WithFullName("Namespace.TypeName"). // // You can also build a ICompareContext for each 2 consecutive analysis result loaded. // analysisResultNext.CodeBase.CreateCompareContextWithOlder(analysisResultPrevious.CodeBase) // and use the methods // ICompareContext.OlderVersion(ICodeElement):ICodeElement // ICompareContext.NewerVersion(ICodeElement):ICodeElement // to retrieve the newer versions of the particular code element, from its older version. ProjectAnalysisUtils.ShowConsoleAnalysisResult(analysisResult.CodeBase); // Ask all/next/quit? if (showAll) { continue; } switch (ConsoleUtils.ConsoleAskShowNextAllStop()) { case AllNextQuit.Next: continue; case AllNextQuit.All: showAll = true; continue; default: // Quit return; } } }
internal static IProject ChooseProject() { var projectManager = new NDependServicesProvider().ProjectManager; var visualStudioManager = new NDependServicesProvider().VisualStudioManager; var top = Console.CursorTop; Console.CursorLeft = 0; while (true) { Console.WriteLine("Please choose..."); Console.WriteLine(" a) an existing CppDepend project"); Console.WriteLine(" b) one or several Visual Studio solutions to analyze"); Console.WriteLine(" c) one or several C/C++ projects to analyze"); Console.WriteLine(""); var c = Char.ToLower(Console.ReadKey().KeyChar); Console.WriteLine(); IProject project = null; switch (c) { case 'a': if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project)) { break; } break; case 'b': { ICollection <IAbsoluteFilePath> solutions; if (!visualStudioManager.ShowDialogSelectVisualStudioSolutionsOrProjects(ConsoleUtils.MainWindowHandle, out solutions)) { break; } var projects = new List <IAbsoluteFilePath>(); foreach (var solution in solutions) { projects.Add(solution); } project = projectManager.CreateTemporaryProject(projects, TemporaryProjectMode.Temporary); break; } default: { ICollection <IAbsoluteFilePath> projects; if (!projectManager.ShowDialogSelectProjects(ConsoleUtils.MainWindowHandle, out projects)) { break; } project = projectManager.CreateTemporaryProject(projects, TemporaryProjectMode.Temporary); break; } } var nbLinesToErase = Console.CursorTop - top; Console.CursorTop = top; Console.CursorLeft = 0; ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase, ConsoleColor.Black); Console.CursorTop = top; Console.CursorLeft = 0; if (project == null) { continue; } Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("Project selected: "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(project.Properties.Name); Console.WriteLine(); return(project); } }