Use the. NET Reflector plug-in FileDisassembler to restore the source code

Source: Internet
Author: User
Tags assert reflection reflector
 
. NET Reflector, which is a class browser and anti-compiler that can analyze the assembly and show you all its secrets .. The NET framework introduces reflection concepts that can be used to analyze any. NET-based code (whether it is a single class or a complete assembly) all over the world. Reflection can also be used to retrieve information about various types, methods, and attributes contained in a specific set of programs. Use. NET Reflector, you can browse the assembly classes and methods, you can analyze the Microsoft Intermediate Language (MSIL) generated by these classes and methods ), in addition, you can decompile these classes and methods and view C # or Visual Basic ?. . NET.
To demonstrate how. NET Reflector works, I will load and analyze the NUnitExample assembly shown earlier. The following figure shows the assembly loaded in. NET Reflector.
In. NET Reflector, there are various tools available to further analyze the assembly. To view the MSIL that constitutes a method, click the method and select discycler from the menu.
In addition to MSIL, you can select Decompiler under the Tools menu to view the C # Format of this method. By changing your selection under the ages menu, you can also view the form in which this method is decompiled to Visual Basic. NET or Delphi. The code generated by. NET Reflector is as follows:
Public void HashtableAddTest (){
Hashtable hashtable1;
Hashtable1 = new Hashtable ();
Hashtable1.Add ("Key1", "value1 ");
Hashtable1.Add ("Key2", "value2 ");
Assert. AreEqual ("value1", hashtable1 ["Key1"], "Wrong object returned! ");
Assert. AreEqual ("value2", hashtable1 ["Key2"], "Wrong object returned! ");
}
The previous code looks like the code I actually wrote for this method. The actual code in this Assembly is as follows:
Public void HashtableAddTest (){
Hashtable ht = new Hashtable (); ht. Add ("Key1", "value1 ");
Ht. Add ("Key2", "value2 ");
Assert. AreEqual ("value1", ht ["Key1"], "Wrong object returned! ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.