Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Lap Around Roslyn CTP: Introduction

DZone's Guide to

Lap Around Roslyn CTP: Introduction

· Performance Zone
Free Resource

Download our Introduction to API Performance Testing and learn why testing your API is just as important as testing your website, and how to start today.

The Roslyn project is the Microsoft implementation of C# and VB compilers-as-a-service. Roslyn provides a transparent view into the inner workings of the compiler, including syntax tree inspection and modification.

An initial CTP of Roslyn has been released for download a couple of days ago—it requires Visual Studio 2010 SP1 and the VS2010 SP1 SDK.

Some of the scenarios enabled by Roslyn are the following:

Refactoring. Refactoring tools no longer need to parse the original source code and then reconstruct it manually. Instead, a set of rewriting APIs is available on the syntax tree level, making possible classical refactorings—“make readonly”, “extract method”, “extract interface”—as well as incredible new things yet to be invented.

Code analysis. Performing static code analysis—especially when data flow and control flow are involved—is an extremely difficult task without the syntactic and semantic compiler engines. It becomes possible to answer questions like “is this local variable returned from the method?”, “is this parameter assigned in this specific block under that specific condition?”, “is this method invoked with a compile-time constant expression?”.

“Quick Fix”. Visual Studio extensions that run in the background can detect common source code issues and suggest a fix.

REPL (Read-Eval-Print Loop). To test code quickly against a given API or to invent a new API and then try it out is easier than ever with the C# Interactive Window in Visual Studio. It is more powerful than the Immediate Window, because you can use the full power of the language—including lambdas and query comprehensions—and because you can define new types or methods and immediately use them.

Scripting. Roslyn ships with a command-line tool called rcsi.exe that evaluates .csx files—script files written in C# that are clear of the “class Program … void Main” clutter and focus on exactly the task at hand. I’ll go as far as saying that this is serious competition for PowerShell!

Embedded compiler. It is now easier to embed the C# compiler in an application and provide an ambient context (host object model) implicitly to the compiled code. Think DSLs and rule engines—taking advantages of the full power of C#.

In the next couple of posts we’ll perform some experimentation with the Roslyn APIs. If you are looking for more, right away, then go ahead and read the “Getting Started” documents and the samples that ship with the CTP.

Find scaling and performance issues before your customers do with our Introduction to High-Capacity Load Testing guide.

Topics:

Published at DZone with permission of Allen Coin. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}