Esempio n. 1
0
        public void TestTvlDiagnosticsPane()
        {
            IOutputWindowService outputWindowService = OutputWindowService;
            IOutputWindowPane    pane = outputWindowService.TryGetPane(PredefinedOutputWindowPanes.TvlDiagnostics);

            Assert.IsInstanceOfType(pane, typeof(IOutputWindowPane));
            TestStandardPanes.TestOutputPaneBehavior(pane, PredefinedOutputWindowPanes.TvlDiagnostics);
        }
Esempio n. 2
0
        public void TestPredefinedGeneralPane()
        {
            IOutputWindowService outputWindowService = OutputWindowService;
            IOutputWindowPane    pane = outputWindowService.TryGetPane(PredefinedOutputWindowPanes.General);

            Assert.IsInstanceOfType(pane, typeof(IOutputWindowPane));
            TestOutputPaneBehavior(pane, PredefinedOutputWindowPanes.General);
        }
Esempio n. 3
0
        public void TestRenameCustomPaneDoesNotAffectPaneLookup()
        {
            IOutputWindowService outputWindowService = OutputWindowService;
            IOutputWindowPane    pane = outputWindowService.TryGetPane(PredefinedOutputWindowPanes.TvlDiagnostics);

            Assert.IsInstanceOfType(pane, typeof(IOutputWindowPane));

            string newName = PredefinedOutputWindowPanes.TvlDiagnostics + " Something Else";

            pane.Name = newName;
            IOutputWindowPane retry = outputWindowService.TryGetPane(PredefinedOutputWindowPanes.TvlDiagnostics);

            Assert.IsInstanceOfType(pane, typeof(IOutputWindowPane));
            Assert.AreEqual(newName, retry.Name);

            retry.Name = PredefinedOutputWindowPanes.TvlDiagnostics;
            Assert.AreEqual(PredefinedOutputWindowPanes.TvlDiagnostics, pane.Name);
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the menu item.
                var menuCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidNewIssue);
                var menuItem      = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(menuItem);
                // Create the commands for the tool windows
                var issueListWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidIssues);
                var menuIssueListWin      = new MenuCommand(ShowIssueListToolWindow, issueListWndCommandID);
                mcs.AddCommand(menuIssueListWin);

                var issueWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidIssueWindow);
                var menuIssueWin      = new MenuCommand(ShowIssueToolWindow, issueWndCommandID);
                mcs.AddCommand(menuIssueWin);
            }

            IComponentModel      componentModel      = (IComponentModel)GetService(typeof(SComponentModel));
            IOutputWindowService outputWindowService = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IOutputWindowService>();
            IOutputWindowPane    gitHubPane          = null;

            // Warn users if dependencies aren't installed.
            vsbaseWarningProvider = new ErrorListProvider(this);
            if (outputWindowService != null)
            {
                gitHubPane = outputWindowService.TryGetPane(View.OutputWriter.GitHubOutputWindowPaneName);
            }
            else
            {
                ErrorTask task = new ErrorTask
                {
                    Category      = TaskCategory.Misc,
                    ErrorCategory = TaskErrorCategory.Error,
                    Text          = "The required VSBase Services debugging support extension is not installed; output window messages will not be shown. Click here for more information."
                };
                task.Navigate += HandleNavigateToVsBaseServicesExtension;
                vsbaseWarningProvider.Tasks.Add(task);
                vsbaseWarningProvider.Show();
            }

            // This code is a bit of a hack to bridge MEF created components and Ninject managed components
            Factory.Rebind <IOutputWindowPane>().ToConstant(gitHubPane);
            Factory.Rebind <ICache>().ToConstant(componentModel.DefaultExportProvider.GetExportedValue <Cache>());
        }
