Skip to content

Commit

Permalink
feat: Add context menu command
Browse files Browse the repository at this point in the history
closes #8
  • Loading branch information
vchirikov committed Sep 11, 2019
1 parent a7d0cdc commit 0ed689d
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.8",
"version": "1.0.9",
"author": "Vladimir Chirikov",
"scripts": {
"install_tools": "npm install -g commitizen cz-conventional-changelog",
Expand Down
19 changes: 7 additions & 12 deletions src/GoToDnSpy/GoToDnSpy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ namespace GoToDnSpy
/// </summary>
internal sealed partial class GoToDnSpy
{
/// <summary>
/// Command ID.
/// </summary>
public const int CommandId = 0x0100;

/// <summary>
/// Command menu group (command set GUID).
/// </summary>
public static readonly Guid CommandSet = new Guid("4843d15e-dca8-4935-8ba3-66c4d25fb295");

/// <summary>
/// VS Package that provides this command, not null.
/// </summary>
Expand Down Expand Up @@ -90,9 +80,14 @@ private GoToDnSpy(Package package)

if (ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
// Add tools menu command
var menuCommandId = new CommandID(PackageGuids.guidGoToDnSpyPackageCmdSetMenu, PackageIds.GoToDnSpyId);
var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandId);
commandService.AddCommand(menuItem);
// Add editor context menu command (right click)
var ctxMenuCommand = new CommandID(PackageGuids.guidGoToDnSpyPackageCmdSetContextMenu, PackageIds.GoToDnSpyContextMenuId);
var ctxMenuItem = new MenuCommand(this.MenuItemCallback, ctxMenuCommand);
commandService.AddCommand(ctxMenuItem);
}

_statusBar = (IVsStatusbar)ServiceProvider.GetService(typeof(SVsStatusbar));
Expand Down
10 changes: 5 additions & 5 deletions src/GoToDnSpy/GoToDnSpy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<VSCTCompile Include="GoToDnSpyCommands.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
</VSCTCompile>
<Compile Update="GoToDnSpyCommands.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>GoToDnSpyCommands.vsct</DependentUpon>
</Compile>

<EmbeddedResource Update="source.extension.resx">
<DesignTime>True</DesignTime>
Expand All @@ -95,11 +100,6 @@

<!-- [Extensibility Tools generator](https://github.com/madskristensen/ExtensibilityTools) -->
<ItemGroup Label="Extensibility tools generators">
<Compile Update="GoToDnSpyCommands.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>GoToDnSpyCommands.vsct</DependentUpon>
</Compile>

<None Update="GoToDnSpyCommands.vsct">
<Generator>VsctGenerator</Generator>
Expand Down
17 changes: 12 additions & 5 deletions src/GoToDnSpy/GoToDnSpyCommands.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by Extensibility Tools v1.10.211
// This file was generated by VSIX Synchronizer
// </auto-generated>
// ------------------------------------------------------------------------------
namespace GoToDnSpy
Expand All @@ -13,11 +13,16 @@ namespace GoToDnSpy
internal sealed partial class PackageGuids
{
public const string guidGoToDnSpyPackageString = "c827298b-8d81-47c0-bed9-cdf072e68d4f";
public const string guidGoToDnSpyPackageCmdSetString = "4843d15e-dca8-4935-8ba3-66c4d25fb295";
public const string guidImagesString = "36462768-caed-442f-be73-841d637c2e3b";
public static Guid guidGoToDnSpyPackage = new Guid(guidGoToDnSpyPackageString);
public static Guid guidGoToDnSpyPackageCmdSet = new Guid(guidGoToDnSpyPackageCmdSetString);

public const string guidGoToDnSpyPackageCmdSetMenuString = "4843d15e-dca8-4935-8ba3-66c4d25fb295";
public static Guid guidGoToDnSpyPackageCmdSetMenu = new Guid(guidGoToDnSpyPackageCmdSetMenuString);

public const string guidImagesString = "36462768-caed-442f-be73-841d637c2e3b";
public static Guid guidImages = new Guid(guidImagesString);

public const string guidGoToDnSpyPackageCmdSetContextMenuString = "d5d8efc6-dc17-4229-9088-dddf76ac0ab3";
public static Guid guidGoToDnSpyPackageCmdSetContextMenu = new Guid(guidGoToDnSpyPackageCmdSetContextMenuString);
}
/// <summary>
/// Helper class that encapsulates all CommandIDs uses across VS Package.
Expand All @@ -27,5 +32,7 @@ internal sealed partial class PackageIds
public const int MyMenuGroup = 0x1020;
public const int GoToDnSpyId = 0x0100;
public const int ico = 0x0001;
public const int EditorContextMenuGroup = 0x3020;
public const int GoToDnSpyContextMenuId = 0x4020;
}
}
}
23 changes: 19 additions & 4 deletions src/GoToDnSpy/GoToDnSpyCommands.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@
group as the part of a menu contained between two lines. The parent of a group
must be a menu. -->
<Groups>
<Group guid="guidGoToDnSpyPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Group guid="guidGoToDnSpyPackageCmdSetMenu" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
<Group guid="guidGoToDnSpyPackageCmdSetContextMenu" id="EditorContextMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN" />
</Group>
</Groups>

