/// <summary> /// Finds a command by cannonical name. /// </summary> public async Task <CommandID?> FindCommandAsync(string name) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsCmdNameMapping cmdNameMap = await VS.Services.GetCommandNameMappingAsync(); int hr = cmdNameMap.MapNameToGUIDID(name, out Guid commandGroup, out uint commandId); if (hr == VSConstants.S_OK) { return(new CommandID(commandGroup, (int)commandId)); } return(null); }
public void SetTargetThread(uint systemThreadId) { int targetThreadIndex = Array.IndexOf(this.GetCurrentProcessThreads(), systemThreadId); if (targetThreadIndex == -1) { throw new DebuggerException("Invalid thread ID"); } else { if (this.TargetThreadSystemId != systemThreadId) { Guid setCurrentThreadCmdGroup; uint setCurrentThreadCmdId; IVsCmdNameMapping vsCmdNameMapping = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsCmdNameMapping)) as IVsCmdNameMapping; vsCmdNameMapping.MapNameToGUIDID("Debug.SetCurrentThread", out setCurrentThreadCmdGroup, out setCurrentThreadCmdId); Microsoft.VisualStudio.Shell.OleMenuCommandService commandService = new Microsoft.VisualStudio.Shell.OleMenuCommandService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider); if (!commandService.GlobalInvoke(new CommandID(setCurrentThreadCmdGroup, (int)setCurrentThreadCmdId), Convert.ToString(targetThreadIndex + 1))) { throw new DebuggerException("Unable to set the active thread in the debugger."); } } } }
public void Continue() { if (this.EnsureDebuggerService()) { DBGMODE[] mode = new DBGMODE[1]; // Only continue when broken in. if ((this.vsDebuggerService.GetMode(mode) == 0) && (mode[0] == DBGMODE.DBGMODE_Break)) { Guid startCmdGroup; uint startCmdId; IVsCmdNameMapping vsCmdNameMapping = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsCmdNameMapping)) as IVsCmdNameMapping; vsCmdNameMapping.MapNameToGUIDID("Debug.Start", out startCmdGroup, out startCmdId); Microsoft.VisualStudio.Shell.OleMenuCommandService commandService = new Microsoft.VisualStudio.Shell.OleMenuCommandService(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider); if (!commandService.GlobalInvoke(new CommandID(startCmdGroup, (int)startCmdId))) { throw new DebuggerException("Unable to continue debugging."); } } } }