Permalink
Browse files

Add menu command for Go To Defnition - Native

This commit contains the bare minimum changes
necessary to make the menu item show up.  The
implementation will come in the next commit.
  • Loading branch information...
SLaks committed Aug 26, 2014
1 parent a71bd37 commit 6ce75a4d7f4bfde5c3c51073ebb9db97baa67f42
Showing with 155 additions and 1 deletion.
  1. +11 −1 Ref12/Ref12.csproj
  2. +25 −0 Ref12/Ref12.vsct
  3. +17 −0 Ref12/Ref12Package.cs
  4. +101 −0 Ref12/VSPackage.resx
  5. +1 −0 Ref12/source.extension.vsixmanifest
View
@@ -30,7 +30,6 @@
<AssemblyName>Ref12</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<GeneratePkgDefFile>false</GeneratePkgDefFile>
<ReferencePath>$(ReferencePath);$(MSBuildThisFileDirectory)..\References\v10.0</ReferencePath>
<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)\devenv.exe</StartProgram>
@@ -104,6 +103,7 @@
<Compile Include="Commands\TextViewListener.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Ref12Package.cs" />
<Compile Include="RoslynUtilities.cs" />
<Compile Include="Services\ILogger.cs" />
<Compile Include="Services\CSharp12Resolver.cs" />
@@ -119,6 +119,13 @@
</None>
</ItemGroup>
<ItemGroup>
<VSCTCompile Include="Ref12.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
</VSCTCompile>
<EmbeddedResource Include="VSPackage.resx">
<MergeWithCTO>true</MergeWithCTO>
<ManifestResourceName>VSPackage</ManifestResourceName>
</EmbeddedResource>
<Content Include="Resources\Ref12-200.png">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
@@ -136,6 +143,9 @@
<Name>Ref12.Unversioned</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<UseCodebase>true</UseCodebase>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="PackageGuid">
<Buttons>
<Button guid="CommandsGuid" id="GoToNativeDefinition" priority="0x0101" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_CODEWIN_NAVIGATETOLOCATION"/>
<Icon guid="guidObjectBrowserButtons" id="15"/>
<Strings>
<ButtonText>Go To Definition - &amp;Native</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
<Symbols>
<GuidSymbol name="PackageGuid" value="{7E85FEAF-1785-4BE8-8E0C-0B4C55A97851}" />
<GuidSymbol name="CommandsGuid" value="{BD27207E-0A63-4C87-A111-D226F1C22EE3}">
<IDSymbol name="GoToNativeDefinition" value="0" />
</GuidSymbol>
</Symbols>
</CommandTable>
View
@@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
namespace SLaks.Ref12 {
// These GUIDS and command IDs must match the VSCT.
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid("7E85FEAF-1785-4BE8-8E0C-0B4C55A97851")]
[PackageRegistration(UseManagedResourcesOnly = true)]
class Ref12Package : Package {
}
[Guid("BD27207E-0A63-4C87-A111-D226F1C22EE3")]
enum Ref12Command {
GoToDefinitionNative = 0
}
}
View
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -24,5 +24,6 @@
</Identifier>
<Content>
<MefComponent>|%CurrentProject%|</MefComponent>
<VsPackage>|%CurrentProject%;PkgdefProjectOutputGroup|</VsPackage>
</Content>
</Vsix>

15 comments on commit 6ce75a4

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

Has this been updated for VS 2015, the 2015 vsixmanifest file looks nothing like this example, at least for VB.

paul1956 replied Sep 21, 2015

Has this been updated for VS 2015, the 2015 vsixmanifest file looks nothing like this example, at least for VB.

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 21, 2015

Owner

What do you mean?
I published this to the gallery a while ago.

Note that my extensions use VSIX v1, for compatibility with VS2010.

Owner

SLaks replied Sep 21, 2015

What do you mean?
I published this to the gallery a while ago.

Note that my extensions use VSIX v1, for compatibility with VS2010.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

I am trying to follow it for VS2015 using Visual Basic and can't map the instructions but I don't think it is because I am using VB.. The vsixmanifest file does not have entries (Identifier, Content, MefComponent). from your example.

paul1956 replied Sep 21, 2015

I am trying to follow it for VS2015 using Visual Basic and can't map the instructions but I don't think it is because I am using VB.. The vsixmanifest file does not have entries (Identifier, Content, MefComponent). from your example.

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 21, 2015

Owner

