public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; var dotNetManager = new NDependServicesProvider().DotNetManager; // Gather most recent .NET Fx + directories containing assemblies var mostRecentVersion = dotNetManager.GetDotNetProfileVersionsInstalled(DotNetProfile.DotNetFramework).First(); var dirs = dotNetManager.GetDotNetProfileDirectories(DotNetProfile.DotNetFramework, mostRecentVersion); Console.WriteLine(".NET Fx v" + mostRecentVersion + " directories that contains assemblies to analyze:"); foreach (var dir in dirs) { Console.WriteLine(" -> " + dir.ToString()); } // Gather all .NET Fx assembly var dotNetFxAssemblies = (from dir in dirs from file in dir.ChildrenFilesPath where dotNetManager.IsAssembly(file) select file).ToList(); Console.WriteLine(dotNetFxAssemblies.Count + " .NET Fx assemblies found"); // Create temporary NDepend project and analyze it var project = projectManager.CreateTemporaryProject(dotNetFxAssemblies, TemporaryProjectMode.Temporary); var analysisResult = ProjectAnalysisUtils.RunAnalysisShowProgressOnConsole(project); // Show results ProjectAnalysisUtils.ShowConsoleAnalysisResult(analysisResult.CodeBase); Console.WriteLine("The .NET Fx analysis result produced can now be consummed live from the NDepend project named \"" + project.Properties.Name + "\""); }
public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; var visualStudioManager = new NDependServicesProvider().VisualStudioManager; // // Gather all Most Recent Used VS solutions and projects file path referenced in registry // var vsFilesPath = new List <IAbsoluteFilePath>(); foreach (var vsVersion in new[] { VisualStudioVersion.V7_2003, VisualStudioVersion.V8_2005, VisualStudioVersion.V9_2008, VisualStudioVersion.V10_2010 }) { if (!visualStudioManager.IsVisualStudioVersionIntalled(vsVersion)) { continue; } vsFilesPath.AddRange(visualStudioManager.GetMostRecentlyUsedVisualStudioSolutionOrProject(vsVersion)); } Console.WriteLine(vsFilesPath.Count + " VS sln or proj files found"); // // Gather all Debug projects built from these VS solutions and projects // var projectsPath = new List <IAbsoluteFilePath>(); foreach (var vsFilePath in vsFilesPath) { projectsPath.Add(vsFilePath); } // // Create temporary project // var project = projectManager.CreateTemporaryProject(projectsPath, TemporaryProjectMode.Temporary); // // Run analysis // var analysisResult = ProjectAnalysisUtils.RunAnalysisShowProgressOnConsole(project); // // Show results // ProjectAnalysisUtils.ShowConsoleAnalysisResult(analysisResult.CodeBase); Console.WriteLine("The analysis result produced can now be consummed from the CppDepend project \"" + project.Properties.Name + "\""); }
public void Run() { // // Get dir // var folderBrowserDialog = new FolderBrowserDialog { ShowNewFolderButton = false }; if (folderBrowserDialog.ShowDialog() != DialogResult.OK) { return; } var dir = folderBrowserDialog.SelectedPath.ToAbsoluteDirectoryPath(); // // Get recursive // bool recursive = false; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Search assemblies recursive under {" + dir.ToString() + "} ?"); Console.WriteLine("Yes? y or No? (another key)"); var consoleKeyInfo = Console.ReadKey(); if (consoleKeyInfo.KeyChar == 'y') { recursive = true; } Console.ForegroundColor = ConsoleColor.White; // // Get assembliesPath // var dotNetManager = new NDependServicesProvider().DotNetManager; var assembliesPath = new List <IAbsoluteFilePath>(); var cursorTop = Console.CursorTop; if (!recursive) { ScanDir(dir, assembliesPath, dotNetManager, cursorTop); } else { ScanDirRecursive(dir, assembliesPath, dotNetManager, Console.CursorTop); } Console.CursorTop = cursorTop; Console.CursorLeft = 0; ConsoleUtils.ShowNLinesOnConsole(10, ConsoleColor.Black); Console.CursorTop = cursorTop; Console.CursorLeft = 0; // // Get project // Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(assembliesPath.Count + " assemblies found"); Console.WriteLine(assembliesPath.Select(path => path.FileNameWithoutExtension).Distinct(StringComparer.InvariantCultureIgnoreCase).Count() + " assemblies with distint names found"); Console.WriteLine("Create the NDepend temporary project."); var projectManager = new NDependServicesProvider().ProjectManager; var project = projectManager.CreateTemporaryProject(assembliesPath, TemporaryProjectMode.Temporary); // // Run analysis // Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Run Analysis!"); var analysisResult = ProjectAnalysisUtils.RunAnalysisShowProgressOnConsole(project); // // Show results // ProjectAnalysisUtils.ShowConsoleAnalysisResult(analysisResult.CodeBase); }
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); } }
public void Run() { var projectManager = new NDependServicesProvider().ProjectManager; var visualStudioManager = new NDependServicesProvider().VisualStudioManager; // // Gather all Most Recent Used VS solutions and projects file path referenced in registry // var vsFilesPath = new List <IAbsoluteFilePath>(); foreach (var vsVersion in new[] { VisualStudioVersion.V7_2003, VisualStudioVersion.V8_2005, VisualStudioVersion.V9_2008, VisualStudioVersion.V10_2010 }) { if (!visualStudioManager.IsVisualStudioVersionIntalled(vsVersion)) { continue; } vsFilesPath.AddRange(visualStudioManager.GetMostRecentlyUsedVisualStudioSolutionOrProject(vsVersion)); } Console.WriteLine(vsFilesPath.Count + " VS sln or proj files found"); // // Gather all Debug assemblies built from these VS solutions and projects // var assembliesPath = new List <IAbsoluteFilePath>(); foreach (var vsFilePath in vsFilesPath) { assembliesPath.AddRange(visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(vsFilePath)); } // // Create temporary project // var project = projectManager.CreateTemporaryProject(assembliesPath, TemporaryProjectMode.Temporary); // // Inform about potential assembly resolving error // IReadOnlyList <IAbsoluteFilePath> applicationAssemblies, thirdPartyAssemblies; IReadOnlyList <IAssemblyResolvingError> applicationAssembliesError, thirdPartyAssembliesError; project.CodeToAnalyze.Resolve(out applicationAssemblies, out thirdPartyAssemblies, out applicationAssembliesError, out thirdPartyAssembliesError); if (applicationAssembliesError.Count > 0) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(applicationAssembliesError.Count + " assembly resolving error, assemblies with following names won't be analyzed:"); foreach (var assemblyResolvingError in applicationAssembliesError) { // You can use assemblyResolvingError.ErrorDescription to show error in plain english // most of the time it'll be several different assemblies with the same name found. Console.Write(assemblyResolvingError.AssemblyName + " ; "); } Console.ForegroundColor = ConsoleColor.White; } // // Run analysis // var analysisResult = ProjectAnalysisUtils.RunAnalysisShowProgressOnConsole(project); // // Show results // ProjectAnalysisUtils.ShowConsoleAnalysisResult(analysisResult.CodeBase); Console.WriteLine("The analysis result produced can now be consummed from the NDepend project \"" + project.Properties.Name + "\""); }