protected virtual void EnterCodeElement(ICodeElement codeElement)
 {
     Debug.Assert(codeElement != null);
     ConsoleUtils.TryOpenSource(codeElement);
 }
        internal static bool TryGetAssembliesToCompareAndAnalyzeThem(out ICompareContext compareContext)
        {
            var analysisManager = new NDependServicesProvider().AnalysisManager;

            var top = Console.CursorTop;

            Console.CursorLeft = 0;

            IProject           projectOlder, projectNewer;
            IAnalysisResultRef analysisResultRefOlder, analysisResultRefNewer;

            Console.WriteLine("Please choose older and newer versions of the code base...");

            bool dialogOk = analysisManager.ShowDialogBuildComparison(
                ConsoleUtils.MainWindowHandle,
                out projectOlder,
                out analysisResultRefOlder,
                out projectNewer,
                out analysisResultRefNewer);

            if (!dialogOk)
            {
                compareContext = null;
                return(false);
            }


            var nbLinesToErase = Console.CursorTop - top;

            Console.CursorTop  = top;
            Console.CursorLeft = 0;
            ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase, ConsoleColor.Black);
            Console.CursorTop  = top;
            Console.CursorLeft = 0;


            //
            // Load or analyze
            //
            IAnalysisResult analysisResultOlder, analysisResultNewer;

            if (analysisResultRefOlder == null)
            {
                Debug.Assert(projectOlder != null);
                Console.WriteLine("Analyze older version of assemblies");
                analysisResultOlder = RunAnalysisShowProgressOnConsole(projectOlder);
            }
            else
            {
                Console.WriteLine("Load older analysis result");
                analysisResultOlder = LoadAnalysisShowProgressOnConsole(analysisResultRefOlder);
            }

            if (analysisResultRefNewer == null)
            {
                Debug.Assert(projectNewer != null);
                Console.WriteLine("Analyze newer version of assemblies");
                analysisResultNewer = RunAnalysisShowProgressOnConsole(projectNewer);
            }
            else
            {
                Console.WriteLine("Load newer analysis result");
                analysisResultNewer = LoadAnalysisShowProgressOnConsole(analysisResultRefNewer);
            }

            //
            // Re-erase
            //
            var nbLinesToErase2 = Console.CursorTop - top;

            Console.CursorTop  = top;
            Console.CursorLeft = 0;
            ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase2, ConsoleColor.Black);
            Console.CursorTop  = top;
            Console.CursorLeft = 0;


            //
            // Show compare description
            //
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("Comparing: ");
            Console.ForegroundColor = ConsoleColor.White;
            ShowAnalysisResultRefDescription(analysisResultOlder.AnalysisResultRef);
            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("     with: ");
            Console.ForegroundColor = ConsoleColor.White;
            ShowAnalysisResultRefDescription(analysisResultNewer.AnalysisResultRef);

            compareContext = analysisResultNewer.CodeBase.CreateCompareContextWithOlder(analysisResultOlder.CodeBase);
            return(true);
        }
Beispiel #3
0
 protected override void Display(IMember member)
 {
     Debug.Assert(member != null);
     ConsoleUtils.ShowConsoleMemberFullNamePrefixedWithAssembly(member);
     Console.WriteLine(); // One line separator!
 }
        internal static bool TryChooseProject(out IProject project)
        {
            var ndependServicesProvider = new NDependServicesProvider();
            var projectManager          = ndependServicesProvider.ProjectManager;
            var visualStudioManager     = ndependServicesProvider.VisualStudioManager;

CHOOSE_PROJECT:
            var top = Console.CursorTop;

            Console.CursorLeft = 0;

            Console.WriteLine("Please choose...");
            Console.WriteLine("  a) an existing NDepend project");
            Console.WriteLine("  b) one or several Visual Studio solutions to analyze");
            Console.WriteLine("  c) one or several .NET assemblies to analyze");
            Console.WriteLine("");
            var c = Char.ToLower(Console.ReadKey().KeyChar);

            Console.WriteLine();

            switch (c)
            {
            case 'a':
                if (!projectManager.ShowDialogChooseAnExistingProject(ConsoleUtils.MainWindowHandle, out project))
                {
                    goto TRY_AGAIN;
                }
                break;

            case 'b': {
                ICollection <IAbsoluteFilePath> solutions;
                if (!visualStudioManager.ShowDialogSelectVisualStudioSolutionsOrProjects(ConsoleUtils.MainWindowHandle, out solutions))
                {
                    goto TRY_AGAIN;
                }
                var assemblies = new List <IAbsoluteFilePath>();
                foreach (var solution in solutions)
                {
                    assemblies.AddRange(visualStudioManager.GetAssembliesFromVisualStudioSolutionOrProject(solution));
                }
                project = projectManager.CreateTemporaryProject(assemblies, TemporaryProjectMode.Temporary);
                break;
            }

            case 'c': {
                ICollection <IAbsoluteFilePath> assemblies;
                if (!projectManager.ShowDialogSelectAssemblies(ConsoleUtils.MainWindowHandle, out assemblies))
                {
                    goto TRY_AGAIN;
                }
                project = projectManager.CreateTemporaryProject(assemblies, TemporaryProjectMode.Temporary);
                break;
            }

            case (char)Keys.Escape:  // ESC to exit!
                project = null;
                return(false);

            default:
TRY_AGAIN:
                var nbLinesToErase = Console.CursorTop - top;
                Console.CursorTop  = top;
                Console.CursorLeft = 0;
                ConsoleUtils.ShowNLinesOnConsole(nbLinesToErase, ConsoleColor.Black);
                Console.WriteLine("(ESC to exit)");
                Console.CursorTop  = top;
                Console.CursorLeft = 0;
                goto CHOOSE_PROJECT;
            }
            Debug.Assert(project != null);



            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("Project selected: ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(project.Properties.Name);
            Console.WriteLine();
            return(true);
        }