Source code for the .NET Framework!

Microsoft is releasing the source to the .NET Base Class Libraries as well as the top three presentation technologies in the framework, ASP.NET, Windows Forms and WPF.

 

This is huge. I’ve been on the Silverlight team for about two years and most of that time was spent using javascript in the browser’s script engine. However, before that I was a PM on the Windows Forms team and I wrote plenty of managed code. Examples include the RegionMaster controls and the MultiLine String UITypEditor. I’ve been writing .NET code since I was an MS intern back in ’99 and if there’s one trick I learned during my 6 year tenure on the Windows Forms team it was how to use the framework source code for debugging as well as a great repository of well written code to borrow code from.

 

There were many times I was writing a bit of sample code and I needed to do something specific. I’d then realize, “oh the DateTimePicker does that” and I would crib the corresponding source from the framework code. The second sample mentioned above is a great example. In the .NET Framework 2.0 we added a multiline editor to the TextBox’s Text property in the property grid. A few customers asked how to add this to their controls and I grabbed the corresponding code from this from the framework and built a sample control around it.

 

The other big advantage of having the framework source code is debugging. No more dreaded “[External Code]” in call stacks and you’ll never have to look at disassembly because the source isn’t available. If you hit an exception you don’t understand, you can now step into the framework code that threw and see what it’s expecting to make everything work. This will save many trips to forums and newsgroups.

 

I realize that tools like Lutz Roeder’s excellent Reflector can help users understand the code in the framework, but there’s nothing as useful as diving into the framework code while it’s running in the debugger.

 

Hopefully the source code for the Silverlight framework will be released as well. Scott’s blog post has more information, screenshots and videos.