public void VsShellUtils_GetOrCreateSonarLintOutputPane() { // Arrange var outputWindow = new ConfigurableVsOutputWindow(); var serviceProvider = new ConfigurableServiceProvider(); serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); // Act IVsOutputWindowPane pane = VsShellUtils.GetOrCreateSonarLintOutputPane(serviceProvider); // Assert outputWindow.AssertPaneExists(VsShellUtils.SonarLintOutputPaneGuid); pane.Should().NotBeNull(); var sonarLintPane = pane as ConfigurableVsOutputWindowPane; if (sonarLintPane == null) { FluentAssertions.Execution.Execute.Assertion.FailWith($"Expected returned pane to be of type {nameof(ConfigurableVsOutputWindowPane)}"); } sonarLintPane.IsActivated.Should().BeTrue("Expected pane to be activated"); sonarLintPane.Name.Should().Be(Strings.SonarLintOutputPaneTitle, "Unexpected pane name."); }
public void VsShellUtils_GetOrCreateSonarLintOutputPane() { // Setup var outputWindow = new ConfigurableVsOutputWindow(); var serviceProvider = new ConfigurableServiceProvider(); serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); // Act IVsOutputWindowPane pane = VsShellUtils.GetOrCreateSonarLintOutputPane(serviceProvider); // Verify outputWindow.AssertPaneExists(VsShellUtils.SonarLintOutputPaneGuid); Assert.IsNotNull(pane); var sonarLintPane = pane as ConfigurableVsOutputWindowPane; if (sonarLintPane == null) { Assert.Inconclusive($"Expected returned pane to be of type {nameof(ConfigurableVsOutputWindowPane)}"); } Assert.IsTrue(sonarLintPane.IsActivated, "Expected pane to be activated"); Assert.AreEqual(Strings.SonarLintOutputPaneTitle, sonarLintPane.Name, "Unexpected pane name."); }
public static IProgressEvents StartAsync(IServiceProvider sp, IProgressControlHost host, Func <IProgressController, ProgressStepDefinition[]> stepFactory) { if (sp == null) { throw new ArgumentNullException(nameof(sp)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (stepFactory == null) { throw new ArgumentNullException(nameof(stepFactory)); } Debug.Assert(ThreadHelper.CheckAccess(), "Expected to be called on the UI thread"); // Initialize a controller and an observer var controller = new SequentialProgressController(sp); controller.Initialize(stepFactory(controller)); IVsOutputWindowPane sonarLintPane = VsShellUtils.GetOrCreateSonarLintOutputPane(sp); bool logFullMessage; #if DEBUG logFullMessage = true; #else logFullMessage = false; #endif var notifier = new VsOutputWindowPaneNotifier(sp, sonarLintPane, ensureOutputVisible: true, messageFormat: Strings.UnexpectedWorkflowError, logFullException: logFullMessage); controller.ErrorNotificationManager.AddNotifier(notifier); Observe(controller, host); controller.RunOnFinished(r => observedControllersMap.Remove(controller)); #pragma warning disable 4014 // We do want to start and forget. All the errors will be forwarded via the error notification manager controller.StartAsync(); #pragma warning restore 4014 return(controller); }
public void Show() { var sonarLintOutputPane = VsShellUtils.GetOrCreateSonarLintOutputPane(serviceProvider); Debug.Assert(sonarLintOutputPane != null, "Failed to create SonarLint pane"); if (sonarLintOutputPane == null) { return; } var hr = sonarLintOutputPane.Activate(); Debug.Assert(ErrorHandler.Succeeded(hr), "Failed to activate SonarLint pane: " + hr); if (ErrorHandler.Succeeded(hr)) { toolWindowService.Show(VSConstants.StandardToolWindows.Output); } }