From ffbfb6f42b3da8777a5c31135a0c214e7167f75f Mon Sep 17 00:00:00 2001 From: William Forney Date: Tue, 12 Nov 2013 03:55:18 -0800 Subject: [PATCH 1/3] Updated project to build in VS 2013. --- Backup/AttachToPackage.cs | 53 ++++++ Backup/GeneralOptionsPage.cs | 33 ++++ Backup/Guids.cs | 15 ++ Backup/PkgCmdID.cs | 14 ++ Backup/Whut.AttachTo.csproj | 183 ++++++++++++++++++++ Whut.AttachTo/AttachTo.vsct | 12 +- Whut.AttachTo/AttachToPackage.cs | 101 ++++++++--- Whut.AttachTo/GeneralOptionsPage.cs | 37 +++- Whut.AttachTo/Guids.cs | 22 ++- Whut.AttachTo/PkgCmdID.cs | 20 ++- Whut.AttachTo/Resources.Designer.cs | 5 +- Whut.AttachTo/Whut.AttachTo.csproj | 132 +++++++++++++- Whut.AttachTo/source.extension.vsixmanifest | 6 + 13 files changed, 581 insertions(+), 52 deletions(-) create mode 100644 Backup/AttachToPackage.cs create mode 100644 Backup/GeneralOptionsPage.cs create mode 100644 Backup/Guids.cs create mode 100644 Backup/PkgCmdID.cs create mode 100644 Backup/Whut.AttachTo.csproj diff --git a/Backup/AttachToPackage.cs b/Backup/AttachToPackage.cs new file mode 100644 index 0000000..05d10ad --- /dev/null +++ b/Backup/AttachToPackage.cs @@ -0,0 +1,53 @@ +using System; +using System.ComponentModel.Design; +using System.Linq; +using System.Runtime.InteropServices; +using EnvDTE; +using Microsoft.VisualStudio; +using Microsoft.VisualStudio.Shell; + +namespace Whut.AttachTo +{ + //// This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is a package. + [PackageRegistration(UseManagedResourcesOnly = true)] + //// This attribute is used to register the informations needed to show the this package in the Help/About dialog of Visual Studio. + [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] + //// This attribute is needed to let the shell know that this package exposes some menus. + [ProvideMenuResource("Menus.ctmenu", 1)] + [Guid(GuidList.guidAttachToPkgString)] + [ProvideOptionPage(typeof(GeneralOptionsPage), "Whut.AttachTo", "General", 110, 120, false)] + [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string)] + [ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)] + public sealed class AttachToPackage : Package + { + protected override void Initialize() + { + base.Initialize(); + + OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + + this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToIIS, gop => gop.ShowAttachToIIS, "w3wp.exe"); + this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToIISExpress, gop => gop.ShowAttachToIISExpress, "iisexpress.exe"); + this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToNUnit, gop => gop.ShowAttachToNUnit, "nunit-agent.exe", "nunit.exe", "nunit-console.exe", "nunit-agent-x86.exe", "nunit-x86.exe", "nunit-console-x86.exe"); + } + + private void AddAttachToCommand(OleMenuCommandService mcs, uint commandId, Func isVisible, params string[] programsToAttach) + { + OleMenuCommand menuItemCommand = new OleMenuCommand( + delegate(object sender, EventArgs e) + { + DTE dte = (DTE)this.GetService(typeof(DTE)); + foreach (Process process in dte.Debugger.LocalProcesses) + { + if (programsToAttach.Any(p => process.Name.EndsWith(p))) + { + process.Attach(); + } + } + }, + new CommandID(GuidList.guidAttachToCmdSet, (int)commandId)); + menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)this.GetDialogPage(typeof(GeneralOptionsPage))); + mcs.AddCommand(menuItemCommand); + } + } +} diff --git a/Backup/GeneralOptionsPage.cs b/Backup/GeneralOptionsPage.cs new file mode 100644 index 0000000..c0d32b3 --- /dev/null +++ b/Backup/GeneralOptionsPage.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; +using Microsoft.VisualStudio.Shell; + +namespace Whut.AttachTo +{ + public class GeneralOptionsPage : DialogPage + { + public GeneralOptionsPage() + { + this.ShowAttachToIIS = true; + this.ShowAttachToIISExpress = true; + this.ShowAttachToNUnit = true; + } + + [Category("General")] + [DisplayName("Show 'Attach to IIS' command")] + [Description("Show 'Attach to IIS' command in Tools menu.")] + [DefaultValue(true)] + public bool ShowAttachToIIS { get; set; } + + [Category("General")] + [DisplayName("Show 'Attach to IIS Express command")] + [Description("Show 'Attach to IIS Express command in Tools menu.")] + [DefaultValue(true)] + public bool ShowAttachToIISExpress { get; set; } + + [Category("General")] + [DisplayName("Show 'Attach to NUnit' command")] + [Description("Show 'Attach to NUnit' command in Tools menu.")] + [DefaultValue(true)] + public bool ShowAttachToNUnit { get; set; } + } +} diff --git a/Backup/Guids.cs b/Backup/Guids.cs new file mode 100644 index 0000000..e609719 --- /dev/null +++ b/Backup/Guids.cs @@ -0,0 +1,15 @@ +// Guids.cs +// MUST match guids.h +using System; + +namespace Whut.AttachTo +{ + public static class GuidList + { + public const string guidAttachToPkgString = "8d6080f0-7276-44d7-8dc4-6378fb6ce225"; + + public const string guidAttachToCmdSetString = "16e2ac5c-ec3d-4ff1-a237-11ccef54fe0f"; + + public static readonly Guid guidAttachToCmdSet = new Guid(guidAttachToCmdSetString); + } +} \ No newline at end of file diff --git a/Backup/PkgCmdID.cs b/Backup/PkgCmdID.cs new file mode 100644 index 0000000..31154ed --- /dev/null +++ b/Backup/PkgCmdID.cs @@ -0,0 +1,14 @@ +// PkgCmdID.cs +// MUST match PkgCmdID.h + +namespace Whut.AttachTo +{ + public static class PkgCmdIDList + { + public const uint cmdidWhutAttachToIIS = 0x100; + + public const uint cmdidWhutAttachToIISExpress = 0x101; + + public const uint cmdidWhutAttachToNUnit = 0x102; + } +} \ No newline at end of file diff --git a/Backup/Whut.AttachTo.csproj b/Backup/Whut.AttachTo.csproj new file mode 100644 index 0000000..e007f33 --- /dev/null +++ b/Backup/Whut.AttachTo.csproj @@ -0,0 +1,183 @@ + + + + Debug + AnyCPU + 2.0 + {557B4FF9-0BBA-4631-9101-FA5DF4D519A3} + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + Whut.AttachTo + AttachTo + True + Key.snk + v4.0 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + + + + + + + + + false + + + + + + + + + + + + + {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2} + 8 + 0 + 0 + primary + False + False + + + {26AD1324-4B7C-44BC-84F8-B86AED45729F} + 10 + 0 + 0 + primary + False + False + + + {1A31287A-4D7D-413E-8E32-3B374931BD89} + 8 + 0 + 0 + primary + False + False + + + {2CE2370E-D744-4936-A090-3FFFE667B0E1} + 9 + 0 + 0 + primary + False + False + + + {1CBA492E-7263-47BB-87FE-639000619B15} + 8 + 0 + 0 + primary + False + False + + + {00020430-0000-0000-C000-000000000046} + 2 + 0 + 0 + primary + False + False + + + + + Component + + + + True + True + Resources.resx + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + true + VSPackage + + + + + Designer + + + + + + + + Menus.ctmenu + + + + + + + + + license.txt + Always + true + + + true + Always + + + + true + + + + + + Program + <_VisualStudioInstallDir>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\InstallDir) + $(_VisualStudioInstallDir)devenv.exe + /rootsuffix Exp + + \ No newline at end of file diff --git a/Whut.AttachTo/AttachTo.vsct b/Whut.AttachTo/AttachTo.vsct index 3bde0b6..206cb30 100755 --- a/Whut.AttachTo/AttachTo.vsct +++ b/Whut.AttachTo/AttachTo.vsct @@ -15,13 +15,13 @@ defining some of the constants that we will use inside the file. --> - + - + - + @@ -40,7 +40,7 @@ must be a menu. --> - + @@ -93,7 +93,7 @@ bitmap strip containing the bitmaps and then there are the numeric ids of the elements used inside a button definition. An important aspect of this declaration is that the element id must be the actual index (1-based) of the bitmap inside the bitmap strip. --> - + @@ -109,7 +109,7 @@ - + diff --git a/Whut.AttachTo/AttachToPackage.cs b/Whut.AttachTo/AttachToPackage.cs index 05d10ad..cd675bb 100755 --- a/Whut.AttachTo/AttachToPackage.cs +++ b/Whut.AttachTo/AttachToPackage.cs @@ -1,16 +1,22 @@ -using System; -using System.ComponentModel.Design; -using System.Linq; -using System.Runtime.InteropServices; -using EnvDTE; -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Shell; - -namespace Whut.AttachTo +namespace Whut.AttachTo { + using System; + using System.ComponentModel.Design; + using System.Diagnostics.Contracts; + using System.Linq; + using System.Runtime.InteropServices; + + using EnvDTE; + + using Microsoft.VisualStudio; + using Microsoft.VisualStudio.Shell; + + /// + /// Class AttachToPackage. This class cannot be inherited. + /// //// This attribute tells the PkgDef creation utility (CreatePkgDef.exe) that this class is a package. [PackageRegistration(UseManagedResourcesOnly = true)] - //// This attribute is used to register the informations needed to show the this package in the Help/About dialog of Visual Studio. + //// This attribute is used to register the information needed to show the this package in the Help/About dialog of Visual Studio. [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] //// This attribute is needed to let the shell know that this package exposes some menus. [ProvideMenuResource("Menus.ctmenu", 1)] @@ -20,34 +26,77 @@ namespace Whut.AttachTo [ProvideAutoLoad(VSConstants.UICONTEXT.NoSolution_string)] public sealed class AttachToPackage : Package { + #region Methods + + /// + /// Initializes this instance. + /// protected override void Initialize() { base.Initialize(); - OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + var oleMenuCommandService = this.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; - this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToIIS, gop => gop.ShowAttachToIIS, "w3wp.exe"); - this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToIISExpress, gop => gop.ShowAttachToIISExpress, "iisexpress.exe"); - this.AddAttachToCommand(mcs, PkgCmdIDList.cmdidWhutAttachToNUnit, gop => gop.ShowAttachToNUnit, "nunit-agent.exe", "nunit.exe", "nunit-console.exe", "nunit-agent-x86.exe", "nunit-x86.exe", "nunit-console-x86.exe"); + this.AddAttachToCommand(oleMenuCommandService, PkgCmdIDList.cmdidWhutAttachToIIS, gop => gop.ShowAttachToIIS, "w3wp.exe"); + this.AddAttachToCommand( + oleMenuCommandService, + PkgCmdIDList.cmdidWhutAttachToIISExpress, + gop => gop.ShowAttachToIISExpress, + "iisexpress.exe"); + this.AddAttachToCommand( + oleMenuCommandService, + PkgCmdIDList.cmdidWhutAttachToNUnit, + gop => gop.ShowAttachToNUnit, + "nunit-agent.exe", + "nunit.exe", + "nunit-console.exe", + "nunit-agent-x86.exe", + "nunit-x86.exe", + "nunit-console-x86.exe"); } - private void AddAttachToCommand(OleMenuCommandService mcs, uint commandId, Func isVisible, params string[] programsToAttach) + /// + /// Adds the attach automatic command. + /// + /// + /// The MCS. + /// + /// + /// The command unique identifier. + /// + /// + /// The is visible. + /// + /// + /// The programs automatic attach. + /// + private void AddAttachToCommand( + OleMenuCommandService oleMenuCommandService, + uint commandId, + Func isVisible, + params string[] programsToAttach) { - OleMenuCommand menuItemCommand = new OleMenuCommand( - delegate(object sender, EventArgs e) - { - DTE dte = (DTE)this.GetService(typeof(DTE)); - foreach (Process process in dte.Debugger.LocalProcesses) + Contract.Requires(oleMenuCommandService != null); + + var menuItemCommand = new OleMenuCommand( + delegate { - if (programsToAttach.Any(p => process.Name.EndsWith(p))) + var dte = (DTE)this.GetService(typeof(DTE)); + foreach ( + var process in + dte.Debugger.LocalProcesses.Cast() + .Where(process => programsToAttach.Any(p => process.Name.EndsWith(p)))) { process.Attach(); } - } - }, + }, new CommandID(GuidList.guidAttachToCmdSet, (int)commandId)); - menuItemCommand.BeforeQueryStatus += (s, e) => menuItemCommand.Visible = isVisible((GeneralOptionsPage)this.GetDialogPage(typeof(GeneralOptionsPage))); - mcs.AddCommand(menuItemCommand); + menuItemCommand.BeforeQueryStatus += + (s, e) => + menuItemCommand.Visible = isVisible((GeneralOptionsPage)this.GetDialogPage(typeof(GeneralOptionsPage))); + oleMenuCommandService.AddCommand(menuItemCommand); } + + #endregion } -} +} \ No newline at end of file diff --git a/Whut.AttachTo/GeneralOptionsPage.cs b/Whut.AttachTo/GeneralOptionsPage.cs index c0d32b3..7181fe4 100755 --- a/Whut.AttachTo/GeneralOptionsPage.cs +++ b/Whut.AttachTo/GeneralOptionsPage.cs @@ -1,10 +1,19 @@ -using System.ComponentModel; -using Microsoft.VisualStudio.Shell; - -namespace Whut.AttachTo +namespace Whut.AttachTo { + using System.ComponentModel; + + using Microsoft.VisualStudio.Shell; + + /// + /// Class GeneralOptionsPage. + /// public class GeneralOptionsPage : DialogPage { + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// public GeneralOptionsPage() { this.ShowAttachToIIS = true; @@ -12,22 +21,40 @@ public GeneralOptionsPage() this.ShowAttachToNUnit = true; } + #endregion + + #region Public Properties + + /// + /// Gets or sets a value indicating whether [show attach automatic IIS]. + /// + /// true if [show attach automatic IIS]; otherwise, false. [Category("General")] [DisplayName("Show 'Attach to IIS' command")] [Description("Show 'Attach to IIS' command in Tools menu.")] [DefaultValue(true)] public bool ShowAttachToIIS { get; set; } + /// + /// Gets or sets a value indicating whether [show attach automatic IIS express]. + /// + /// true if [show attach automatic IIS express]; otherwise, false. [Category("General")] [DisplayName("Show 'Attach to IIS Express command")] [Description("Show 'Attach to IIS Express command in Tools menu.")] [DefaultValue(true)] public bool ShowAttachToIISExpress { get; set; } + /// + /// Gets or sets a value indicating whether [show attach automatic asynchronous unit]. + /// + /// true if [show attach automatic asynchronous unit]; otherwise, false. [Category("General")] [DisplayName("Show 'Attach to NUnit' command")] [Description("Show 'Attach to NUnit' command in Tools menu.")] [DefaultValue(true)] public bool ShowAttachToNUnit { get; set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Whut.AttachTo/Guids.cs b/Whut.AttachTo/Guids.cs index e609719..e1fa059 100755 --- a/Whut.AttachTo/Guids.cs +++ b/Whut.AttachTo/Guids.cs @@ -1,15 +1,27 @@ -// Guids.cs -// MUST match guids.h -using System; - -namespace Whut.AttachTo +namespace Whut.AttachTo { + // Guids.cs + // MUST match guids.h + using System; + + /// + /// Class GuidList. + /// public static class GuidList { + /// + /// The unique identifier attach automatic PKG string + /// public const string guidAttachToPkgString = "8d6080f0-7276-44d7-8dc4-6378fb6ce225"; + /// + /// The unique identifier attach automatic command set string + /// public const string guidAttachToCmdSetString = "16e2ac5c-ec3d-4ff1-a237-11ccef54fe0f"; + /// + /// The unique identifier attach automatic command set + /// public static readonly Guid guidAttachToCmdSet = new Guid(guidAttachToCmdSetString); } } \ No newline at end of file diff --git a/Whut.AttachTo/PkgCmdID.cs b/Whut.AttachTo/PkgCmdID.cs index 31154ed..b24b511 100755 --- a/Whut.AttachTo/PkgCmdID.cs +++ b/Whut.AttachTo/PkgCmdID.cs @@ -1,14 +1,26 @@ -// PkgCmdID.cs -// MUST match PkgCmdID.h - -namespace Whut.AttachTo +namespace Whut.AttachTo { + // PkgCmdID.cs + // MUST match PkgCmdID.h + + /// + /// Class PkgCmdIDList. + /// public static class PkgCmdIDList { + /// + /// The cmdid whut attach automatic IIS + /// public const uint cmdidWhutAttachToIIS = 0x100; + /// + /// The cmdid whut attach automatic IIS express + /// public const uint cmdidWhutAttachToIISExpress = 0x101; + /// + /// The cmdid whut attach automatic asynchronous unit + /// public const uint cmdidWhutAttachToNUnit = 0x102; } } \ No newline at end of file diff --git a/Whut.AttachTo/Resources.Designer.cs b/Whut.AttachTo/Resources.Designer.cs index 4de098e..b14960b 100755 --- a/Whut.AttachTo/Resources.Designer.cs +++ b/Whut.AttachTo/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:4.0.30319.34003 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace Whut.AttachTo { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -59,6 +59,5 @@ internal Resources() { resourceCulture = value; } } - } } diff --git a/Whut.AttachTo/Whut.AttachTo.csproj b/Whut.AttachTo/Whut.AttachTo.csproj index e007f33..65824ce 100755 --- a/Whut.AttachTo/Whut.AttachTo.csproj +++ b/Whut.AttachTo/Whut.AttachTo.csproj @@ -1,5 +1,6 @@  - + + Debug AnyCPU @@ -12,7 +13,30 @@ AttachTo True Key.snk - v4.0 + v4.5 + 12.0 + + + + + 4.0 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + 1 true @@ -22,6 +46,44 @@ DEBUG;TRACE prompt 4 + false + bin\Debug\AttachTo.XML + true + True + False + False + True + False + True + True + True + True + True + False + True + True + True + True + False + True + True + True + True + False + False + + + + + + + + False + False + Full + DoNotBuild + 0 + x86 pdbonly @@ -31,6 +93,43 @@ prompt 4 true + false + bin\Release\AttachTo.XML + True + False + False + True + True + True + True + True + False + True + True + True + True + False + True + True + True + True + False + False + + + + + + + + False + False + Full + DoNotBuild + 0 + True + False + x86 @@ -162,11 +261,38 @@ Always + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 4.5 + true + + true + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + - + + - - Program - <_VisualStudioInstallDir>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\InstallDir) - $(_VisualStudioInstallDir)devenv.exe - /rootsuffix Exp - - \ No newline at end of file From 18d7c83b4764ed9b596448444bec93ceeb7e8d34 Mon Sep 17 00:00:00 2001 From: William Forney Date: Fri, 15 Nov 2013 04:57:50 -0800 Subject: [PATCH 3/3] Updated icons with default VS project icons from VS2013. Tweaked some things, added PostSharp for tracing. --- Whut.AttachTo/AttachTo.vsct | 5 +- Whut.AttachTo/AttachToPackage.cs | 67 +++++++-- Whut.AttachTo/Attributes/TraceAttribute.cs | 133 ++++++++++++++++++ Whut.AttachTo/Properties/AssemblyInfo.cs | 9 +- .../{ => Properties}/Resources.Designer.cs | 4 +- Whut.AttachTo/{ => Properties}/Resources.resx | 0 Whut.AttachTo/RequiresPostSharp.cs | 11 ++ Whut.AttachTo/Resources/Images.png | Bin 0 -> 994 bytes Whut.AttachTo/Resources/Images_32bit.bmp | Bin 5176 -> 0 bytes Whut.AttachTo/Whut.AttachTo.csproj | 26 +++- Whut.AttachTo/Whut.AttachTo.psproj | 8 ++ Whut.AttachTo/packages.config | 5 + Whut.AttachTo/source.extension.vsixmanifest | 3 - 13 files changed, 248 insertions(+), 23 deletions(-) create mode 100644 Whut.AttachTo/Attributes/TraceAttribute.cs rename Whut.AttachTo/{ => Properties}/Resources.Designer.cs (94%) mode change 100755 => 100644 rename Whut.AttachTo/{ => Properties}/Resources.resx (100%) mode change 100755 => 100644 create mode 100644 Whut.AttachTo/RequiresPostSharp.cs create mode 100644 Whut.AttachTo/Resources/Images.png delete mode 100755 Whut.AttachTo/Resources/Images_32bit.bmp create mode 100644 Whut.AttachTo/Whut.AttachTo.psproj create mode 100644 Whut.AttachTo/packages.config diff --git a/Whut.AttachTo/AttachTo.vsct b/Whut.AttachTo/AttachTo.vsct index 206cb30..516a59d 100755 --- a/Whut.AttachTo/AttachTo.vsct +++ b/Whut.AttachTo/AttachTo.vsct @@ -74,7 +74,7 @@ Attach to IIS Express - +