-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
5 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 - &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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been updated for VS 2015, the 2015 vsixmanifest file looks nothing like this example, at least for VB.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
I published this to the gallery a while ago.
Note that my extensions use VSIX v1, for compatibility with VS2010.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/Pkgdefcontent from the VSIX v2 designer; IIRC, it's one of the entries in the dropdown.6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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..
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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..
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Asset Type="Microsoft.VisualStudio.VsPackageis exactly what you need.It sounds like you're adding a VB file to a C# project.
Change your project type.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to Address this with the Roslyn team or Visual Studio support.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
vbprojand not acsproj.6ce75a4There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new VB extension project added a Menu Item and get identical errors. I filed it with details under Roslyn project.