/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(AsyncPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken); var commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; DebugStartWithoutDebuggingCommand.Instance = new DebugStartWithoutDebuggingCommand(package, commandService); }
/// <summary> /// Initializes the package. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>The tracking <see cref="Task"/>.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Basic initialization. Instance = this; dte = (DTE2)(await GetServiceAsync(typeof(SDTE))); // Get references to necessary the IDE services. SolutionService = await RaspberryDebuggerPackage.Instance.GetServiceAsync(typeof(IVsSolution)) as IVsSolution; if (SolutionService == null) { Covenant.Assert(false, "GetService(typeof(IVsSolution)) returns NULL."); } // Initialize the log panel. var debugWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow; var generalPaneGuid = VSConstants.GUID_OutWindowDebugPane; debugWindow.GetPane(ref generalPaneGuid, out debugPane); // Intercept the debugger commands and quickly decide whether the startup project is enabled // for Raspberry remote debugging so we can invoke our custom commands instead. We'll just // let the default command implementations do their thing when we're not doing Raspberry // debugging. debugStartCommandEvent = dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 0x0127]; debugStartWithoutDebuggingCommandEvent = dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 0x0170]; debugAttachToProcessCommandEvent = dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 0x00d5]; debugRestartCommandEvent = dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 0x0128]; debugStartCommandEvent.BeforeExecute += DebugStartCommandEvent_BeforeExecute; debugStartWithoutDebuggingCommandEvent.BeforeExecute += DebugStartWithoutDebuggingCommandEvent_BeforeExecute; debugAttachToProcessCommandEvent.BeforeExecute += AttachToProcessCommandEvent_BeforeExecute; debugRestartCommandEvent.BeforeExecute += DebugRestartCommandEvent_BeforeExecute; // Initialize the new commands. await SettingsCommand.InitializeAsync(this); await DebugStartCommand.InitializeAsync(this); await DebugStartWithoutDebuggingCommand.InitializeAsync(this); await DebugAttachToProcessCommand.InitializeAsync(this); }