Monday, October 24, 2011

Creating a basic code analysis with Roslyn

If you’ve installed the Roslyn CTP, you can go to the installation folder and look inside the Documentation folder, there’s a lot of interesting information here that you can make use of. I’ve got my documentation here:

    C:\Program Files (x86)\Microsoft Codename Roslyn CTP\Documentation

Now there’s one document here that is a bit extra interesting, at least for me, it talks about how we can make basic code analysis with Roslyn ( How to Write a Quick Fix (CSharp).docx ). The basic idea is to identify whenever a variable can be made const. So for those of you that haven’t had the time to download and install Roslyn yet, I’ll show you how to do exactly that with the help of their sample. It’s essentially the same outcome and code as they use in their documentation, but I will try explain a little bit more about each piece and add some extra things as well. But be sure to check out the documentation that comes with Roslyn as well!

However, the sample in the document has an error to it so it doesn’t run out of the box!

First thing is to open up an instance of Visual Studio and create a new Code Issue project, I’ll call it MyFirstCodeIssueFix


Read more: Filip Ekberg's blog

Posted via email from Jasper-Net