A version of the C# and VB compilers that is written in managed code.

Written in 100% managed code, the Roslyn project exposes the C# and VB compilers as a service.

Historically, the managed compilers we’ve shipped in Visual Studio have been opaque boxes: you provide source files, and they churn those files into output assemblies. Developers haven’t been privy to the intermediate knowledge that the compiler itself generates as part of the compilation process, and yet such rich data is incredibly valuable for building the kinds of higher-level services and tools we’ve come to expect in modern day development environments like Visual Studio.

With these compiler rewrites, the Roslyn compilers become services exposed for general consumption, with all of that internal compiler-discovered knowledge made available for developers and their tools to harness. The stages of the compiler for parsing, for doing semantic analysis, for binding, and for IL emitting are all exposed to developers via rich managed APIs.

Useful resources

Tips & Tricks

  • Use the Syntax Visualizer to easily inspect syntax trees.

  • The Roslyn Quoter tool can quickly show you the structure of the syntax tree of any given piece of code.

  • Formatter.Format is an easy way to format your syntax nodes.