Any decent text diff/merge engine for .NET?

I think the "Generic - Reusable Diff Algorithm in C#" on Codeproject is the best you can find as a .NET-Engine for diff/patch/merge. I made a project on my own with it and it fits my needs with most scenarios. There are one or two worst-case scencario when the algorithm made the patch-file larger than it have to be. But in most of the cases it works just fine for me (textfiles with a size of >30 MB).

I'm currently testing another Codeproject-Project you can find here: http://www.codeproject.com/KB/applications/patch.aspx It's using some DLLs from Microsoft for patching, so it looks interesting. But those DLLs are unmanaged and this project is only some sort of wrapper for it. But maybe it can help you

Edit: Just found another project, DiffPlex: http://diffplex.codeplex.com/ It's a combination of a .NET Diffing Library with both a Silverlight and HTML diff viewer. As stated there, DiffPlex is the library that CodePlex leverages to generate the diffs of files.


You can grab the COM component that uses Google's Diff/Patch/Match. It works from .NET.

Update, 2010 Oct 17: The Google Diff/Patch/Merge code has been ported to C#. The COM component still works, but if you're coming from .NET, you'll wanna use the .NET port directly.


GitSharp includes a diff engine based on meyers diff. Take a look at the demo which implements a simple wpf diff viewer based on the Diff.Sections collection: http://www.eqqon.com/index.php/GitSharp#GitSharp.Demo


None of the answers so far (except possibly the GitSharp reference) deal with 3-way merge, so in case it helps anyone I recently ported Tony Garnock-Jones' javascript diff3 implementation (from the synchrotron project, based on Hunt and McIlroy 1976) to C#.

It's a simplistic single-file port of diff and three-way merge methods, but it's the standard algorithm and so far works very well for me: https://gist.github.com/2633407

Tags:

.Net

Merge

Diff