Developer

Use Microsoft's Reference Source To View .NET's Original Code

One of that great things about .NET is that inspecting compiled code is simple — fire up your IL (Intermediate Language) disassembler of choice, crack open the library in question and as long as it’s not obfuscated, you can see a very close interpretation of the source.

If it’s Microsoft’s own libraries you want to check, you can do better — the company’s Reference Source site, which includes the original comments and unaltered code for all the base DLLs.

The disadvantage of IL dissemblers is that you don’t get comments — they’re obviously ignored at compile time — and compiler optimisations can make it a little harder to discern what’s going on.

With Microsoft’s Reference Source, it’s the same code that gets put into the compiler. On top of this, most classes, including HashSet above, are well-documented so it’s great as a learning tool also.

The difference between Reference Source and say, viewing CoreFX on GitHub is that the former is much, much easier to search. Still, if you actually want to use the source in some form, grabbing it via GitHub is the better way to go.

Reference Source [Microsoft]


Have you subscribed to Lifehacker Australia's email newsletter? You can also follow us on LinkedIn, Facebook, Twitter and YouTube.

Trending Stories Right Now