├── .gitignore ├── README.md ├── appveyor.yml ├── Tvl.DebugCommandLine ├── DebugCommandLineCommand.cs ├── DebugCommandLineCommandID.cs ├── DebugCommandLine.vsct ├── packages.config ├── source.extension.vsixmanifest ├── Properties │ └── AssemblyInfo.cs ├── VSPackage.resx ├── Tvl.DebugCommandLine.csproj └── DebugCommandLinePackage.cs ├── DebugCommandLine.sln └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Per-user files 2 | *.csproj.user 3 | *.suo 4 | 5 | # Temporary files created by the IDE 6 | *.sln.ide/ 7 | 8 | # NuGet packages 9 | packages/ 10 | 11 | # Build output 12 | bin/ 13 | obj/ 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Debug Command Line extension for Visual Studio 2012+ 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/76hlkncquan95idk/branch/master?svg=true)](https://ci.appveyor.com/project/sharwell/debugcommandline/branch/master) 4 | 5 | Provides a toolbar dropdown to quickly switch between recently used debugger command lines. 6 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | os: Visual Studio 2015 3 | configuration: Release 4 | platform: Any CPU 5 | init: 6 | - ps: git config --global core.autocrlf true 7 | before_build: 8 | - nuget restore 9 | build: 10 | verbosity: minimal 11 | artifacts: 12 | - path: '**\*.vsix' 13 | # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified 14 | cache: 15 | - packages -> **\packages.config 16 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/DebugCommandLineCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information. 3 | 4 | namespace Tvl.DebugCommandLine 5 | { 6 | using System.Runtime.InteropServices; 7 | 8 | /// 9 | /// This enumeration defines the commands that are provided by this extension. The GUID of this enumeration is the 10 | /// command group which these commands are assigned to. 11 | /// 12 | [Guid("B9B17AA7-66FB-4BEB-AE17-876222AE8390")] 13 | internal enum DebugCommandLineCommand 14 | { 15 | DebugCommandLineCombo = 0, 16 | DebugCommandLineComboGetList = 1, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/DebugCommandLineCommandID.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information. 3 | 4 | namespace Tvl.DebugCommandLine 5 | { 6 | using System.ComponentModel.Design; 7 | 8 | /// 9 | /// This class represents a command ID from the enumeration. 10 | /// 11 | internal class DebugCommandLineCommandID : CommandID 12 | { 13 | public DebugCommandLineCommandID(DebugCommandLineCommand command) 14 | : base(typeof(DebugCommandLineCommand).GUID, (int)command) 15 | { 16 | } 17 | 18 | public new DebugCommandLineCommand ID 19 | { 20 | get 21 | { 22 | return (DebugCommandLineCommand)base.ID; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DebugCommandLine.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tvl.DebugCommandLine", "Tvl.DebugCommandLine\Tvl.DebugCommandLine.csproj", "{EF5268F9-17D6-4814-A75E-461277C90706}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A4EBC846-EA67-4858-BA68-EC18DCF83A40}" 9 | ProjectSection(SolutionItems) = preProject 10 | appveyor.yml = appveyor.yml 11 | LICENSE.txt = LICENSE.txt 12 | README.md = README.md 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {EF5268F9-17D6-4814-A75E-461277C90706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {EF5268F9-17D6-4814-A75E-461277C90706}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {EF5268F9-17D6-4814-A75E-461277C90706}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {EF5268F9-17D6-4814-A75E-461277C90706}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/DebugCommandLine.vsct: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | DynamicVisibility 9 | DefaultInvisible 10 | CommandWellOnly 11 | 12 | Debug Command Line 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug Command Line 6 | Provides a toolbar dropdown to quickly switch between recently used debugger command lines. 7 | https://github.com/tunnelvisionlabs/DebugCommandLine 8 | LICENSE.txt 9 | 10 | 11 | https://github.com/tunnelvisionlabs/DebugCommandLine/releases/tag/2.3.0 12 | 13 | 14 | configuration, debugging 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information. 3 | 4 | using System; 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("Tvl.DebugCommandLine")] 12 | [assembly: AssemblyDescription("")] 13 | [assembly: AssemblyConfiguration("")] 14 | [assembly: AssemblyCompany("Tunnel Vision Laboratories, LLC")] 15 | [assembly: AssemblyProduct("Tvl.DebugCommandLine")] 16 | [assembly: AssemblyCopyright("Copyright © Sam Harwell 2015")] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | [assembly: CLSCompliant(false)] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | // The following GUID is for the ID of the typelib if this project is exposed to COM 27 | [assembly: Guid("dfaeea2b-3881-4498-8447-08c480be5fbb")] 28 | 29 | // Version information for an assembly consists of the following four values: 30 | // 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // 36 | // You can specify all the values or you can default the Build and Revision Numbers 37 | // by using the '*' as shown below: 38 | // [assembly: AssemblyVersion("1.0.*")] 39 | [assembly: AssemblyVersion("2.3.0.0")] 40 | [assembly: AssemblyFileVersion("2.3.0.0")] 41 | [assembly: AssemblyInformationalVersion("2.3.0-dev")] 42 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/VSPackage.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | text/microsoft-resx 91 | 92 | 93 | 1.3 94 | 95 | 96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 97 | 98 | 99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100 | 101 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/Tvl.DebugCommandLine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | AnyCPU 8 | {EF5268F9-17D6-4814-A75E-461277C90706} 9 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Library 11 | Properties 12 | Tvl.DebugCommandLine 13 | Tvl.DebugCommandLine 14 | v4.5 15 | 512 16 | true 17 | v3 18 | 19 | 20 | 25 | None 26 | 27 | 28 | 29 | Program 30 | $(DevEnvDir)\devenv.exe 31 | /rootSuffix Exp 32 | 33 | 34 | 35 | $(VisualStudioVersion) 36 | 37 | 38 | 39 | False 40 | 41 | 42 | true 43 | full 44 | false 45 | bin\Debug\ 46 | DEBUG;TRACE 47 | prompt 48 | 4 49 | 50 | 51 | pdbonly 52 | true 53 | bin\Release\ 54 | TRACE 55 | prompt 56 | 4 57 | 58 | 59 | 60 | False 61 | False 62 | ..\packages\VSSDK.DTE.7.0.4\lib\net20\envdte.dll 63 | 64 | 65 | False 66 | ..\packages\VSSDK.GraphModel.11.0.4\lib\net45\Microsoft.VisualStudio.GraphModel.dll 67 | 68 | 69 | False 70 | ..\packages\VSSDK.OLE.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.OLE.Interop.dll 71 | 72 | 73 | False 74 | ..\packages\VSSDK.Settings.11.11.0.4\lib\net40\Microsoft.VisualStudio.Settings.11.0.dll 75 | 76 | 77 | False 78 | ..\packages\VSSDK.Shell.11.11.0.4\lib\net45\Microsoft.VisualStudio.Shell.11.0.dll 79 | 80 | 81 | False 82 | ..\packages\VSSDK.Shell.Immutable.10.10.0.4\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll 83 | 84 | 85 | False 86 | ..\packages\VSSDK.Shell.Immutable.11.11.0.4\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll 87 | 88 | 89 | False 90 | ..\packages\VSSDK.Shell.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.dll 91 | 92 | 93 | False 94 | False 95 | ..\packages\VSSDK.Shell.Interop.10.10.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.10.0.dll 96 | 97 | 98 | False 99 | False 100 | ..\packages\VSSDK.Shell.Interop.11.11.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.11.0.dll 101 | 102 | 103 | False 104 | ..\packages\VSSDK.Shell.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.8.0.dll 105 | 106 | 107 | False 108 | ..\packages\VSSDK.Shell.Interop.9.9.0.4\lib\net20\Microsoft.VisualStudio.Shell.Interop.9.0.dll 109 | 110 | 111 | False 112 | ..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll 113 | 114 | 115 | False 116 | ..\packages\VSSDK.TextManager.Interop.8.8.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.8.0.dll 117 | 118 | 119 | 120 | 121 | False 122 | False 123 | ..\packages\VSSDK.DTE.7.0.4\lib\net20\stdole.dll 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | VSPackage 148 | true 149 | 150 | 151 | 152 | 153 | Menus.ctmenu 154 | 155 | 156 | 157 | 158 | 159 | 160 | LICENSE.txt 161 | true 162 | 163 | 164 | 165 | 166 | 167 | 168 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 169 | 170 | 171 | 172 | 173 | 174 | 181 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Tvl.DebugCommandLine/DebugCommandLinePackage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. 2 | // Licensed under the Apache License, Version 2.0. See LICENSE.txt in the project root for license information. 3 | 4 | namespace Tvl.DebugCommandLine 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Collections.ObjectModel; 9 | using System.ComponentModel.Design; 10 | using System.Linq; 11 | using System.Runtime.InteropServices; 12 | using Microsoft.VisualStudio; 13 | using Microsoft.VisualStudio.Settings; 14 | using Microsoft.VisualStudio.Shell; 15 | using Microsoft.VisualStudio.Shell.Interop; 16 | using Microsoft.VisualStudio.Shell.Settings; 17 | 18 | [PackageRegistration(UseManagedResourcesOnly = true)] 19 | [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)] 20 | [ProvideMenuResource("Menus.ctmenu", 1)] 21 | [Guid("238A874D-D659-4517-85D1-06B0E3CF4B7F")] 22 | internal class DebugCommandLinePackage : Package 23 | { 24 | private static readonly string[] KnownStartupProperties = { "CommandArguments", "StartArguments" }; 25 | private static readonly string SettingsCollectionName = "DebugCommandLine"; 26 | private static readonly string RecentCommandLinesCollectionName = SettingsCollectionName + @"\RecentCommandLines"; 27 | private static readonly int maxRecentCommandLineCount = 15; 28 | private WritableSettingsStore SettingsStore; 29 | 30 | private ReadOnlyCollection RecentCommandLines = new ReadOnlyCollection(new string[0]); 31 | 32 | protected override void Initialize() 33 | { 34 | base.Initialize(); 35 | 36 | OleMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; 37 | if (menuCommandService != null) 38 | { 39 | // This is the drop down combo box itself 40 | CommandID comboBoxCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineCombo); 41 | OleMenuCommand comboBoxCommand = new OleMenuCommand(HandleInvokeCombo, HandleChangeCombo, HandleBeforeQueryStatusCombo, comboBoxCommandID); 42 | menuCommandService.AddCommand(comboBoxCommand); 43 | 44 | // This is the special command to get the list of drop down items 45 | CommandID comboBoxGetListCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineComboGetList); 46 | OleMenuCommand comboBoxGetListCommand = new OleMenuCommand(HandleInvokeComboGetList, comboBoxGetListCommandID); 47 | menuCommandService.AddCommand(comboBoxGetListCommand); 48 | } 49 | 50 | var shellSettingsManager = new ShellSettingsManager(this); 51 | SettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); 52 | LoadSettings(); 53 | } 54 | 55 | private void LoadSettings() 56 | { 57 | var recentCommands = new List(RecentCommandLines); 58 | for (int i = 0; i < maxRecentCommandLineCount; i++) 59 | { 60 | if (!SettingsStore.PropertyExists(RecentCommandLinesCollectionName, i.ToString())) 61 | break; 62 | 63 | var commandLine = SettingsStore.GetString(RecentCommandLinesCollectionName, i.ToString()); 64 | recentCommands.Add(commandLine); 65 | } 66 | 67 | RecentCommandLines = new ReadOnlyCollection(recentCommands); 68 | } 69 | 70 | private void SaveSettings() 71 | { 72 | if (SettingsStore.CollectionExists(RecentCommandLinesCollectionName)) 73 | SettingsStore.DeleteCollection(RecentCommandLinesCollectionName); 74 | 75 | SettingsStore.CreateCollection(RecentCommandLinesCollectionName); 76 | for (int i = 0; i < RecentCommandLines.Count; i++) 77 | { 78 | SettingsStore.SetString(RecentCommandLinesCollectionName, i.ToString(), RecentCommandLines[i]); 79 | } 80 | } 81 | 82 | private void HandleInvokeCombo(object sender, EventArgs e) 83 | { 84 | OleMenuCmdEventArgs oleEventArgs = e as OleMenuCmdEventArgs; 85 | if (oleEventArgs == null) 86 | throw new ArgumentException("EventArgs required."); 87 | 88 | string newChoice = oleEventArgs.InValue as string; 89 | if (newChoice != null) 90 | { 91 | SetStartupCommandArguments(newChoice); 92 | SetMostRecentString(newChoice); 93 | } 94 | 95 | if (oleEventArgs.OutValue != IntPtr.Zero) 96 | { 97 | string commandArguments = TryGetStartupCommandArguments(); 98 | SetMostRecentString(commandArguments); 99 | Marshal.GetNativeVariantForObject(commandArguments, oleEventArgs.OutValue); 100 | return; 101 | } 102 | } 103 | 104 | private void HandleChangeCombo(object sender, EventArgs e) 105 | { 106 | } 107 | 108 | private void HandleBeforeQueryStatusCombo(object sender, EventArgs e) 109 | { 110 | OleMenuCommand command = sender as OleMenuCommand; 111 | if (command == null) 112 | return; 113 | 114 | DebugCommandLineCommandID commandID = command.CommandID as DebugCommandLineCommandID; 115 | if (commandID == null || commandID.ID != DebugCommandLineCommand.DebugCommandLineCombo) 116 | return; 117 | 118 | command.Supported = true; 119 | 120 | try 121 | { 122 | command.Enabled = !string.IsNullOrEmpty(TryGetStartupCommandArgumentsPropertyName()); 123 | } 124 | catch (Exception ex) 125 | { 126 | if (ErrorHandler.IsCriticalException(ex)) 127 | throw; 128 | 129 | command.Enabled = false; 130 | } 131 | } 132 | 133 | private void HandleInvokeComboGetList(object sender, EventArgs e) 134 | { 135 | OleMenuCmdEventArgs oleEventArgs = e as OleMenuCmdEventArgs; 136 | if (oleEventArgs == null) 137 | throw new ArgumentException("EventArgs required."); 138 | 139 | if (oleEventArgs.InValue != null) 140 | throw new ArgumentException(); 141 | 142 | if (oleEventArgs.OutValue == IntPtr.Zero) 143 | throw new ArgumentException(); 144 | 145 | Marshal.GetNativeVariantForObject(RecentCommandLines.ToArray(), oleEventArgs.OutValue); 146 | } 147 | 148 | private static EnvDTE.Properties TryGetDtePropertiesFromHierarchy(IVsHierarchy hierarchy) 149 | { 150 | try 151 | { 152 | EnvDTE.Project project = TryGetExtensibilityObject(hierarchy) as EnvDTE.Project; 153 | if (project == null) 154 | return null; 155 | 156 | EnvDTE.ConfigurationManager configurationManager = project.ConfigurationManager; 157 | if (configurationManager == null) 158 | return null; 159 | 160 | EnvDTE.Configuration activeConfiguration = configurationManager.ActiveConfiguration; 161 | if (activeConfiguration == null) 162 | return null; 163 | 164 | return activeConfiguration.Properties; 165 | } 166 | catch (Exception ex) 167 | { 168 | if (ErrorHandler.IsCriticalException(ex)) 169 | throw; 170 | 171 | return null; 172 | } 173 | } 174 | 175 | private static object TryGetExtensibilityObject(IVsHierarchy hierarchy, uint itemId = (uint)VSConstants.VSITEMID.Root) 176 | { 177 | try 178 | { 179 | object obj; 180 | int hr = hierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out obj); 181 | if (ErrorHandler.Failed(hr)) 182 | return null; 183 | 184 | return obj; 185 | } 186 | catch (Exception ex) 187 | { 188 | if (ErrorHandler.IsCriticalException(ex)) 189 | throw; 190 | 191 | return null; 192 | } 193 | } 194 | 195 | private EnvDTE.Properties TryGetStartupProjectProperties() 196 | { 197 | try 198 | { 199 | IVsSolutionBuildManager solutionBuildManager = GetGlobalService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager; 200 | if (solutionBuildManager == null) 201 | return null; 202 | 203 | IVsHierarchy startupProject; 204 | if (ErrorHandler.Failed(solutionBuildManager.get_StartupProject(out startupProject)) || startupProject == null) 205 | return null; 206 | 207 | EnvDTE.Properties properties = TryGetDtePropertiesFromHierarchy(startupProject); 208 | return properties; 209 | } 210 | catch (Exception ex) 211 | { 212 | if (ErrorHandler.IsCriticalException(ex)) 213 | throw; 214 | 215 | return null; 216 | } 217 | } 218 | 219 | private string TryGetStartupCommandArgumentsPropertyName() 220 | { 221 | try 222 | { 223 | EnvDTE.Properties properties = TryGetStartupProjectProperties(); 224 | if (properties == null) 225 | return null; 226 | 227 | return KnownStartupProperties.FirstOrDefault(i => properties.OfType().Any(property => string.Equals(i, property.Name, StringComparison.OrdinalIgnoreCase))); 228 | } 229 | catch (Exception ex) 230 | { 231 | if (ErrorHandler.IsCriticalException(ex)) 232 | throw; 233 | 234 | return null; 235 | } 236 | } 237 | 238 | private string TryGetStartupCommandArguments() 239 | { 240 | EnvDTE.Properties properties = TryGetStartupProjectProperties(); 241 | if (properties == null) 242 | return null; 243 | 244 | try 245 | { 246 | // Iterating over the properties has proven much more reliable than calling Item() 247 | foreach (EnvDTE.Property property in properties) 248 | { 249 | foreach (var propertyName in KnownStartupProperties) 250 | { 251 | if (string.Equals(propertyName, property.Name, StringComparison.OrdinalIgnoreCase)) 252 | { 253 | return property.Value as string; 254 | } 255 | } 256 | } 257 | 258 | return null; 259 | } 260 | catch (Exception ex) 261 | { 262 | if (ErrorHandler.IsCriticalException(ex)) 263 | throw; 264 | 265 | return null; 266 | } 267 | } 268 | 269 | private void SetStartupCommandArguments(string value) 270 | { 271 | EnvDTE.Properties properties = TryGetStartupProjectProperties(); 272 | if (properties == null) 273 | throw new NotSupportedException("No startup project is set, or it does not support setting properties."); 274 | 275 | // Iterating over the properties has proven much more reliable than calling Item() 276 | foreach (EnvDTE.Property property in properties) 277 | { 278 | foreach (var propertyName in KnownStartupProperties) 279 | { 280 | if (string.Equals(propertyName, property.Name, StringComparison.OrdinalIgnoreCase)) 281 | { 282 | property.Value = value ?? string.Empty; 283 | return; 284 | } 285 | } 286 | } 287 | 288 | throw new NotSupportedException("Could not identify the startup arguments property for the project."); 289 | } 290 | 291 | private void SetMostRecentString(string command) 292 | { 293 | List recentCommands = new List(RecentCommandLines); 294 | recentCommands.Remove(command); 295 | recentCommands.Insert(0, command); 296 | while (recentCommands.Count > maxRecentCommandLineCount) 297 | recentCommands.RemoveAt(recentCommands.Count - 1); 298 | 299 | RecentCommandLines = new ReadOnlyCollection(recentCommands); 300 | SaveSettings(); 301 | } 302 | } 303 | } 304 | --------------------------------------------------------------------------------