Monday, February 10, 2014

What is Microsoft® “Roslyn”

By tradition compiler is a “black box”. We are pushing the source code in one end and assemblies are coming out at the other end. Something happens in between which we are not aware of. And I am sure most of you would agree, we didn’t even want to know what’s happening inside. With “Roslyn”, Microsoft is letting us not only know what is happening inside the compiler, they are letting us to use the compiler through a set of APIs.

Microsoft Unveils its Compiler as a Service technology via project “Roslyn”. “Roslyn” exposes C# and Visual Basic compilers as a set of APIs. So with “Roslyn”, compilers become services.

The “Roslyn” is currently available as a Community Technology Preview (CTP). Microsoft released the first CTP of the “Roslyn” Project back in October, 2011. That particular CTP installs on Visual Studio 2010 SP1 and it requires the Visual Studio 2010 SP1 SDK. The current latest version is Microsoft “Roslyn” September 2012 CTP installs as an extension to Visual Studio 2012 (Please note that Visual Studio 2010 is no longer supported by this CTP). When you have installed Microsoft “Roslyn” September 2012 CTP, insider Visual Studio 2012 when you click on New Project, you can see a new project template type “Roslyn”.

Microsoft "Roslyn" Project Templates
The Roslyn assemblies are also installed in the GAC. If you create an other project type instead of all above, You can still add references to use “Roslyn”.

Adding References
Not only this. Once you have installed Microsoft Roslyn CTP, you are getting a new window to Visual Studio called “C# Interactive” (If you are wondering whether there is “VB Interactive” Window, NO, there is nothing like that yet). To open the “C# Interactive” window, you don’t even have to create a new project. Just fire off Visual Studio, under View->Other Windows, there you can find “C# Interactive” window.

C# Interactive Window
There you can also see a “F# Interactive” window, but it was not installed with Microsoft Roslyn CTP. It comes with the default Visual Studio Installation. Anyway “C# Interactive” window can be very useful when you want to try out things.

Let’s say I want to check the Ping.Send() Method.

IntelliSense in C# Interactive Window
As you can see in the above picture, IntelliSense is fully supported.

Testing with C# Interactive Window
Learn more on Microsoft “Roslyn”,
   Microsoft® “Roslyn” CTP

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment