You probably already noticed that Microsoft has enabled access to the source code of parts of the .NET Framework 3.5. Here is the announcement of availability in case you missed it. And there are detailed instructions on how to enable this as well.
This morning I started stepping into the Windows Presentation Foundation. Before I knew it I was deep down into the internals of dependency properties and the Dispatcher object. The dispatcher has a nice old-fashioned message pump. I stepped into the dispatch of a message call onto a non-UI thread. Even though I already knew this, it is still startling to see that this translates into old-fashioned User32 Windows messages being send.
What really surprised me was to see a bit of VB code in a file that is called ExceptionFilterHelper.vb. According to the comment this file was needed because C#, unlike VB, does not support exception filters. However, the filter always returns true. According to the comment in the source code it is a “dummy stub to keep compiler happy, will not be replaced”.
Something weird is going on here. The debugger shows I am in WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen. The source code file shows the class MS.Internal.Threading.ExceptionWrapper.TryCatchWhen. Reflector can only find the former class. The disassembly of this class shows source code that is very different than what the MS source code server gives me.
This doesn’t make much sense to me. Is the source code for this class deliberately hidden or is there some error in the source code lookup?
Since I haven’t had my lawyer take a look at the license agreement that governs the source code access, I will not add a screen shot of the VB code 😉