Esempio n. 5
0
        public void ExecuteTests(string consolePath, string commandArgs, bool debug)
        {
            string command = string.Format("{0} {1}", consolePath, commandArgs);

            tracer.Trace(command, GetType().Name);

            var pane          = outputWindowService.TryGetPane(OutputWindowDefinitions.SpecRunOutputWindowName);
            var displayResult = pane != null;
            var dispatcher    = Dispatcher.CurrentDispatcher;

            var process = new System.Diagnostics.Process();

            process.StartInfo.FileName               = consolePath;
            process.StartInfo.Arguments              = commandArgs;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.CreateNoWindow         = true;

            if (displayResult)
            {
                pane.Clear();
                pane.Activate();
                dte.ToolWindows.OutputWindow.Parent.Activate();
                pane.WriteLine(command);
                process.OutputDataReceived += (sender, args) =>
                {
                    if (args.Data != null)
                    {
                        dispatcher.BeginInvoke(new Action(() => pane.WriteLine(args.Data)), DispatcherPriority.ContextIdle);
                    }
                };
            }

            process.Start();

            if (debug)
            {
                AttachToProcess(process.Id);
            }

            if (displayResult)
            {
                process.BeginOutputReadLine();
            }

            // async execution: we do not call 'process.WaitForExit();'
        }
        public void ExecuteTests(string consolePath, string commandArgs, bool debug, Version specRunVersion)
        {
            string command = string.Format("{0} {1}", consolePath, commandArgs);

            tracer.Trace(command, GetType().Name);

            var pane          = outputWindowService.TryGetPane(OutputWindowDefinitions.SpecRunOutputWindowName);
            var displayResult = pane != null;
            var dispatcher    = Dispatcher.CurrentDispatcher;

            var process = new System.Diagnostics.Process
            {
                StartInfo =
                {
                    FileName               = consolePath,
                    Arguments              = commandArgs,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true
                }
            };

            var executionContext = new ExecutionContext(displayResult ? pane : null, dispatcher, process, debug, dte, tracer, specRunVersion);

            if (displayResult)
            {
                pane.Clear();
                pane.Activate();
                dte.ToolWindows.OutputWindow.Parent.Activate();
                pane.WriteLine(command);
            }

            executionContext.Start();

            // async execution: we do not call 'process.WaitForExit();'
        }
        private void ReParse()
        {
            try
            {
                _dirty = false;

                IOutputWindowPane outputWindow = null;
                if (_outputWindowService != null && !string.IsNullOrEmpty(_outputWindowName))
                {
                    outputWindow = _outputWindowService.TryGetPane(_outputWindowName);
                }

                Stopwatch stopwatch = Stopwatch.StartNew();

                string message = "{0}: Background parse {1}{2} in {3}ms. {4}";
                string name    = Name;
                if (!string.IsNullOrEmpty(name))
                {
                    name = "(" + name + ") ";
                }

                string        filename     = "<Unknown File>";
                ITextDocument textDocument = TextDocument;
                if (textDocument != null)
                {
                    filename = textDocument.FilePath;
                    if (filename != null)
                    {
                        filename = filename.Substring(filename.LastIndexOfAny(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) + 1);
                    }
                }

                try
                {
                    ReParseImpl();

                    if (outputWindow != null)
                    {
                        long time = stopwatch.ElapsedMilliseconds;
                        outputWindow.WriteLine(string.Format(message, filename, name, "succeeded", time, string.Empty));
                    }
                }
                catch (Exception e2)
                {
                    if (ErrorHandler.IsCriticalException(e2))
                    {
                        throw;
                    }

                    try
                    {
                        if (outputWindow != null)
                        {
                            long time = stopwatch.ElapsedMilliseconds;
                            outputWindow.WriteLine(string.Format(message, filename, name, "failed", time, e2.Message + e2.StackTrace));
                        }
                    }
                    catch (Exception e3)
                    {
                        if (ErrorHandler.IsCriticalException(e3))
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ErrorHandler.IsCriticalException(ex))
                {
                    throw;
                }
            }
        }