locked
Add-In: Require an API for adding Code Snippets Locations in visual studio RRS feed

  • Question

  • I'm currently creating a Visual Studio Add-In and require the ability to add a location for custom Code Snippets to the users Visual Studio Environment programatically. I'm aware of the DTE Command Tools.CodeSnippetsManager but don't know if there are command argurments which allow me to add these locations.
    Saturday, September 18, 2010 3:20 PM

All replies

  • Hello,

     

    Unfortunately, the tools.CodeSnippetmanager doesn’t have any arguments and the underlying dialog that comes up CCodeExpansionWindow doesn’t have built in automation that we’ll be able to manipulate via the dte object model.  (you would have to use a sendkeys type approach if you manipulated the dialog)  As you probably already know, the prescribed way of installing snippets is via the Visual Studio content installer approach http://msdn.microsoft.com/en-us/library/ms242311.aspx

     

    Another idea might be to manipulate the xml files snippetsindex.xml found under the language you are adding snippets to e.g.

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033

    Thursday, September 23, 2010 2:06 PM
  • Hi, thanks for your response.  I had a feeling that there currently wasn't an API for registering snippet locaitons programmatically.

    Can you tell me a but more about the snippetsindex.xml.  I tried adding a new SnippetDir node to the file pointing to my own custom location but Visual Studio doesn't seem to recognise this. 

    Is this all that needs to be done for VS to detect the new snippet directory and display it via the snippet shortcut command and the snippet manager?

    Also, what does the OnOff element do?


    Thanks

    Thursday, October 7, 2010 9:46 AM
  • Hello,

    Unfortunately, the tools.CodeSnippetmanager doesn’t have any arguments and the underlying dialog that comes up CCodeExpansionWindow doesn’t have built in automation that we’ll be able to manipulate via the dte object model.  (you would have to use a sendkeys type approach if you manipulated the dialog)  As you probably already know, the prescribed way of installing snippets is via the Visual Studio content installer approach http://msdn.microsoft.com/en-us/library/ms242311.aspx

    Another idea might be to manipulate the xml files snippetsindex.xml found under the language you are adding snippets to e.g.
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033

    My recommendation would be to have you open a paid support incident with Microsoft support, and see

    if we can't get a repro. You may have a few options for opening said support

    incident.

    Alliance and Premier VSIP membership includes a complimentary MSDN subscription, which includes 4

    professional support incidents. These can be used to initialize a support request with Microsoft's

    Customer Support Services. Some versions of Visual Studio include a number of free support incidents

    as well. See the "Technical Support Incidents" topic for details.

    visit the below link to see the various paid support options that are available to better meet your

    needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    This appears to be a bug in WPF, and Microsoft is aware of it and investigating a solution.

    If you need help with a workaround, please contact Microsoft Support at

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    bill boyce
    Friday, November 5, 2010 3:29 PM