Cover

ASP.NET Core Snippets for Visual Studio Code

February 14, 2017
No Comments.

I found a project called ASP.NET Core Snippets to my excitement, but it only had snippets for some of the main files in your project. Not action snippets or razor snippets. So at 4am last night I wrote a Visual Studio Code extension to add some of these snippets.

So far, it only has a handful of snippets that my 4am brain knew I wanted:

C# Snippets:

mvc6-action: Creates an MVC6 Action that returns a view.
mvc6-get: Creates an MVC6 Action that Implements a basic GET.
mvc6-post: Creates an MVC6 Action that Implements a basic POST.
mvc6-put: Creates an MVC6 Action that Implements a basic PUT.
mvc6-delete: Creates an MVC6 Action that Implements a basic DELETE.
mvc6-controller: Creates an MVC6 Controller for views.
mvc6-apicontroller: Creates an MVC6 Controller for an API that implements all four basic verbs.
ef-dbcontext: Creates an Entity Framework Core DbContext class.

Razor Snippets:

razor-inject: Generates an @inject block.
razor-environment: Generates an environment block.
razor-raw: Generates an @Html.Raw block.

You can get the snippet from the marketplace here:

http://shawnw.me/aspnetcoresnippets

or by installing them directly in Visual Studio Core:

install

I’d love anyone that has snippets that would be helpful or knows a snippet they’d like me to build. Fork the repo and send me a pull-request, or just add an issue to the github repo:

http://github.com/shawnwildermuth/aspnetcore-snippets