C# Snippet Parity

Microsoft recently released a complete set of C# code snippets for Visual Studio 2005. This brings C# to parity with VB.NET, which had many more code snippets "in the box".


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2006/02/c-snippet-parity.html

Thanks! Much improved over MS’ “installation”

Interestingly enough, I can not find the “Code Snippets Manager” on my VS2005 Tools menu.

All the MSDN2 Articles just assume it will be there, and I haven’t yet figured out how to force it to show up either.

Mort.

Dunno if WinRAR supports [self-extracting archives], but the 7zip program does.

I agree, but when the archive is only 60kb to start with, the overhead of the self-extracting EXE is a little too much to bear :wink:

I second Jon Galloway on the Darwinia accusation! Though the code snippets aren’t going to save me any time.

Jeff Ah, ok. So I was missing something! :slight_smile:

Malcolm On one of my VS installations, I had no menu item either, for some reason. I added it myself by… Right-click on the menu, choose Customize, go to the Commands tab, from the Categories list click Tools. In the right-hand list you should see it listed as Code Snippets Manager. Drag-and-drop it from there to wherever you want it in the menu. Works?

Interestingly enough, I can not find the “Code Snippets Manager” on my VS2005 Tools menu

Use the keyboard shortcut I mentioned in the post: CTRL+K, CTRL+B

Same issue with Team Developer installed. It doesn’t appear in the menus by default. This can of course be customized… Frederik described how to add it.

Hi,

I can highly recommend IZArc [http://www.izarc.org/] which is freeware. It uncompresses most formats and can compress to zip, 7-zip and a bunch of others (not rar though).

I like the interface better than WinZip or WinRAR.

regards,
martin

Maybe I’m missing something, but for me, installing these snippets using the Microsoft download was easy-peasy. I just added the root folder (in my case, D:\Documents\MSDN\Visual C# 2005 Code Snippets) in the Code Snippet Manager and everything ‘just worked™’. No manually adding each folder for me! Weeee!

I like 7-Zip just as it is. :slight_smile: Sure, there’s room for improvements, but it’s free and it basically does everything I need it to do.

Anyway, thanks for the “installer”. I did download Microsoft’s MSI packages a while ago, but I didn’t install all of them for the same reason you describe.

I just added the root folder (in my case, D:\Documents\MSDN\Visual C# 2005 Code Snippets) in the Code Snippet Manager

I wanted the snippets in the same folder as the “standard” C# set-- which means you have to add each folder individually.

But you can add an arbitrary new folder, or put the snippets in your user snippet folder.

Leave it to a VB developer to make it easier… :wink:

Jeff man, thanks for this! We owe ya.

After installing the C# code snippets, I have an extra folder that appears in the pop-up as shown in this picture: a href="http://pics.bbzzdd.com/users/mrmilney/snippets_popup.gif"http://pics.bbzzdd.com/users/mrmilney/snippets_popup.gif/a

The 1033 folder does not appear in the snippets manager dialog as you can see in this picture: a href="http://pics.bbzzdd.com/users/mrmilney/snippets_manager.gif"http://pics.bbzzdd.com/users/mrmilney/snippets_manager.gif/a

I have looked and looked in vain, but I can’t see where this extra entry is stored in either the registry or in any configuration files in the VS 2005 directory. I’d appreciate any help anyone could give me.

I apologize for the bad links in the above post, if anyone wants to see the pics I will be glad to e-mail them to you.

The problem is this: when I type ctrl+k, ctrl+x to bring up the Insert Snippet pop-up in VS.NET 2005, the topmost folder in the list is 1033. If I bring up the Code Snippets Manager with ctrl+k, ctrl+b the 1033 folder is not listed (and therefore I can’t remove it).

I have checked both the registry keys referenced in the add-csharp-snippets.reg file, but I can’t see where this extra entry is coming from. It seems that VS 2005 is hiding the snippet paths somewhere else, but I can’t figure out where. If anyone has any suggestions, I’d love to hear them.

The registry is the master source, no doubt about it. Check both local and user keys:

HKLM\Software\Microsoft\VisualStudio\8.0\Languages\CodeExpansions\CSharp

HKCU\Software\Microsoft\VisualStudio\8.0\Languages\CodeExpansions\Visual C#

Beware, the path is duplicated within these keys-- check for a “Path” subkey. I have no idea why, but it is.

You can validate this yourself by adding a new path in the snippet manager. If you check the reg key afterwards, you’ll see it is there…

It seems that the link for download [http://www.codinghorror.com/blog/files/ms-csharp-snippets.7z.zip]
is dead. Could you update the link.

Murugan.G

I agree that the snippet entries must be in the registry, but I can’t seem to find the one I need to remove this extra folder. I even went so far as to manually add “%InstallRoot%\VC#\Snippets%LCID%;” to both path keys under HKCU. While this did make the 1033 entry appear in the Code Snippets Manager, removing it from there did not make the problem go away.

Does anyone have any further suggestions? My OC is kicking in and that extra folder is really bothering me.

Joe, it’s really weird that there is a mismatch between what the snippet manager shows and what shows up in the IDE! I have no idea what’s going on there, but triple check all those registry keys and sub-keys.

Could you update the link.

The link works for me:

http://www.codinghorror.com/blog/files/ms-csharp-snippets.7z.zip

I checked in IE6 and Firefox 1.5.

My 2: 7-Zip rocks.

My own little rant, cut and pasted from an email
Everyone should be using 7-Zip. But the best way to get everyone using it is to get your friends to install TugZip. TugZip ( http://www.tugzip.com/ ) is the best windows archiver I’ve ever used. Its integration into the file manager is awesome, and it’s completely free!

Not only does it allow right-click creation of archives and unzipping multiple archives at once (each into it’s own directory), but it allows you to customize the icons for each type of archive that it supports, and lets you set the default compression level (including creating solid archives) for those right-click “add to .7z” actions.
end rant

The only thing it CAN’T do is CREATE rar archives (without rar.exe). But it does unpack them with no problems, which is all I care about, since I’m making 7-Zip, not rar.