You mean you're trying to add a menu command to a MEF-only VSIX?

You're having trouble because I'm using VSIX v1, whereas you're probably using VSIX v2 (the language is completely irrelevant).
You should be able to add the VsPackage / Pkgdef content from the VSIX v2 designer; IIRC, it's one of the entries in the dropdown.

Owner

SLaks replied Sep 21, 2015

You mean you're trying to add a menu command to a MEF-only VSIX?

You're having trouble because I'm using VSIX v1, whereas you're probably using VSIX v2 (the language is completely irrelevant).
You should be able to add the VsPackage / Pkgdef content from the VSIX v2 designer; IIRC, it's one of the entries in the dropdown.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

I am trying to add a menu to an Analyzer that is delivered through a VSIX. The VSIX file references a VB project in the some Solution. Don't know what "VSIX v2 designer; IIRC" is but I think you are saying that I can add a "menu item" to Visual Studio 2015 directly within Visual Studio without manually editing. I did try to add a "Command Item" directly to the VXIS project, but got over 300 errors just from adding the item which lead me to your post looking for an example..

paul1956 replied Sep 21, 2015

I am trying to add a menu to an Analyzer that is delivered through a VSIX. The VSIX file references a VB project in the some Solution. Don't know what "VSIX v2 designer; IIRC" is but I think you are saying that I can add a "menu item" to Visual Studio 2015 directly within Visual Studio without manually editing. I did try to add a "Command Item" directly to the VXIS project, but got over 300 errors just from adding the item which lead me to your post looking for an example..

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 21, 2015

Owner

Show me your VSIX manifest.

The non-code changes in this commit (VSIX manifest and GeneratePkgDefFile) do not affect compilation; they're just necessary to get VS to actually load the menu item.

If you 're getting compilation errors, you're probably missing some assembly references.
What errors are you getting?

Other than the differences between a v2 VSIX and a v1 VSIX, you should do exactly what I did in this commit, and that should make a menu item appear.

Owner

SLaks replied Sep 21, 2015

Show me your VSIX manifest.

The non-code changes in this commit (VSIX manifest and GeneratePkgDefFile) do not affect compilation; they're just necessary to get VS to actually load the menu item.

If you 're getting compilation errors, you're probably missing some assembly references.
What errors are you getting?

Other than the differences between a v2 VSIX and a v1 VSIX, you should do exactly what I did in this commit, and that should make a menu item appear.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

Actual it is 381 warnings in ControlName.vb, ControlNamePackage.vb that were added to the VSIX project. The warnings are "Type or namespace definition or end-of-line expected", "Newline in Comment", "Type Expected" , "Too many characters in character literal"., "Comma Expected". None of which make any sense in a VB file. If I move these files to a VB project most of the errors disappear and the ones that are left are all correct..

<?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="Pure_Visual_Basic_Refactoring.Vsix..ac920cbf-a241-4baa-a5d7-5b3b8661ecb9" Version="1.0" Language="en-US" Publisher="Paul M Cohen" />
    <DisplayName>Pure Visual Basic Refactoring</DisplayName>
    <Description xml:space="preserve">This is a Code Refactoring and Analyzer written in Visual Basic by Paul M Cohen</Description>
    <License>LICENSE.txt</License>
    <Icon>ms_visual_basic_express.png</Icon>
    <Tags>Refactoring, code analysis, analyzer, Roslyn, VB.NET</Tags>
  </Metadata>
  <Installation>
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.Pro" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VWDExpress" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinExpress" />
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5.2,)" />
    <Dependency Id="Microsoft.VisualStudio.MPF.14.0" DisplayName="Visual Studio MPF 14.0" d:Source="Installed" Version="[14.0]" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Pure_Visual_Basic_Refactoring" Path="|Pure_Visual_Basic_Refactoring|" />
    <Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="Pure_Visual_Basic_Refactoring" Path="|Pure_Visual_Basic_Refactoring|" />
    <Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
  </Assets>
</PackageManifest>

paul1956 replied Sep 21, 2015

Actual it is 381 warnings in ControlName.vb, ControlNamePackage.vb that were added to the VSIX project. The warnings are "Type or namespace definition or end-of-line expected", "Newline in Comment", "Type Expected" , "Too many characters in character literal"., "Comma Expected". None of which make any sense in a VB file. If I move these files to a VB project most of the errors disappear and the ones that are left are all correct..

