In 2007 ScottGu’s team announced they were releasing the .NET Framework source code for reference. Just a little later, Microsoft made it possible to step through the .NET Framework Source code while debugging. This was announced to much fanfare, and for a while, it was very cool. It wasn’t “Open Source” but it’s definitely “Source Opened.”
However, as time passed, the original Reference Source website for the .NET Framework sucked for a number of reasons, mostly because it wasn’t updated often enough.
It’s easy to browse the code, but if you’d prefer you can also download the .NET Framework source in a ZIPfrom the download link at the top of the site.
THE ROSLYN-POWERED .NET REFERENCE SOURCE BROWSER
There’s some very cool .NET-related stuff happening this year, and you’ll be hearing about it all soon. The new “Roslyn” compiler-as-a-service replacements for the C# and VB compilers have had the “Big Switch” flipped. We’re now getting an amazing totally-rewritten managed compiler that can enable features that weren’t possible when .NET started over a decade ago.
Today there’s a new team working on the .NET Reference Source, and Roslyn let the team generate a complete syntactic and semantic index of the .NET Framework Sources.
From the team: The version of the framework that we currently have indexed is .NET framework version 4.5.1. If this is something that folks agree is useful, our ongoing commitment towards this feature is to update this every major release i.e. an update for 4.5.2 and so on.
This is a crucial feature, IMHO, and they are recommitted to making it happen, and most importantly, keeping it fresh and updated. They are also thinking about maybe using the Monaco editor for the site as well.
Be sure to explore the browser and click on everything, as there’s a lot more there than just “search box and results.”
Here’s a few cool things you can do with the URLS on the new site that you should explore. I like being able to reference a line number in the URL for tweeting or IM’ing.
- Link to assembly /#System.Core
- Link to file /#mscorlib/system/environment.cs
- Link to line number /#mscorlib/system/environment.cs#56
- Link to a type/member /mscorlib/a.html#1f55292c3174123d (right-click the definition and choose Copy Shortcut)
- Link to search results /#q=Button%20PresentationFramework
There’s also a lot of flexibility in the search:
- Search for any full or partial type, or member name.
- Add any keyword like assembly, type, class, struct to filter the results
- Find projects by path like ndp\fx\src\data
- Find string literals like GUIDs: 03973551-57A1-3900-A2B5-9083E3FF2943
You can also actually click on types directly within the editor and find where they are referenced in the code.
They will switch the beta site at http://referencesource-beta.microsoft.com/ to take over the existing Reference Source site soon. Until then, use the Feedback link on the site and email the team directly! They are listening and actively working on this site.
The next thing the team is working on, and they are very close, is getting .NET Source Stepping (meaning you can just F11 into the .NET source code) to again work reliably when debugging, no matter what patch version you have of the .NET Framework on your local machine. Look for that in a few days on the .NET Team Blog.
BONUS: COMMUNITY VISUAL STUDIO EXTENSION
Here’s an exciting bonus. Community member and fabulous coder Schabse Laks has created a Visual Studio extension for VS2010, 2012, and 2013! This extension sends calls to Go To Definition (or pressing F12 on a symbol) directly to the code online (when it’s .NET Framework code, not yours).
You can download this companion “Ref12” Visual Studio Extension now! Just Goto Definition on any .NET type we have source for and it’ll launch your default browser so you can explore the .NET Framework source yourself! Thanks Schabse!
.NET REFERENCE SOURCE CODE LICENSING CLARIFIED
Finally, the licensing before was originally the very straightforward Microsoft Reference Source License, but then started to get other caveats tacked on like “don’t look at this if you aren’t using Windows” until it wasn’t really the MS-RSL at all.
They’ve changed that stuff. They’re back to the straight MS-RSL which is easy to read and clear. This means that folks can now look at this Reference Source and not have to gouge their eyes out afterwards. Which is great!
We all hope you like the new site and the team looks forward to your comments!