C# file comparison utility [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this questionCan 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.
At this moment (april 2015), there are at least 3 commercial comparison tools that have into account the structure of C# code files to make an advanced diff and merge between code files:
- Coode Software Code Compare++
- Devart Code Compare
- Semantic Merge
These three tools support this kind of advanced comparison only on the payed versions (or the trial periods). AFAIK there is no free tool that can do this.
[Update (2015): Since writing this answer there are now more modern tools that can do structural and semantic merging and diffing of code in various languages. See JotaBe's answer for some examples]
Original answer (2010): 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.
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.
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.
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.
精彩评论