public static IEnumerable <string> GetCommandNames([NotNull] this IVsCmdNameMapping commandNameMapping) { Requires.NotNull(commandNameMapping, nameof(commandNameMapping)); IEnumString enumString; if (ErrorHandler.Succeeded(commandNameMapping.EnumNames(VSCMDNAMEOPTS.CNO_GETENU, out enumString))) { string[] array = new string[1]; while (true) { uint count; int hr = enumString.Next((uint)array.Length, array, out count); ErrorHandler.ThrowOnFailure(hr); if (hr == VSConstants.S_FALSE || count == 0) { break; } for (uint i = 0; i < count; i++) { yield return(array[i]); } } } }
public static IEnumerable <string> GetCommandNames(this IVsCmdNameMapping commandNameMapping) { Contract.Requires <ArgumentNullException>(commandNameMapping != null, "commandNameMapping"); Contract.Ensures(Contract.Result <IEnumerable <string> >() != null); IEnumString enumString; if (ErrorHandler.Succeeded(commandNameMapping.EnumNames(VSCMDNAMEOPTS.CNO_GETENU, out enumString))) { string[] array = new string[1]; while (true) { uint count; int hr = enumString.Next((uint)array.Length, array, out count); ErrorHandler.ThrowOnFailure(hr); if (hr == VSConstants.S_FALSE || count == 0) { break; } for (uint i = 0; i < count; i++) { yield return(array[i]); } } } }
public VsCommandShortcutProvider(Lifetime lifetime, ShortcutDisplayStatistics statistics, DTE dte, IVsCmdNameMapping vsCmdNameMapping, VsShortcutFinder vsShortcutFinder, VsToolsOptionsMonitor vsToolsOptionsMonitor, IActionShortcuts actionShortcuts) { this.statistics = statistics; this.vsCmdNameMapping = vsCmdNameMapping; this.vsShortcutFinder = vsShortcutFinder; this.actionShortcuts = actionShortcuts; this.dte = dte; cachedActionDefs = new Dictionary <string, CommandBarActionDef>(); vsToolsOptionsMonitor.VsOptionsMightHaveChanged.Advise(lifetime, _ => cachedActionDefs.Clear()); }
/// <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 CommandHelper(System.IServiceProvider serviceProvider) { var rot = this.GetRunningObjectTable(); System.Runtime.InteropServices.ComTypes.IMoniker cmdDispatchMoniker = this.GetCmdDispatcherMoniker(); System.Runtime.InteropServices.ComTypes.IMoniker cmdNameMoniker = this.GetCmdNameMoniker(); var cmdDispatchObject = this.GetObjectFromRot(rot, cmdDispatchMoniker); var cmdNameObject = this.GetObjectFromRot(rot, cmdNameMoniker); if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } this.shellCmdTarget = (IOleCommandTarget)cmdDispatchObject; this.cmdNameMapping = (IVsCmdNameMapping)cmdNameObject; }
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."); } } } }
public ActionOverrideRegistrar(Lifetime lifetime, IActionManager actionManager, VsActionManager vsActionManager, IVsCmdNameMapping vsCmdNameMapping) { AddOverridingHandler(lifetime, actionManager, "QuickFix", new FsiFriendlyQuickFixActionHandler(vsActionManager, vsCmdNameMapping)); }
public FsiFriendlyQuickFixActionHandler(VsActionManager vsActionManager, IVsCmdNameMapping vsCmdNameMapping) { this.vsActionManager = vsActionManager; this.vsCmdNameMapping = vsCmdNameMapping; }