Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

While developing with Java in Eclipse it was very handy: you can attach sources and explore core java code just like your own. In Visual Studio I know about watching at the .net source code is possible only when debugging (and I can't say this feature works well).
Are there any alternatives of exploring .net source code?

share|improve this question

6 Answers 6

up vote 5 down vote accepted

Using ReSharper you can do "Go to Declaration" directly from within visual studio and it will take you the actual, original source code that is not part of your solution. It works both while debugging and in normal mode. It doesn't just work for the .NET source it works for any assemblies that you have pdbs for (given that the source code is anywhere on your disk or in your network).

In conjunction with the ReflectorNavigator PowerToy "Go to Declaration" even works for assemblies that you neither have the source code nor the pdbs for. It will use reflector behind the scenes to decompile the assembly and presents you the source code directly in visual studio.

Here is an article that discusses all that.

alt text

share|improve this answer
    
Which will go to the Object Browser, if it can't see the source code. It will not give you the source code for string.Split, for example. –  Oded Oct 6 '10 at 9:34
    
You have to configure resharper to do so. Then it will take you even to string.Split. String.Split is available in the .NET source code repository. I have updated my answer with an article describing all that. –  bitbonk Oct 6 '10 at 10:06

You can look at the Mono source code.

Mono is an open source implementation of the CLR and many base class libraries.

As for the Microsoft ones - they are proprietary, so any access to them is determined by Microsoft. As you have seen, debugging is one way of doing so and some companies have signed NDAs with Microsoft that allow them to see the source (an unlikely option for any individual, unfortunately).

Having said that, some libraries are available to download (provided you agree to the EULA), as @Hemant says in his answer.

Another option (since all of the .NET library code is compiled to IL) is to use a tool like Reflector to see a disassembled version (it will not give you the original C#, but a best effort decompilation).

share|improve this answer
1  
.NET framework library source code is available to everyone. Refer my answer! –  Hemant Oct 6 '10 at 9:40

you can see the source code from the tool called Reflector. Some companies obfuscate their DLLs(for security reasons) in which case Reflector will unable to show source code.

share|improve this answer
2  
Reflector is a great tool - but for the .Net source code itself you can download the actual source code (which has code comments and private variable names etc), together with the debug symbols to allow you to step into the code in the IDE. Nothing wrong with suggesting reflector, but specifically for the .Net Framework source code, I think the actualy source is often a better choice. –  Rob Levine Oct 6 '10 at 9:52

Have you tried Reflector? Might do the job.

share|improve this answer

You should take a look at Reflector which allow you to read bytecode compiled .NET assemblies. It's a mandatory tool for any .NET developper ;)

share|improve this answer

Source code of many .NET framework libraries is available for download. It is released under reference license so you can certainly browse through code.

Also refer this and this blog post about how to setup visual studio to step-in while debugging.

share|improve this answer
    
+1 - everyone else has mentioned Reflector, which is a great tool, but you are the only one so far to actually suggest using the real source code. Where available the original source code is far preferable to decompiled source code as it has all the original comments/variable names etc. –  Rob Levine Oct 6 '10 at 9:39
2  
OK I downloaded a couple of .MSI files from that link but they are both corrupt... seems like a half-assed offering from Microsoft. –  demoncodemonkey Oct 6 '10 at 9:54
    
Considering that a lot of people have successfully downloaded those files, perhaps, just perhaps, the problem isn't on Microsoft's end. But hey, it's more fun to flame Microsoft, isn't it? –  jalf Oct 6 '10 at 10:12
    
@jalf Well I tried in both Firefox and IE... what would you think? Can you download the .NET 4 one? –  demoncodemonkey Oct 6 '10 at 10:14
    
@demoncodemonkey: yep. Just did –  jalf Oct 6 '10 at 10:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.