TextMerge Class
Merges two texts that were both changed from a common base, as diff3 and git merge do.
public static class TextMergeMethods
| Name | Description |
|---|---|
| Merge(string, string, string, TextMergeOptions?, CancellationToken) | Merges the changes made to baseText in oursText and in theirsText. |
Merge(string, string, string, TextMergeOptions?, CancellationToken)
TextMerge.csMerges the changes made to baseText in oursText and in theirsText.
public static TextMergeResult Merge(string baseText, string oursText, string theirsText, TextMergeOptions? options = null, CancellationToken cancellationToken = default)Parameters
baseTextstring- The common ancestor of both texts.
oursTextstring- The first changed version.
theirsTextstring- The second changed version.
optionsTextMergeOptions?- The diff options, and how to write the conflicts.
cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
TextMergeResult The regions of the merge and the merged text.
Exceptions
ArgumentNullExceptionbaseText,oursTextortheirsTextisnull.ArgumentOutOfRangeException- An option of
optionsis out of range. OperationCanceledExceptioncancellationTokenis canceled.
Remarks
Both versions are compared to the base. A region changed in only one of them takes that change; a region changed the same way in both takes it once; a region changed differently in both is a conflict. Changes that touch the same place, such as two insertions after the same line, are a conflict even when they do not overlap.