/// <summary> /// The initialize. /// </summary> protected override void Initialize() { try { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this)); base.Initialize(); this.SetupMenuCommands(); this.dte2 = (DTE2)GetGlobalService(typeof(DTE)); if (this.dte2 == null) { return; } try { this.visualStudioInterface = new VsPropertiesHelper(this.dte2, this); this.VsEvents = new VsEvents(this.visualStudioInterface, this.dte2, this); var bar = this.GetService(typeof(SVsStatusbar)) as IVsStatusbar; this.StatusBar = new VSSStatusBar(bar, this.dte2); var extensionRunningPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty).ToString(); var uniqueId = this.dte2.Version; if (extensionRunningPath.ToLower().Contains(this.dte2.Version + "exp")) { uniqueId += "Exp"; } SonarQubeViewModelFactory.StartupModelWithVsVersion(uniqueId).InitModelFromPackageInitialization(this.visualStudioInterface, this.StatusBar, this, this.AssemblyDirectory); DColor defaultBackground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey); DColor defaultForeground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey); SonarQubeViewModelFactory.SQViewModel.UpdateTheme(ToMediaColor(defaultBackground), ToMediaColor(defaultForeground)); // force analysis to come to vsix var i = 0; var data = string.Empty; foreach (var item in SonarQubeViewModelFactory.StartupModelWithVsVersion(uniqueId).VSonarQubeOptionsViewData.RoslynModel.ExtensionDiagnostics) { i += item.Value.AvailableChecks.Count; foreach (var check in item.Value.AvailableChecks) { DiagnosticAnalyzer analyser = check; data += analyser.ToString(); } } this.StatusBar.DisplayMessage("checks : " + i); try { var outWindow = GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; var customGuid = new Guid("CDA8E85D-C469-4855-878B-0E778CD0DD53"); if (outWindow != null) { outWindow.CreatePane(ref customGuid, "VSSonarQube Output", 1, 1); IVsOutputWindowPane customPane; outWindow.GetPane(ref customGuid, out customPane); ((VsPropertiesHelper)this.visualStudioInterface).CustomPane = customPane; ((VsPropertiesHelper)this.visualStudioInterface).CustomPane.Activate(); } SonarQubeViewModelFactory.SQViewModel.PluginRequest += this.LoadPluginIntoNewToolWindow; this.CloseToolWindow(); this.StartSolutionListeners(this.visualStudioInterface); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } catch (Exception ex) { UserExceptionMessageBox.ShowException("SonarQubeExtension not able to start", ex); } } catch (Exception ex) { UserExceptionMessageBox.ShowException("Extension Failed to Start", ex); throw; } }
/// <summary> /// The initialize. /// </summary> protected override void Initialize() { try { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this)); base.Initialize(); this.SetupMenuCommands(); this.dte2 = (DTE2)GetGlobalService(typeof(DTE)); if (this.dte2 == null) { return; } try { this.visualStudioInterface = new VsPropertiesHelper(this.dte2, this); this.visualStudioInterface.WriteToVisualStudioOutput(DateTime.Now + " : VsSonarExtensionPackage Initialize"); this.VsEvents = new VsEvents(this.visualStudioInterface, this.dte2, this); var bar = this.GetService(typeof(SVsStatusbar)) as IVsStatusbar; this.StatusBar = new VSSStatusBar(bar, this.dte2); var extensionRunningPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", string.Empty).ToString(); var uniqueId = this.dte2.Version; if (extensionRunningPath.ToLower().Contains(this.dte2.Version + "exp")) { uniqueId += "Exp"; } SonarQubeViewModelFactory.StartupModelWithVsVersion(uniqueId).InitModelFromPackageInitialization(this.visualStudioInterface, this.StatusBar, this, this.AssemblyDirectory); this.CloseToolsWindows(); this.OutputGuid = "CDA8E85D-C469-4855-878B-0E778CD0DD" + int.Parse(uniqueId.Split('.')[0]).ToString(CultureInfo.InvariantCulture); this.StartOutputWindow(this.OutputGuid); // start listening SonarQubeViewModelFactory.SQViewModel.PluginRequest += this.LoadPluginIntoNewToolWindow; this.StartSolutionListeners(this.visualStudioInterface); // configure colours DColor defaultBackground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey); DColor defaultForeground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey); SonarQubeViewModelFactory.SQViewModel.UpdateTheme(ToMediaColor(defaultBackground), ToMediaColor(defaultForeground)); } catch (Exception ex) { UserExceptionMessageBox.ShowException("SonarQubeExtension not able to start", ex); } } catch (Exception ex) { UserExceptionMessageBox.ShowException("Extension Failed to Start", ex); throw; } }