Use the Algorithm.Diff.Diff class to compare two arbitrary lists of data. Normally the lists will be of characters, to perform a character-level comparison, or of strings, to perform a line-by-line comparison, of two strings. However, any object type may be used, and comparisons among objects in the lists will be made with the Equals method of the objects. Comparisons can also be performed according to a user-supplied IComparer and IHashCodeProvider.
For three-way diffs, see the Algorithm.Diff.Merge class.
The Algorithm.Diff.Patch class is used to store a compact representation of a Diff, containing only what is needed to transform the first list into the second list. For string-based lists, it can be serialized into and deserialzed from an XML format.
The Algorithm.Diff.Merge class represents a set of diffs against a shared original list. It is used to merge multiple revisions of the same document, for instance in performing n-way diffs.
The Diff class was translated into C# from the Perl module Algorithm::Diff. The Algorithm::Diff documentation says: "It uses an intelligent algorithm similar to (or identical to) the one used by the Unix "diff" program. It is guaranteed to find the *smallest possible* set of differences."
| Type | Description |
|---|---|
| Diff | Computes the differences between two arbitrary lists. |
| Diff+Hunk | A hunk is a segment of a diff. It relates a region of the base document to a region of the changed document. |
| Hunk | A hunk is a range in the original list that is in correspondence with ranges in one or more other lists. |
| IDiff | An interface representing objects that return Algorithm.Diff+Hunk objects. |
| Merge | A set of diffs all based on a common original document. |
| Merge+Conflict | A segment of a document returned by Algorithm.Diff.Merge.MergeLists for which there were conflicts among the revisions. |
| Merge+Hunk | A segment of the orginal document in which no revised documents had changes, or one or more revised documents had changes. |
| NodeInterface | This is a utility class for structured diffs and is not yet documented. |
| Patch | A compactly represented difference between an original document and a revision. |
| Patch+Hunk | A hunk is a segment of a patch. It relates a region of the base document to a region of the changed document. |
| Range | A window into another list. |
| StructuredDiff | This class is not yet documented. |
| TextDiff | Provides a differencing algorithm that is specialized for text documents. |
| UnifiedDiff | A utility class for generating diffs in the unified diff format. |
| XmlOutputNodeInterface | The is used for structured diffs and is not yet documented. |
| XmlOutputStructuredDiff | This is a utility class for structured diffs and is not yet documented. |