This project is read-only.
How to get started?

Here are all the steps to get started. Depending of your knowledge of Microsoft Visual Studio, it can take 15 minutes to 1 hour.
  1. Create a temporary folder (named C:\TempFolder here) where you will setup everything.
    1. Download latest version of Reflector and unzip it - http://www.red-gate.com/products/reflector/
    2. Download CrossNet sources - http://crossnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=7414
    3. Download CrossNetSystem sources - http://crossnetsystem.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=7856
  2. Unzip all and remove read only attributes for all the files (except if you are using a revision control system).
  3. Open Microsoft Visual Studio 2005. If you are using 2008, it will upgrade the projects automatically for you.
    1. Create an empty solution.
    2. Move the parent folder of each projects in the same folder as the solution file. (i.e. we skip the package name and version). Although you can have put the projects where you want, it will reduce the setup later.
    3. You should end up with something like that:
      1. C:\TempFolder\CrossNet.sln
      2. And for each project (like for CrossNetRuntime):
      3. C:\TempFolder\CrossNetRuntime\CrossNetRuntime.vcproj
      4. C:\TempFolder\CrossNetRuntime\includes\...
      5. C:\TempFolder\CrossNetRuntime\sources\...
      6. So each project file should be one level below the solution file.
  4. Add every projects to the solution. You should have 7 projects in the solution:
    1. CplusplusBenchmark
    2. CrossNetBenchmark
    3. CrossNetParser
    4. CrossNetRuntime
    5. CrossNetSystem
    6. CSharpBenchmark
    7. Reflector.CrossNet
  5. Duplicate the file Reflector.exe and rename it to Reflector.dll. You will need to do that everytime you update the version of Reflector.
  6. Open the projects "CrossNetParser" and "Reflector.CrossNet" and update the references to the Reflector.dll that you just created.
  7. Now we need to fix up the runtime references and the BCL references to CrossNetBenchmark, we are going to use CrossNetSystem for that. Open CrossNetBenchmark properties, go into the Configuration properties -> Linker -> Inputs
    1. In additional dependencies, type: ..\$(ConfigurationName)\CrossNetRuntime.lib ..\$(ConfigurationName)\CrossNetSystem.lib
    2. Build CrossNetBenchmark and there should be no compile / link error.
  8. Now compile CrossNetParser and you should have 4 compile errors. This is expected. Since October 2007, Reflector API changed for the using keyword. For the moment, replace .Variable by .Expression. I'll send you a real fix if you are using "using" :) Sorry about that.
  9. At that point you should be able to compile the whole solution without any error.
  10. Copy Reflector.CrossNet.dll and CrossNet.dll where you have Reflector.exe. If you built the whole solution, the two dlls should be in the bin folder of Reflector.CrossNet.


Now that everything is configured correctly we can start to have fun.
  1. Compile CSharpBenchmark. If you want to run it and see what the benchmark does:
    1. Rename the method Test() in the class CSharpBenchmark._Benchmark.Benchmark to Main()
    2. Make the library a console application.
    3. Run the C# Benchmark.
  2. Revert these changes for the C++ conversion.
  3. Once compiled, go in the folder Reflector.CrossNet and modify example.xml like this:
    1. Change <OutputFolder>YourOutputPath</OutputFolder> to <OutputFolder>C:\TempFolder\CrossNetBenchmark\</OutputFolder>
    2. Change <AssemblyToParse>FirstPath\FirstAssembly.dll</AssemblyToParse> to <AssemblyToParse>C:\TempFolder\CSharpBenchmark\bin\Debug\CSharpBenchmark.dll</AssemblyToParse>
    3. Remove <AssemblyToParse>SecondPath\SecondAssembly.dll</AssemblyToParse>
    4. Make sure that the paths are correct.
    5. You will need to change the xml file only when adding new assemblies (to parse or to reference)
  4. Run Reflector.exe, select .NET 2.0 runtime version (it should not matter but never know).
    1. Go in View -> AddIns, and add Reflector.CrossNet to the list of add-ins.
    2. If you regularly use Reflector make sure that the optimization mode is set to .NET 2.0 (not 3.0+).
    3. Close Reflector.exe.
    4. Open the command prompt (run cmd.exe) and go in the folder where Reflector.exe is located (and the 2 other dlls).
    5. Type: Reflector.exe /crossnet:C:\TempFolder\Reflector.CrossNet\Example.xml
    6. This will show Reflector UI for few seconds and should close it after a short beep.
    7. If you go in CrossNetBenchmark folder you should see the C++ sources updated.
  5. Go back to Visual Studio, compile again CrossNetBenchmark, it should compile and link correctly (there may be some link warnings about missing pdbs).
    1. You can now run the benchmark (C# code translated in C++).
  6. List of things that you should consider at some point:
    1. Make step 4 a post-build step to the step 1. (using a batch file).
    2. Switch the C++ code to release to have real performance.
    3. Tweak the compile flags to optimize more. Set the dependencies correctly in the solution.
    4. Modify the C# benchmark code or reference your own assembly instead.
    5. Remember to augment CrossNetSystem if you are using more CLR classes (and share with the community).
    6. etc...

Enjoy and have fun!

Last edited May 12, 2010 at 2:38 AM by OlivierNallet, version 5

Comments

mjaggard Nov 11, 2010 at 3:55 PM 
Reflector crashes each time I run it with /crossnet :-(