ITextDifferencingService Interface


This service has methods that compute differences over strings, snapshots, and spans. Differences are computed according to the specified StringDifferenceTypes, starting with the most general type (line is more general than word, and word is more general than character). This service is meant to be provided by extenders to override diff behavior by content type, thus allowing more control over the differences produced and how they align semantically (based upon the given language/content type).

public interface ITextDifferencingService


This is a MEF component part, and should be exported with the following attribute:


Component exporters must add at least one content type attribute to specify the content types for which the component is valid, such as [ContentType("basic")].

Use ITextDifferencingSelectorService to get the most specific ITextDifferencingService for a particular content type.

Implementers of this class are free to interpret differencing fairly liberally. For example, a text differencing service for C# files could perform differencing by namespace/class/method, and then return these results in line form (or whatever is requested by the StringDifferenceOptions). To that end, the results returned are also allowed to be non-minimal, allowing implementations to return results that fit better into the semantic model of a given language (in order to try to more closely match user intent, instead of being technically minimal). The normal contract of IDifferenceCollection<T> does still apply, however, in the sense that differences cannot overlap, be sorted, etc.

When calling into an instance of this interface and choosing a WordSplitBehavior, you should be using LanguageAppropriate, unless a different word splitting behavior is explicitly needed. This allows the individual implementation latitude to apply the best word splitting rules for the given content type.


DiffSnapshotSpans(SnapshotSpan, SnapshotSpan, StringDifferenceOptions)

Computes the differences between two snapshot spans, using the given difference options.

DiffSnapshotSpans(SnapshotSpan, SnapshotSpan, StringDifferenceOptions, Func<ITextSnapshotLine,String>)

Computes the differences between two snapshot spans, using the given difference options.

DiffStrings(String, String, StringDifferenceOptions)

Computes the differences between two strings, using the given difference options.

Applies to