views:

124

answers:

4

Can you recommend a good file comparison utility that is able to handle C# very well. I have tried both WinMerge, BeyondCompare and KDiff and they are not good enough, e.g. if I have functions with the same name but placed in different areas of the file they show it as differences.

A: 

I don't think you're going to find a text compare utility that will do this. You're better off reorganizing the functions so they are in the same places. I've seen designer generated code do this (ie, move functions around every time the file gets regenerated). Its annoying, but I don't think you're going to get around it. BeyondCompare really is one of the best comparison utilities out there.

Tim Coker
+1  A: 

Unfortunately, that is kind of the nature of Diff. It's always been a line by line comparison, it's not a language aware comparison. As far as I am aware there is nothing that does what you are asking for (It's always possible I'm wrong though).

You could use a tool like regionerate to standardize class layout before you do the comparison. This would order all your methods, so you wouldn't have the problem with a method of the same name being in different places in a file.

Simon P Stevens
+1  A: 

The only tool I am aware of that may be able to do this (I am not sure it can) is Git.

As far as I know, it can track functions even if they are moved to different files, so using it in this scenario would not show a difference.

See this answer for more detail.

Oded
A: 

I am using Devart CodeCompare for this task. Native VS editor allows me to handle C# and VB very well. They call this feature "Structure comparison". It will be useful for you.

JackD