5

My Situation:
So, I decompiled a .NET assembly with ILSpy into C# last week; since, then, I've put a ton of labour into massaging the files/project, etc. so that they all work correctly again (there were lots of little bugs [mostly caused by ILSpy's code generation process] and random issues and I've been fixing them as I go). I'm now inches away from my goal, with the finish line in sight!

But, lo, and behold: I just realized all of the XML comments are missing. >.<

I did some scouring and I was able to find the .xml intelli-sense file, with all the Visual Studio generated comments inside.

What I would Like to Accomplish:
I would LIKE to copy these comments from the generated .xml intelli-sense file back into the source files (in an automated fashion of course, as there are about 5000 classes in this Assembly).

My Question:
How should I proceed? Are there any tools that can do help me automate this task?

4

2 回答 2

1

Since code files are generated using a tool (ILSpy), code style and formatting (whitespaces and indentations) will be same for almost every code file. What I would do is

  1. check if decompiling of that 5000+ class library is against the law,
  2. write a simple parser to parse code files and find class/method/property definitions
  3. check if what I've found matches with what is in xml
  4. If everything is ok, then I would copy found xml tags to their new position on code files since now that I know positions of definitions in a file.

PS: just a reminder, to ease string replacing/inserting, always do inserting from bottom of the file to top of the file. this way, whenever you insert a line, indexes of other lines to be inserted will remain same.

于 2013-06-12T07:04:34.770 回答
1

You could use the Roslyn CTP for C# to make a tool that would reinsert the comments into the source files. (http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx) Roslyn creates a tree like structure of your C# code that you can manipulate programmatically and then write back to a file.

于 2013-06-17T16:07:12.747 回答