Roslyn CTP 3 Released — Breaking Changes
Microsoft has released yet another CTP version of Roslyn and this doesn’t come as a big surprise. Since the previous CTP (CTP2) does not work very well with Visul Studio 2012. Now with Roslyn CTP3, we have Visual Studio 2012 support! However, this upgrade does come with a price, there are some breaking changes in the third version of the Roslyn CTP.
This unfortunately breaks some code samples in my book C# Smorgasbord, but not to worry. The changes are pretty easy to figure out and I’ve put together an Errata that covers all the code samples that are affected by the breaking changes.
If you’re using Visual Studio and you have intellisense enabled, it’s going to be pretty easy to figure out what has changed. Below is a short list of what I’ve found and what is in the Errata.
No longer possible to run Scripts through ScriptEngine directly
To execute a snippet you need to create a session first, like this:
var engine = new ScriptEngine(); var session = engine.CreateSession(); var result = session.Execute("var x = 10; x"); Console.WriteLine(result);
ParseCompilationUnit is removed
You can now use ParseText and ParseFile instead.
The auto generated GetIssue method has changes.
When creating a Code Issue project, the generated file is changed a bit. Instead of GetText() on the token, you now use ToString() and instead of CodeIssue.Severity.Warning you use CodeIssueKind.Warning.
Method AnalyzeStatementDataFlow is renamed
The method AnalyzeStatementDataFlow on SemanticModel has been renamed to AnalyzeDataFlow().
There are probably a lot more changes to Roslyn than the ones listed above.
If you have any questions regarding the code samples in C# Smorgasbord or if you want to chat about Roslyn, leave me a comment or an e-mail. Even though these are breaking changes, it does not ruin the reading expreience of C# Smorgasbord!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)