Xamarin Studio now supports Microsoft’s Roslyn compiler-as-a-service features found in Visual Studio 2015. They’ve also announced a new project model that integrates with Microsoft’s MSBuild system.
In previous versions of Microsoft’s Visual Studio, they had their C# compiler, but they separately had to write and maintain all of the code that supplied Intellisense, refactoring, red-squiggles, etc. Keeping that logic synchronized with the actual compiler was obviously tricky and duplicated work. With VS2015, they cut over to Roslyn to allow the IDE to tap into the same end-stream compiler, ensuring consistency and eliminating duplicate work. That seems to be what this early preview version of Xamarin Studio has tapped into as well. — John Garland
The specific benefits of this change include:
In addition to adding Roslyn support, they’ve also changed the project model to allow a deeper integration with MSBuild. … Read more
Now that Visual Studio 2015 RC is fresh off the build machines and available for everyone, I’ve updated my Wintellect.Analyzers project (http://johnr.us/1bEO4h8) with full RC support. Go forth and add them to your project so you can get the benefit of advanced compiler analysis and code fixes. To add the analyzers, hit up your Package Manager Console with the following command:
I guess you could go through the fancy new NuGet window in Visual Studio, but you want to be hard core and use PowerShell in VS!
If you’re interested in writing your own analyzers, as I have discussed previously, you’re immediately going to run into errors and warnings with projects based off the default Roslyn template when you try to install your analyzer masterpiece. Here’s what you’ll see:
Attempting to gather dependencies information for package ‘Analyzer22.214.171.124’ with respect to project targeting ‘.NETPortable, Version=v4.5, Profile=Profile7’
Attempting to resolve dependencies for package ‘Analyzer126.96.36.199’ with DependencyBehavior ‘Lowest’
Resolving actions to install package ‘Analyzer188.8.131.52’
Resolved actions to install package ‘Analyzer184.108.40.206’
Adding package ‘Analyzer1 220.127.116.11’ to folder ‘c:\junk\code\Analyzer1\packages’
Added package ‘Analyzer1 18.104.22.168’ to folder ‘c:\junk\code\Analyzer1\packages’
Added package ‘Analyzer1 22.214.171.124’ to ‘packages.config’
Executing script file ‘c:\junk\code\Analyzer1\packages\Analyzer126.96.36.199.0\tools\install.ps1’
Get-ChildItem : Cannot find path ‘C:\junk\code\Analyzer1\packages\Analyzer188.8.131.52.0\tools\analyzers\C#’ because it does not exist.… Read more
My deep abiding love of Roslyn continues! I just published a new video Writing Roslyn Analyzers and Code Fixes up at WintellectNOW: https://www.wintellectnow.com/Videos/Watch?videoId=writing-roslyn-analyzers-and-code-fixes. My goal was to take you from zero knowledge of Roslyn to writing a real world analyzer and code fix in 1.5 hours. This video covers everything from using the Syntax Visualizer to developing and testing analyzers and code fixes. Along the way I show how I solved some of the hard real world issues you’ll encounter.
Given that there’s not a lot of documentation on Roslyn I thought this video would help get folks up to speed as we approach the release date for Visual Studio 2015. I would love to hear any and all constructive criticisms you have on the video. What did I do right, what did I do wrong, and what else do you want to see. Sign up for a free WintellectNOW account and post to the discussion area under the video.
Please note that we reserve the right to move the video to subscription required in the future. Given how new Roslyn and VS 2015 are at the time of recording we thought it was good to get the info out now.… Read more
The other day my co-worker Jeffrey Richter and I were discussing my latest infatuation, Roslyn analyzers. As we bounced around a few ideas one came to the forefront; every catch block should throw. This is not a hard and fast rule, but eating an exception, especially accidentally, has caused more bugs in .NET than we all care to count. My mind started spinning thinking that I want to see if I can automate checking for eaten exceptions in a Roslyn analyzer.
At first glance, the idea seems pretty easy. Look for the catch blocks and look to see if there are any throws, returns, or, goto statements. (Realizing that you can use a goto in a catch block made me involuntarily shudder.) Anyway, sketching through a quick algorithm of going about analyzing the syntax nodes made me realize there was going to be nothing quick about it. This was going to be a lot of work, especially when you really start thinking about all the ramifications. While I welcomed the challenge, I thought I better look deeper at the Roslyn API to see what it offers. Fortunately for everyone, there’s a super nice control flow analysis engine built right into Roslyn.… Read more
Over the last few months I have been having a wonderful time developing Roslyn analyzers and code fixes. You can find all the Wintellect.Analyzers code at Wintellect’s GitHub page. If you would like to include these analyzers in your own Visual Studio 2015 CTP 6 project, install the NuGet package by executing the following in Visual Studio’s package manager console window:
Now that I’m getting more fluent in analyzers and code fixes I wanted to share some of the things I’ve learned to save you some time when you start doing your own in the future. First I’ll go over some of the new analyzers I’ve written. Next I’ll turn to the question of using analyzers and code fixes as NuGet packages vs. a Visual Studio VSIX. Finally, I’ll jump into some of the development aspects of analyzer and code fix development where I’ve had issues. Obviously, in that section, I’m assuming you know something about Roslyn and analyzer development. If this is all new to you Alex Turner’s two part series in MSDN Magazine gives you a solid understanding quickly: Part 1, Part 2.
Kathleen Dollard talks to Matthew Gertz, Principal Development Manager of Visual Studio Managed Languages at Microsoft about how they are becoming more transparent, ways in which the open source developer community helps Microsoft make better products, and the future of Roslyn.
In this video we interview John Robbins about a new and open Microsoft, the potential of Roslyn, and how debugging has changed over the years.
John Robbins is a cofounder of Wintellect, where he heads up the consulting and debugging services side of the business. He also travels the world teaching his Mastering .NET Debugging and Mastering Windows Debugging courses so that developers everywhere can learn the techniques he uses to solve the nastiest software problems known to man. As one of the world’s recognized authorities on debugging, John takes an evil delight in finding and fixing impossible bugs in other people’s programs.… Read more
In this interview with Kathleen Dollard we dig into some of the new features of Visual Studio 2015, what’s coming up in the C# language, and the power of Roslyn and what it means for developers.
Kathleen Dollard wants to teach you to code better. There’s more to learn about the tools you use every day and the tools you aren’t yet using. Coding is our passion and debugging is our challenge – you’ll be happier if you do both better. Kathleen’s written dozens of articles, spoken at conferences and user groups around the world, and pushes Microsoft to respond to your real world needs as a long time MVP. Her Open Source project RoslynDom offers alterative access to information in the .NET Compiler Platform, Roslyn with a load/interrogate/mutate/build SyntaxTree model. She has courses in the Pluralsight library and a series of C# 6 webcasts now available for free on WintellectNOW.… Read more
When I first saw the Roslyn compiler, I was thrilled! For once the compiler was not going to be a black hole where source code comes in and on the other side of the worm hole a binary comes out. With open extensibility there’s going to be some amazing tools developed that were impossible to do any other way. With this week’s release of the Visual Studio 2015 Preview, the Roslyn API is solid and ready for extension!
We have posted on Wintellect’s GitHub account our first five analyzers and code fixers we wrote to explore that part of the API. They should give you a good idea how to get started writing your own new rules. Here’s the initial set of rules:… Read more