Boston Code Camp 22 materials: Slides | Extension Demo Code | Post on Language Features

With the new code editors in Visual Studio 2015 now written around the Roslyn compiler a whole new level of extensibility is available both for built in features and user created extensions. If you’ve worked with Visual Studio extensibility before a Roslyn extension can a big improvement both in ease of coding and end user experience.

New Refactorings

Refactoring support was added in Visual Studio 2005 and since then a grand total of 0 new ones have been added. Now two new ones have been added to allow introducing new variables and for inlining existing ones. The experience is much improved for all the existing refactorings too.

New Refactoring Experience in 2015

Diagnostics and Code Fixes

Normal compiler errors show up in the editor as you type but can also be augmented with additional diagnostic checks performed by other Roslyn extensions. One key example is a large portion of the existing FxCop Code Analysis rules which were previously run as an additional build step but now happen on the fly as you type, making it much easier to apply these rules right away and keep your code cleaner from the start.

Unlike with normal compiler warnings or errors that you would normally get with FxCop, many of the new diagnostics include an additional component to actually correct the problem for you when possible, even showing a preview of the changes right in line (just like Refactorings).

Write your own!

Visual Studio has been extensible for a long time but there have been major limitations on how deep an extension could get into the code without writing your own compiler. In 2015, a Roslyn extension can take advantage of deep knowledge of the code in real time through the compiler as a service. Project templates are available that make it easy to set up either a Refactoring or a Diagnostic with (or without) a Code Fix. Deployment can be done either through a VSIX that can go up on Visual Studio Gallery, or now as part of a NuGet package that can be deployed on a project by project basis. The possibilities are endless and I expect a huge flood of Roslyn extensions are going to be available on top of what’s already been added into the product.

Download Visual Studio 2015 Preview and the SDK: http://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs

Roslyn templates Visual Studio extension: https://visualstudiogallery.msdn.microsoft.com/849f3ab1-05cf-4682-b4af-ef995e2aa1a5

Bill Wagner announcing a new central location for community Roslyn extensions: http://thebillwagner.com/blog/announcing-dotnetanalyzers-diagnostics-and-code-fix-open-source-projects