New GitHub and VSIX Package: Division42.CodeSnippets

As mentioned several times, I am a big fan of using “snippets” in Visual Studio. In fact I even published some C# templates as Gists. There are two things which became problematic:

  1. You had to manually save the files, and manually add them to Visual Studio.
  2. There were not any VB.NET snippets. (Jamie, please note there is no support in any of these technologies for F#)
  3. Lastly, the issue of versioning became an issue as I would refine some snippets.

The two main reasons I never made VB.NET snippets is A) they are pain to use in Visual Studio – it requires several mouse clicks; NOT COOL! Secondly, until today, I’ve NEVER been able to get a VB.NET snippet installed correctly.

Now, I am attempting to correct all that in one effort!

Enter the Division42.CodeSnippets VSIX extension:
I took a few minutes to create a .vsix package which will install both the C# and VB.NET snippets. As of this writing, the snippets included are:

  • argNull – checks an argument for null (Nothing in VB), and throws an ArgumentException
  • argString – checks a string argument for String.IsNullOrWhiteSpace(), and throws an ArgumentException
  • propProper – creates a proper exception, and keeps the backing-field with the property. Also includes “Gets or sets …” XML code comments
  • exceptionProper – a proper implementation of an Exception class, with basic XML code comments

The idea being that this is where this can start. As I develop other snippets (and I do use several other) – or if YOU have an idea for snippets, anyone can add them and we can publish a new version.

The project on GitHub:
I’ve made this open source on GitHub using a very liberal MIT license. I created the project with Visual Studio 2013 and do target .NET v4.5.2 (you might need to install the 4.5.2 Developer Pack). The project is out here:

https://github.com/Division42LLC/Division42.CodeSnippets

If you are interested in contributing, see this page for information about how to contribute to an open source project on GitHub.

The VSIX on Visual Studio Gallery:
Once I verified that the installer worked locally, I published it out on Visual Studio Gallery, here:

https://visualstudiogallery.msdn.microsoft.com/7f385eaf-a2e0-4cc8-9d3f-e53bb9cef4f2

You can also simply install it as a Visual Studio Extension from Tools –> Extensions and Updates, then search for “division42”:

image

Next steps…
There are a few more snippets I’ll work on and publish (for both C# and VB.NET), as time-permits. Meanwhile, if you have snippets you use and would like to contribute do a pull-request and let’s get them in here!

Posted in Best-practices, Computers and Internet, Development Tools, General, Open Source, Organization will set you free, Professional Development, Uncategorized, Visual Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2 other followers

%d bloggers like this: