Wednesday, December 02, 2009

Solution for reading your VS Solutions - “LINQ to Visual Studio Solution”

CodeProject - LINQ to Visual Studio Solution

LinqPad

Introduction

In attempting to write software for Windows Mobile using Visual Studio C# Express or SharpDevelop, I found that there is some common code that is generated by the designers which does not work on Windows Mobile. Instead of fixing it by hand every time I changed something on the form, I wanted to write a general refactoring tool that I could run from the command line (or the "Tools" menu) and fix the problem code.

I got something very ugly working, using (or misusing) the NRefactory library from SharpDevelop. However, I found that sometimes I needed to use Reflection, and so I needed to know which libraries were referenced in the project. At this point, I had never used LINQ, but I started to see how LINQ to XML could save a lot of code.

Then, as I was working on it, the code to get project properties evolved into the general purpose LINQ to Visual Studio solution that I present here. There is nothing in this code that deals with refactoring. It does read only property queries against Visual Studio projects. Hopefully, at some point, my refactoring code will be at a decent stage and I can post an article on that.

…”

I just thought that was too darn cool to not reference. It’s not that it’s uber hard (a VS Solution is just an XML file), just that it seems to make such good sense to abstract it this way and make it so easily LINQ’able. And I dig how the author took the time to generalize it and share it with all of us.  :)

No comments: