views:

106

answers:

6

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?

+2  A: 

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).

Oded
.NET framework library source code is available to **everyone**. Refer my answer!
Hemant
+3  A: 

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.

Adeel
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
+2  A: 

Have you tried Reflector? Might do the job.

Pike65
+3  A: 

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

bitbonk
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
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
A: 

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 ;)

Maupertuis
+3  A: 

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.

Hemant
+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
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
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
@jalf Well I tried in both Firefox and IE... what would you think? Can you download the .NET 4 one?
demoncodemonkey
@demoncodemonkey: yep. Just did
jalf
@jalf And can you tell me the size of it please?
demoncodemonkey