Microsoft releases a preview of the .NET Compiler Platform, codenamed Roslyn

Microsoft released a public preview of the .NET Compiler Platform, codenamed Roslyn, on April 3rd, 2014. The code is available at http://roslyn.codeplex.com/ for you to bask in all of it’s glory.

You can clone the .NET Compiler Platform Git repository using this command:

https://git01.codeplex.com/roslyn

Or install the Nuget Package:

Install-Package Microsoft.CodeAnalysis -Pre

What is the .NET Compiler Platform?

The .NET Compiler Platform is Microsoft’s effort to open source the C# and Visual Basic compilers. The code is released under the Apache License 2.0. From Codeplex:



Microsoft took the original C# and Visual Basic compilers, which were written mostly in C++, and completely rewrote them in managed code. This means they were able to create a set of APIs that allow you to consume the code compilation and analysis results. There are currently 2 main APIs: The [Compiler APIs](http://roslyn.codeplex.com/wikipage?title=Overview&referringTitle=Home#Compiler APIs "Roslyn Compiler APIs") and [Workspace APIs](http://roslyn.codeplex.com/wikipage?title=Overview&referringTitle=Home#Workspaces APIs "Roslyn Workspace APIs"). It is worth noting that neither of these APIs have a dependency on Visual Studio which means you can provide much of the same Visual Studio functionality in any application you want.

Compiler APIs

The Compiler API layer allows you to view information about the compilation process. This includes syntax and semantic information, errors, warnings, as well as access to files and information after compilation is complete. It provides Syntax Trees that display the structure and references between your code, Syntax Tokens which are the keywords, variables, etc in your code, and Syntax Trivia which is essentially the items that the compiler ignores such as whitespace and comments.

Workspace APIs

The Workspace APIs provide you information about the current project and solution, allowing quick and easy access to a vast array of information about the code. This assists in providing code analysis, refactoring, and Intellisense to the user. The Workspace API has a CurrentSolution property that gets updated whenever a change to the host environment occurs. This can be anything from typing a letter in a source file to saving a project.

Why is this cool?

Well, first off, it’s open source! The .NET Compiler Platform is part of Microsoft’s newly created .NET Foundation, which is a foundation created to help spur on development of open source technologies making use of .NET. Open source means that the community at large can review the code, provide bug reports and fixes, and can maintain the code even if Microsoft falls off the face of the earth. The fact that Microsoft open sourced these compilers means they are serious about their recent push cultivate the open source .NET community.

This is also awesome because it means that creating code analysis tools is much, much easier. Like, an order of magnitude easier. Like, I might even be able to do it. Right now, developers of tools like JetBrains’ ReSharper, Telerik’s JustCode, and even Visual Studio itself had to write their own code that is essentially a duplicate of the existing compiler code. Roslyn allows them to tie into existing operations and make use of the analysis and syntax trees the compiler already has.

If you don’t want to create a full blown productivity extension, anyone can take this and write small extensions that provide new warnings and errors to the compiler. Or create a new refactoring extension that finds duplicate code through an entire solution. Or a tool that finds all comments in your solution and outputs a documentation file. Or create an analysis tool that provides your method’s Kevin Bacon Number!.

Antes de revisar el catálogo, es recomendable fijar la frecuencia con la que se utilizará la camiseta. También es necesario confirmar que la descripción coincide con las imágenes. Al consultar «», resulta más sencillo comparar datos actuales e históricos cuando corresponda. Antes de elegir definitivamente, conviene verificar el contenido exacto de la opción elegida.

Antes de revisar el catálogo, es recomendable fijar la frecuencia con la que se utilizará la camiseta. También es necesario confirmar que la descripción coincide con las imágenes. Al consultar «camisetas de la selección de Argentina para mujer», resulta más sencillo comparar datos actuales e históricos cuando corresponda. Antes de elegir definitivamente, conviene verificar el contenido exacto de la opción elegida.

Now what?

Remember, this is just a preview release. Microsoft hasn’t provided a final release date, but I don’t expect it to be anytime soon. For now, go play with it! Look through the code, download the source, have fun! If nothing else, it’s a great look into the C# and Visual Basic compilers.

Now, if you’ll excuse me, I’m going to go add Intellisense to Notepad.