C# view source code of a particular .NET class - c#

I browsed through some questions and this one stood out as the better one:
.Net Classes and their source code which pointed me to this place here: Microsoft Reference Source Server.
I tried everything the site says, downloaded a file that I cannot open from there and at some point ended up with a .pdb file in my source folder for the symbol cache that I could not open with a multitude of tools I looked into.
So this is my last resort to find an answer to my question. Out of pure curiosity (and lack of a better way to understand some stuff) I want to open a particular class from Microsoft (namely I wanna look into RichTextBox and maybe the classes it inherits from) but I simply cannot find a way to make this work for me. I want the original source, not a decompiler product because, well because I mainly need to understand some stuff, not see random variable names. I appreciate any help that may get me around my stupidity and clumsiness, as well as the right tools to do so (if any other than VS).
Note that I am using Visual Studio 2012 and yes, I went over a guide covering this specific version instead of the guide on VS 2008.

The "download" links on this page: http://referencesource.microsoft.com/netframework.aspx should work. However try downloading them via Internet Explorer; my Firefox attempted to download an .aspx file instead of the installer itself for some reason. (EDIT: as #ParagMeshram pointed out, just rename the netframework.aspx to netframework.msi as a quick fix if necessary)
In addition, here's a link to the source hosted by dotnetframework.org: http://www.dotnetframework.org/default.aspx/4#0/4#0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/wpf/src/Framework/System/Windows/Controls/RichTextBox#cs/1305600/RichTextBox#cs
I can't say for certain if it's the latest greatest, or what you would be compiling against exactly, but should give you a good idea of how it works.

Related

Where is the snippet for a method's XML summary?

I'm referring to the snippet that's used when typing /// before a method.
I've found something for JavaScript (C:\Program Files (x86)\Microsoft Visual Studio 14.0\JavaScript\Snippets\1033\XML Comments) but changing it didn't affect the C# XML summary.
I'm aware of this question but the accepted answer doesn't really answer this question, and the second answer is outdated.
As requested by OP, not sure if it's an answer - but there doesn't seem to be a better one at the moment, unfortunately...
This may be helpful, this is a User Voice for this and still unresolved as it seems.
As per the #HenkHolterman's comment - that I agree with - I don't think that's a snippet. For the moment it seems to be built into VS (out of curiosity I searched through VS 15 - new version not the 2015, and nothing new in there either - I searched all files for anything resembling XML comments).
There's a VB solution that, as I could see, places a custom .XML file in the specific AppData location - which doesn't work for C#. They describe the process as...
Visual Studio has built-in defaults for the XML skeletons that get
inserted, but when VBXMLDoc.xml is present upon startup, Visual Studio
will use the XML definitions from that file instead
As per a comment above - there's a User Voice request for it. And as per a comment on the User Voice - it can be done in VB but not C#.

made changes, compiled and regret

I made today few changes by ctrl+h to all the solution.
When I understood my mistakes I tried to undo it with ctrl-Z but the results were awful.
The question is : How can I reload the last compiled project before I had done this stupid move.
Lets say I want the solution as it was at yesterday.
Thanks for your help,
Eliran.
you can try decompiling the old binary with tools like dotPeek. But in general that is the reason why you use a source control system.
You cannot. Once saved, the changes are irreversible. That's the point of backups. There are tools to decompile your .NET executable, but as not all sourcecode is actually compiled into the executable (for example formatting and comments are not), you will never get your original code back.
You may want to look into source control software like Git, Subversion or Team Foundation Server to handle this problem properly next time.

How to check in only some parts of the program in Visual Studio Team Services?

Additional info: I thought it might be helpful to say that my forms and classes are in the same solution as the already updated forms.
In our company we have this project which 3 people are working on it. One works on the database part, me and another colleague of mine are working on making the UI ready and relating it to database which is MS SQL Server 2012 and we are programming in C# in VS 2012.
The problem is that I made this one form ready, but the server version is ahead of me. That is, if I check in the whole program, I will damage the project as some forms has changed and the version I have is older. I tried right clicking and checking in only the forms and classes which I, myself made and I have their latest version. They check in without any error or anything, but the problem is, when my colleagues or myself(after deleting my source project) try to get latest version, my forms or classes doesn't show up.
We also tried to check in the whole program but only accept those pending changes which are made by me, still no success.
The problem is, we are kinda afraid to play with the server version as a lot of effort has gone into it.
Any help will be really appreciated as I'm stuck with this problem and the manager won't give me more parts of the program to make until we can come up with some way to deal with this.
You haven't mentioned merging at all but I think this is the answer to your question.
When you work on an older version of the code (because your local code is older, or maybe the whole branch of the code is older), you need to merge the code into the newer version. When you merge, any potential conflicts are detected and you can resolve all of them manually. There's obviously tools to help you - one is built into Visual Studio but you can replace it with an external tool which may work better for you. Either way, you need to decide how to merge the code. You have a few options:
take the whole code from the source (old code in this case),
take the whole code from the target (new code in this case),
merge the changes and take bits from each version based on your knowledge of the changes and how the code should look like.
As for why the forms don't show up, you probably didn't check in the changes to the project file so the new files are not part of the project as it exists in Team Services.

