/// <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> /// <param name="cancellationToken"> /// A <see cref="CancellationToken"/> that can be used to cancel the initialization of the package. /// </param> /// <param name="progress"> /// A provider to update progress. /// </param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(continueOnCapturedContext: true); var callback = new ServiceCreatorCallback(this.CreateService); foreach (KeyValuePair <Type, ServiceInformation> serviceInformationKVP in ServiceTypeToServiceInformation) { ((IServiceContainer)this).AddService(serviceInformationKVP.Key, callback, promote: serviceInformationKVP.Value.Promote); } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // initialize Option first since other componments may depends on options. await SarifViewerOption.InitializeAsync(this).ConfigureAwait(false); OpenLogFileCommands.Initialize(this); CodeAnalysisResultManager.Instance.Register(); SarifToolWindowCommand.Initialize(this); ErrorList.ErrorListCommand.Initialize(this); this.sarifFolderMonitor = new SarifFolderMonitor(); if (await this.IsSolutionLoadedAsync()) { // Async package initilized after solution is fully loaded according to // [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string, PackageAutoLoadFlags.BackgroundLoad)] // SolutionEvents.OnAfterBackgroundSolutionLoadComplete will not by triggered until the user opens another solution. // Need to manually start monitor in this case. this.sarifFolderMonitor?.StartWatch(); } SolutionEvents.OnBeforeCloseSolution += this.SolutionEvents_OnBeforeCloseSolution; SolutionEvents.OnAfterBackgroundSolutionLoadComplete += this.SolutionEvents_OnAfterBackgroundSolutionLoadComplete; return; }
/// <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() { OpenLogFileCommands.Initialize(this); base.Initialize(); string path = Assembly.GetExecutingAssembly().Location; var configMap = new ExeConfigurationFileMap(); configMap.ExeConfigFilename = Path.Combine(Path.GetDirectoryName(path), "App.config"); AppConfig = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); #if DEBUG string telemetryKey = SarifViewerPackage.AppConfig.AppSettings.Settings["TelemetryInstrumentationKey_Debug"].Value; #else string telemetryKey = SarifViewerPackage.AppConfig.AppSettings.Settings["TelemetryInstrumentationKey_Release"].Value; #endif TelemetryConfiguration configuration = new TelemetryConfiguration() { InstrumentationKey = telemetryKey }; TelemetryProvider.Initialize(configuration); TelemetryProvider.WriteEvent(TelemetryEvent.ViewerExtensionLoaded); _sarifEditorFactory = new SarifEditorFactory(); RegisterEditorFactory(_sarifEditorFactory); CodeAnalysisResultManager.Instance.Register(); Microsoft.Sarif.Viewer.SarifToolWindowCommand.Initialize(this); }
/// <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() { OpenLogFileCommands.Initialize(this); base.Initialize(); _sarifEditorFactory = new SarifEditorFactory(); RegisterEditorFactory(_sarifEditorFactory); CodeAnalysisResultManager.Instance.Register(); }
/// <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> /// <param name="cancellationToken"> /// A <see cref="CancellationToken"/> that can be used to cancel the initialization of the package. /// </param> /// <param name="progress"> /// A provider to update progress. /// </param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(continueOnCapturedContext: true); var callback = new ServiceCreatorCallback(this.CreateService); foreach (KeyValuePair <Type, ServiceInformation> serviceInformationKVP in ServiceTypeToServiceInformation) { ((IServiceContainer)this).AddService(serviceInformationKVP.Key, callback, promote: serviceInformationKVP.Value.Promote); } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); OpenLogFileCommands.Initialize(this); CodeAnalysisResultManager.Instance.Register(); SarifToolWindowCommand.Initialize(this); ErrorList.ErrorListCommand.Initialize(this); return; }
/// <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 async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { OpenLogFileCommands.Initialize(this); base.Initialize(); ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService); ((IServiceContainer)this).AddService(typeof(SLoadSarifLogService), callback, true); string path = Assembly.GetExecutingAssembly().Location; var configMap = new ExeConfigurationFileMap(); configMap.ExeConfigFilename = Path.Combine(Path.GetDirectoryName(path), "App.config"); AppConfig = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); #if DEBUG string telemetryKey = SarifViewerPackage.AppConfig.AppSettings.Settings["TelemetryInstrumentationKey_Debug"].Value; #else string telemetryKey = SarifViewerPackage.AppConfig.AppSettings.Settings["TelemetryInstrumentationKey_Release"].Value; #endif TelemetryConfiguration configuration = new TelemetryConfiguration() { InstrumentationKey = telemetryKey }; TelemetryProvider.Initialize(configuration); TelemetryProvider.WriteEvent(TelemetryEvent.ViewerExtensionLoaded); _sarifEditorFactory = new SarifEditorFactory(); RegisterEditorFactory(_sarifEditorFactory); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); CodeAnalysisResultManager.Instance.Register(); SarifToolWindowCommand.Initialize(this); ErrorList.ErrorListCommand.Initialize(this); return; }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(Package package) { Instance = new OpenLogFileCommands(package); }