From http://www.cnblogs.com/wuliangbo
Reflector for. Net: http://www.aisto.com/roeder/dotnet/
Tool for reflector. filedisassembler. dll CS file: http://www.denisbauer.com/Downloads/Reflector.FileDisassembler.zip
1. Download reflector.filedisassembler.zip and decompress the package to obtain some files. The reflector. filedisassembler. dll is compiled, and the others are its source code;
2. Open reflector, add-ins under the View menu, and add reflector. filedisassembler. DLL to it;
3. Open a DLL, EXE, or MCL file. Of course, you must support. Net files.
4. Select the DLL to be decompiled (displayed in the list), select Tools-> file discycler, and the path for storing source code is displayed in the right window. Click Generate!
However, using filedisassembler to compile a CS file may cause a bug where variables, classes, and namespaces are sometimes renamed.
Fortunately, when filedisassembler is released with the source code, it saves the need for reflect. After all, the temporary variable name generated by the machine still looks uncomfortable. It's easy to fix this bug. I modified the createfile method and added a getuniquefilename method. The source code is as follows:
Private streamwriter createfile (string directory, string filename)
{
Directory = directory. Replace ("<","_");
Directory = directory. Replace ("> ","_");
Directory = directory. Replace (":","_");
Directory = directory. Replace ("| ","_");
Directory = directory. Replace ("? ","_");
Directory = directory. Replace ("*","_");
Directory = path. Combine (this. outputdirectory, directory );
Ilanguage Language = This. languagemanager. activelanguage;
String fileextension = language. fileextension;
Filename = filename. Replace ("<","_");
Filename = filename. Replace ("> ","_");
Filename = filename. Replace (":","_");
Filename = filename. Replace ("| ","_");
Filename = filename. Replace ("? ","_");
Filename = filename. Replace ("*","_");
Filename = path. Combine (directory, filename );
Filename = path. changeextension (filename, fileextension );
Filename = getuniquefilename (filename );
This. writeline (filename );
Directory = filename. substring (0, filename. lastindexof ('""'));
If (! Directory. exists (directory ))
{
Directory. createdirectory (directory );
}
Streamwriter writer = new streamwriter (filename );
Return writer;
}
Private hashtable filenames = new hashtable ();
Private string getuniquefilename (string filename)
{
String strextension = path. getextension (filename );
Filename = filename. Replace (strextension ,"");
String _ filename = filename. tolower ();
Bool bfirstrename = true;
While (filenames. Contains (_ filename ))
{
String existfilename = (string) filenames [_ filename];
String [] efnparts = existfilename. Split (New char [] {'"'});
String [] fnparts = filename. Split (New char [] {'""'});
For (INT I = 0; I <fnparts. length; ++ I)
{
If (efnparts [I]! = Fnparts [I])
{
If (bfirstrename)
{
Fnparts [I] + = '_';
Bfirstrename = false;
}
Fnparts [I] + = 'X ';
Break;
}
}
Filename = string. empty;
For (INT I = 0; I <fnparts. length; ++ I)
{
Filename + = '"' + fnparts [I];
}
Filename = filename. substring (1 );
_ Filename = filename. tolower ();
}
Filenames [_ filename] = filename;
Return filename + strextension;
}