Does anyone know of an advanced diff tool for C#?

.net, asp.net, c#, diff, visual-studio

Solution

I use http://winmerge.org/

I don't think you can do what you are asking, because of the way the longest common subsequence algorithms work for these tools.

Even if your functions get re-arranged, and your source file's functionality remains the same, it will still show up as a difference because of the nature of the LCS.

EDIT: This is a bit far fetched, but if you were feeling extra ambitious, you could write your own that tailors to your exact needs.

you could use regular expressions to pull out each method in a source file, and do the LCS diff on each method individually based on its name. You could store your code a Dictionary (key,value) so that the key is the name of the method and the value is the string of the function. Then you just diff your dictionary_orig['method'] with your dictionary_new['method'].

Other than that, I don't know how you'd accomplish what you are looking for.

Problem

I'm looking for a diff tool that can analyse my code and tell me what has changed on a construct by construct basis. For instance, if I cut and paste a method from the start of my file and put it at the end but leave that method unchanged, I don't want it flagged. If however I insert a line of code or change something inside that method, it would flag it as changed. I've used various diff tools, but all of them seem to fall short at telling you that lines have been inserted, removed or changed but couldn't tell what the changes were in any kind of logical fashion. It would be nice if when I periodically rearrange the layout of my code file the diff tool could keep up. Does anyone have such a tool?

Original source