How to write and testing ASP.NET 4 on notepad?

Conditions:
I've been asked to develop a simple ASP.NET 4(C#) project in notepad. I'm completely new to this area.
The completed project should include several .aspx files, one master page, one sitemap and a web.config.
The book I'm using is a beginner cook book, based on using Visual Studio 2010 Express.
Developing it on notepad is a requirement to this school assignment.
Questions:
As what I know now VS2010 has its built-in Development Web Server which notepad doesn't. Should I test .aspx files by opening notepad files in browser? Will tags with runat="server" work?
Is there any helpful site or post that you know?
How should I testing master page?
Forgive my noob questions. The most sites I can find is teaching people how to develop by using VS2010, which is like my book, instead of notepad. The schedule is tight so I need some help here. Thank you for your time. I'll also share my experience when I finish this assignment.
It's a little more complicated than "runat="server"".
To give a little bit of 101, you will need:
A web server. The most natural one to use is IIS. I believe you should be able to use Apache as well if you're feeling adventurous.
The application framework. Guess what, it's .NET! There's also Mono if you're not using IIS. The application framework should also include the compiler. C# is a compiled language, so before you can run the code, you will have to compile it first. This is slightly different when compared to PHP.
The editor. You should be able to use Notepad, but Visual Studio provides you with more than just a fancy text editor. It helps you create the build script (the command that you send to the compiler), it helps you with project organization, and it helps you debugging.
So just using Notepad is doable, but you'll lose so much time for not using a free tool like Visual Studio Express.
Now to actually answer your questions:
No, it doesn't work that way. You will need a web server (see point 1 above) and a compiler (see point 2 above).
That's a little bit too broad. Your book should be a good starting point.
See answer 1.
I have finished that assignment. Here is my experience:
First, to develop an ASP.NET project on notepad or textpad is very unwise, unless you want to test your coding skill or having some other reasons. Because for beginner the best way to test your code is using VS "Ctrl+F5". If you write your code in notepad/textpad and test them in VS, it kind of defeat the original purpose.
There is a few tips, for the beginner like me.
Named your sitemap file "web.sitemap", and put it in the root directory of your project, otherwise you may have to go through complicated configuration process.
P.S. This is not a compulsory requirement, you can change the file name or directory, but you need to add site map provider in "web.config".
2 Choose your solution or project root directory carefully, because it is not easy to redefine it.
P.S. I spent a lot of time to move files around in Windows Explorer because I wanted to change my current solution directory to another folder.
These are the tips I find most useful. I would've saved at least 2 hours if I know these in the beginning.

Visual Studio 2008 C# - Recover solution from application manifest possible?

Hello I recently deleted what I thought was an unused folder which happened to have the solution and code for a windows application I am maintaining.
I have published the app multiple times with ClickOnce and have access to the application manifest, deploy, etc. Is there a way for me to use the published application to get back my solution?
Thanks
If you don't currently use source control, I would highly recommend using one. I'm not aware of a way to get back all the solution files without source control, but you can get back the code using .NET Reflector. There is a file disassembler add-in which allows you to dump the code straight out of Reflector.
not possible. you can't recover the solution and original code from the compiled and deployed version.
if you have not used that machine or hard drive since you deleted it, you may be able to recover the files but it's a long shot and may be expensive.
you need to invest some time in learning source control. git, mercurial, subversion... they're all free and easy to use in windows. having your code in source control would prevent this problem - delete it all you want, just do a checkout from source control again.
Just go get the project back from Subversion.
Basically all you can do at this point is feed the assemblies to a program like reflector and reverse engineer it back. Welcome to sucksville.
If you don't have your stuff in some type of repository already I'd highly recommend fixing that first thing in the morning. With free tools like subversion available, nevermind things like TFS or even VSS there just isnt a good excuse.

Categories

Resources