2

I have a project compiled and published on web server.

The copy of latest source code was lost. The copy I have right now is older one. There were alot of changes made after this copy of code.

How can I get my copy of Source Code up to date with the code on web server. The code on the web server is compiled and I have tried to decompile the code using-

  1. Telerik JustDecompiler
  2. DotPeek
  3. RedGate .NET Reflector

When these applications decompile the code, the syntax is also changed.

What would you suggest the best way to merge my code?

soccer7
  • 3,547
  • 3
  • 29
  • 50
  • 2
    "When these applications decompile the code, the syntax is also changed." - Well yes, it would be. You've lost information. You can't really get away from that. (I hope you now have proper source and deployment controls in place, btw...) – Jon Skeet Jan 13 '16 at 07:14
  • 1
    This is why you should use source control. At least start using from today. Btw you can't get the exact source code. IMO Reflector does a pretty good job in decompiling. – Sriram Sakthivel Jan 13 '16 at 07:14
  • We had the same problem and only possible way was to make reverse engineering by one of your listed tools. Hope you will find a better way! – Michael Jan 13 '16 at 07:19
  • If the project is not too complex or large, it might also be feasible to use the source you have, and the decompiled code you get, and rewrite it using both as a guide. Not ideal, but at this point you may be considering all options... – Kory Gill Jan 13 '16 at 07:34

1 Answers1

2

Sadly, there's no way to get exact source code automagically, even from byte-code. At best, you'll lose all comments and readability. It could take a lot of efforts to restore codebase back to maintainable state.

Your best option is to generate source code from compiled assemblies using Export assembly source code function in Reflector or Export to project in dotPeek, and then compare the "old" and "decompiled" versions of files with diff tool (you'll either need source control enabled in VS or invoke diff manually, as suggested there).

Community
  • 1
  • 1
cyberj0g
  • 3,707
  • 1
  • 19
  • 34
  • 1
    In addition, using by this tools generate source code from compiled assemblies from production server and from existing compiled source code of your project, then use something like WinDiff to find differences and minimize search scope. – Michael Jan 13 '16 at 07:52