<?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="Pure_Visual_Basic_Refactoring.Vsix..ac920cbf-a241-4baa-a5d7-5b3b8661ecb9" Version="1.0" Language="en-US" Publisher="Paul M Cohen" />
    <DisplayName>Pure Visual Basic Refactoring</DisplayName>
    <Description xml:space="preserve">This is a Code Refactoring and Analyzer written in Visual Basic by Paul M Cohen</Description>
    <License>LICENSE.txt</License>
    <Icon>ms_visual_basic_express.png</Icon>
    <Tags>Refactoring, code analysis, analyzer, Roslyn, VB.NET</Tags>
  </Metadata>
  <Installation>
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.Pro" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VWDExpress" />
    <InstallationTarget Version="[14.0,]" Id="Microsoft.VisualStudio.VSWinExpress" />
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5.2,)" />
    <Dependency Id="Microsoft.VisualStudio.MPF.14.0" DisplayName="Visual Studio MPF 14.0" d:Source="Installed" Version="[14.0]" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="Pure_Visual_Basic_Refactoring" Path="|Pure_Visual_Basic_Refactoring|" />
    <Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="Pure_Visual_Basic_Refactoring" Path="|Pure_Visual_Basic_Refactoring|" />
    <Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
  </Assets>
</PackageManifest>
@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 21, 2015

Owner

The Asset Type="Microsoft.VisualStudio.VsPackage is exactly what you need.

It sounds like you're adding a VB file to a C# project.
Change your project type.

Owner

SLaks replied Sep 21, 2015

The Asset Type="Microsoft.VisualStudio.VsPackage is exactly what you need.

It sounds like you're adding a VB file to a C# project.
Change your project type.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

The VSIX project includies the line below but I have never seen this line is a VB Project file and all the errors match exactly what you would get if you add the VB files in a C# project and rename them to .cs.

paul1956 replied Sep 21, 2015

The VSIX project includies the line below but I have never seen this line is a VB Project file and all the errors match exactly what you would get if you add the VB files in a C# project and rename them to .cs.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

I have nothing in C# but something is assuming that files in a VSIX project are C# even if they have a .VB extension. How to I change a project type for something that Visual Studio created automatically. If I include the two fines in a C# project I actually don't get the errors and Visual Studio seems to understand they are VB (I didn't try to actual compile).

paul1956 replied Sep 21, 2015

I have nothing in C# but something is assuming that files in a VSIX project are C# even if they have a .VB extension. How to I change a project type for something that Visual Studio created automatically. If I include the two fines in a C# project I actually don't get the errors and Visual Studio seems to understand they are VB (I didn't try to actual compile).

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 21, 2015

I think I need to Address this with the Roslyn team or Visual Studio support.

paul1956 replied Sep 21, 2015

I think I need to Address this with the Roslyn team or Visual Studio support.

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 21, 2015

Owner

VSIX projects are normal VS projects that have a few extra files & build targets.

You can change the language by changing the project GUID near the type of the file; search Google to find a list of VS project GUIDs.

Owner

SLaks replied Sep 21, 2015

VSIX projects are normal VS projects that have a few extra files & build targets.

You can change the language by changing the project GUID near the type of the file; search Google to find a list of VS project GUIDs.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 22, 2015

    <ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>

which translates to Extensibility,VB.NET which is correct but something thinks the 2 VB files are C#

The vsct file includes "C++" .h files and the comment says it is (usually) the C++ preprocessor don't know if that matters.

paul1956 replied Sep 22, 2015

    <ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>

which translates to Extensibility,VB.NET which is correct but something thinks the 2 VB files are C#

The vsct file includes "C++" .h files and the comment says it is (usually) the C++ preprocessor don't know if that matters.

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Sep 22, 2015

Owner

The VSCT is completely separate from all normal compilation.
Create a new VB VSIX project and compare the project files.
Also, make sure your project is a vbproj and not a csproj.

Owner

SLaks replied Sep 22, 2015

The VSCT is completely separate from all normal compilation.
Create a new VB VSIX project and compare the project files.
Also, make sure your project is a vbproj and not a csproj.

@paul1956

This comment has been minimized.

Show comment
Hide comment
@paul1956

paul1956 Sep 22, 2015

I created a new VB extension project added a Menu Item and get identical errors. I filed it with details under Roslyn project.

paul1956 replied Sep 22, 2015

I created a new VB extension project added a Menu Item and get identical errors. I filed it with details under Roslyn project.

Please sign in to comment.