Compartir a través de


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).

Namespace:  Microsoft.VisualStudio.Text.Differencing
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)

Syntax

'Declaration
Public Interface ITextDifferencingService
public interface ITextDifferencingService
public interface class ITextDifferencingService
type ITextDifferencingService =  interface end
public interface ITextDifferencingService

The ITextDifferencingService type exposes the following members.

Methods

  Name Description
Public method DiffSnapshotSpans(SnapshotSpan, SnapshotSpan, StringDifferenceOptions) Computes the differences between two snapshot spans, using the given difference options.
Public method DiffSnapshotSpans(SnapshotSpan, SnapshotSpan, StringDifferenceOptions, Func<ITextSnapshotLine, String>) Computes the differences between two snapshot spans, using the given difference options.
Public method DiffStrings Computes the differences between two strings, using the given difference options.

Top

Remarks

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

[Export(typeof(ITextDifferencingService))]

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.

See Also

Reference

Microsoft.VisualStudio.Text.Differencing Namespace