BT

Code Analysis with Project Roslyn

by Jeff Martin on Apr 27, 2012 |

 

Microsoft's Lang.NEXT conference held in Redmond this month included a presentation providing a demonstration of the Roslyn's project code analysis tools. Dustin Campbell's presentation, "Going Deeper with Project Roslyn", gives a soft introduction to the project and concludes with the construction of a sample project.

The Roslyn framework is not intended to be a framework for building a custom compiler, rather it is intended to focus on maximizing the utility of C# and Visual Basic. Both of these languages have had their compilers rewritten from scratch, so that Roslyn's C# compiler is written in C# and Roslyn's VB compiler is written in VB. As Campbell observes, this has allowed for numerous corner cases and bugs in the original compilers to be corrected.

Roslyn Design Characteristics

  • Immutable – Objects cannot be changed, so changes are introduced by creating new objects on the originals

  • Complete – Full representation of the source code, including whitespace, comments, errors, etc.

  • Resilient– Fault tolerance to handle errors. For example, statement completion is almost always on broken code, so parsers must able to handle it.

  • Efficient– Project is exhibits efficiency at building snapshots, and possesses the ability incrementally parse code

When the Roslyn environment is open, two instances of the active workspace exist. The first is the traditional workspace that holds the currently loaded VS solution. The other instance holds the interactive window (REPL). This separation helps statement completion and IntelliSense to work correctly on the code in development.

Campbell notes that Roslyn while available since October in Beta format, release code (version 1.0) will not be shipping with the upcoming Visual Studio 11.  Instead it will be released as part of a future VS. However, while Campbell does not specifically state this, given that the Beta supports VS2010, it would seem Microsoft could deploy it independently of a formal VS release.

 

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT