In case you have missed the late yesterday news from Redmond: Roslyn CTP is now available! See soma, ericli, vsteam, vbteam, c#faq blog posts. But to concretely get started, see the official msdn page: msdn.microsoft.com/roslyn This page points to 7 walk through typical Roslyn API usages + a white book.
But wait a minute, what is Roslyn?
- Roslyn is the result of the last 4 or 5 years effort from the C# and VB.NET team now unified around the Roslyn project.
- Roslyn will be a replacement for the actual C# and VB.NET compilers, when exactly? after dev11 goes live, dixit Soma : the Roslyn work is focused towards a post-Visual Studio 11 release. So it sounds like we can’t expect a RTM version before at best, a year.
- Roslyn is entirely written in managed code and, opposed to current C# and VB.NET compilers, Roslyn is open, it is not a black box: Roslyn proposes a .NET API to let developers write meta-programs. Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data. Meta-programming represents concretely many sort of cool things such as: syntax analysis, semantic analysis, refactoring, Aspect Oriented Programming engines, interactive C# and VB.NET editors…
- But also, Roslyn will be used to add tremendous flexibility to your application by letting the user expresses what he wants to achieve through portions of C# or VB.NET code. For example, I can thing of financial traders (you know the guys that rule the world) writing complex financial data treatments through a C# interactive Window. I already saw them writing VBA code to achieve what they wanted!
- Finally, Roslyn is the implementation of the Compiler as Services paradigm introduced by Anders Helsberg last year.
Some facts about Roslyn
As usual, when putting my hands dirty in a new .NET API, I do a quick check with NDepend to get some sort quantitative ideas. And actually Roslyn exposes a big, very big API, bigger than anything you’ve seen except the whole .NET Framework itself.
- 939 publicly visible types (and a total of 5 811 types).
- 6.105 publicly visible methods (and a total of 51 843 method).
- Just a bit more than 1 M IL instructions which means around 150K lines of code.
Keep in mind that Roslyn is still in an early alpha stage, and these numbers will certainly increase. The purpose of this CTP is, for the Roslyn team, to get as much relevant feedbacks, to make sure they go in the right direction. This CTP version is far from being feature complete (more details in ericli post).
Here is a treemap representation of the Roslyn implementation, the blue squares being the public types, the elementary rectangles being methods with a surface proportional to the implementation size (in terms of IL instructions).
This treemap view is especially suited to locate where the public surface of the Roslyn API is. While such a project potentially comes with plenty of potential extension points, not everything will be publicly available and the Roslyn team are serious about keeping the public API compact.
You must also keep in mind that the Roslyn API is built upon one tenet: Immutability. Objects grapes returned by Roslyn API, (like Abstract Syntax Trees) will be seen as immutable , which not necessarily mean they are internally immutable, but one behavior you’ll observe and can rely on will be immutability.
Here is also the number of publicly available types and methods exposed by Roslyn assemblies and namespaces:
For those interested, here are Roslyn assemblies dependencies displayed through a dependency matrix (it is too complex to be shown through a comprehensive dependency graph): a blue square means that the column assembly is using the row assembly, the number in a blue square is the number of types consumed.
The C# Interactive Windows
Roslyn proposes an interactive C# editor windows view available in VS2010 Menu View> Others Windows > C# Interactive Windows:
I wanted to see exactly which Roslyn API was consumed by this C# Interactive Windows but to my surprise, this assembly seems to consume only oldish Microsoft.VisualStudio API assemblies? Any feedback on that?
Update: Answer from a Roslyn Team member: The InteractiveWindow assembly is the language agnostic VS host for the window. The “smarts” are in Roslyn.VisualStudio.CSharp.Repl.dll.
I don’t think I have the right to decompile this Roslyn.VisualStudio.CSharp.Repl.dll assembly, but it is still interesting to have a look at which Roslyn API types it is using. The number in blue square represents the number of members used. A zero means that the type is an interface implemented, or an enumeration used. (btw, a Mono C# Repl is available since more than a year ago).
To be continued…
Without any doubt Roslyn is a major initiative. Roslyn will revolutionize the .NET development tooling sphere. Since VS inception, many have bashed the lake of refactoring facilities in VS, but available in Eclipse or through third-party addin like Resharper or CodeRush. But with Roslyn, instead of giving fishes, MS is building a multi-purposes fishing rod: developing features such as complex and customized search, semantic analysis or refactoring goodies, is what Roslyn will excel at.
During internal pre-discussions with the Roslyn team I noted that Roslyn will be delivered with the .NET Fx bits, so no need to have VisualStudio installed to consume the Roslyn API from your widely delivered code. Hence what we don’t clearly see yet, is that Roslyn might well change the face of typical application, by letting introducing features based on Compiler as Services and Meta-Programming paradigms.