<!--Buttons section. -->
Expand All @@ -52,8 +55,15 @@
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>DynamicVisibility</CommandFlag>
If you do not want an image next to your command, remove the Icon node /> -->
<Button guid="guidGoToDnSpyPackageCmdSet" id="GoToDnSpyId" priority="0x0100" type="Button">
<Parent guid="guidGoToDnSpyPackageCmdSet" id="MyMenuGroup" />
<Button guid="guidGoToDnSpyPackageCmdSetMenu" id="GoToDnSpyId" priority="0x0100" type="Button">
<Parent guid="guidGoToDnSpyPackageCmdSetMenu" id="MyMenuGroup" />
<Icon guid="guidImages" id="ico" />
<Strings>
<ButtonText>GoTo dnSpy...</ButtonText>
</Strings>
</Button>
<Button guid="guidGoToDnSpyPackageCmdSetContextMenu" id="GoToDnSpyContextMenuId" priority="0x0100" type="Button">
<Parent guid="guidGoToDnSpyPackageCmdSetContextMenu" id="EditorContextMenuGroup" />
<Icon guid="guidImages" id="ico" />
<Strings>
<ButtonText>GoTo dnSpy...</ButtonText>
Expand All @@ -77,13 +87,18 @@
<GuidSymbol name="guidGoToDnSpyPackage" value="{c827298b-8d81-47c0-bed9-cdf072e68d4f}" />

<!-- This is the guid used to group the menu commands together -->
<GuidSymbol name="guidGoToDnSpyPackageCmdSet" value="{4843d15e-dca8-4935-8ba3-66c4d25fb295}">
<GuidSymbol name="guidGoToDnSpyPackageCmdSetMenu" value="{4843d15e-dca8-4935-8ba3-66c4d25fb295}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="GoToDnSpyId" value="0x0100" />
</GuidSymbol>

<GuidSymbol name="guidImages" value="{36462768-caed-442f-be73-841d637c2e3b}" >
<IDSymbol name="ico" value="1" />
</GuidSymbol>

<GuidSymbol name="guidGoToDnSpyPackageCmdSetContextMenu" value="{d5d8efc6-dc17-4229-9088-dddf76ac0ab3}">
<IDSymbol value="0x3020" name="EditorContextMenuGroup" />
<IDSymbol value="0x4020" name="GoToDnSpyContextMenuId" />
</GuidSymbol>
</Symbols>
</CommandTable>
9 changes: 2 additions & 7 deletions src/GoToDnSpy/GoToDnSpyPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ namespace GoToDnSpy
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] // Info on this package for Help/About
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(GoToDnSpyPackage.PackageGuidString)]
[Guid(PackageGuids.guidGoToDnSpyPackageString)]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "pkgdef, VS and vsixmanifest are valid VS terms")]
[ProvideOptionPage(typeof(SettingsDialog), "GoTo dnSpy", "General", 0, 0, true)]
[ProvideOptionPage(typeof(SettingsDialog), "GoTo dnSpy", "General", 0, 0, supportsAutomation: true)]
public sealed class GoToDnSpyPackage : Package
{
/// <summary>
/// GoToDnSpyPackage GUID string.
/// </summary>
public const string PackageGuidString = "c827298b-8d81-47c0-bed9-cdf072e68d4f";

/// <summary>
/// Initializes a new instance of the <see cref="GoToDnSpy"/> class.
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions src/GoToDnSpy/MemberType.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace GoToDnSpy
{
enum MemberType
internal enum MemberType
{
Field,
Property,
Method,
Event,
Field = 0,
Property = 1,
Method = 2,
Event = 3,
}
}
10 changes: 10 additions & 0 deletions src/GoToDnSpy/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.ComponentModel;
using Microsoft.VisualStudio.Shell;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace GoToDnSpy
{
Expand All @@ -16,5 +17,14 @@ public class SettingsDialog : DialogPage
[DisplayName("dnSpy path")]
[Description("Path to dnSpy.exe. Example: C:\\dnSpy\\dnSpy.exe")]
public string DnSpyPath { get; set;}

/// <summary>
/// Mode was added recently in new version <see cref="DialogPage"/> ?
/// So this is workaround for removing it from settings property grid
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
public uint Mode => 1337;
}
}
7 changes: 1 addition & 6 deletions src/GoToDnSpy/source.extension.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This file was generated by Extensibility Tools v1.10.211
// </auto-generated>
// ------------------------------------------------------------------------------
namespace GoToDnSpy
{
static class Vsix
Expand All @@ -11,7 +6,7 @@ static class Vsix
public const string Name = "GoToDnSpy";
public const string Description = @"Open dnSpy and select method or type under caret.";
public const string Language = "en-US";
public const string Version = "1.0.8";
public const string Version = "1.0.9";
public const string Author = "Vladimir Chirikov";
public const string Tags = "GoToDnSpy, GoTo, Disasm, ILSpy, ILDisasm, Disassemble, CIL, IL, MSIL, dnSpy, de4dot, dnlib, decompile, Emit";
}
Expand Down
2 changes: 1 addition & 1 deletion src/GoToDnSpy/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="GoToDnSpy" Version="1.0.8" Language="en-US" Publisher="Vladimir Chirikov" />
<Identity Id="GoToDnSpy" Version="1.0.9" Language="en-US" Publisher="Vladimir Chirikov" />
<DisplayName>GoToDnSpy</DisplayName>
<Description xml:space="preserve">Open dnSpy and select method or type under caret.</Description>
<MoreInfo>https://github.com/vchirikov/GoToDnSpy</MoreInfo>
Expand Down

0 comments on commit 0ed689d

Please sign in to comment.