Table of Contents

Class TextDiff

Namespace
NuvTools.AspNetCore.Blazor.Components
Assembly
NuvTools.AspNetCore.Blazor.dll

Compares two texts line by line (Myers' algorithm, the one behind git diff) and returns the rows of a side-by-side view. Within a changed line it marks the part that differs. Pure .NET, so it runs in WebAssembly and on the server alike.

public static class TextDiff
Inheritance
TextDiff
Inherited Members

Remarks

NuvTextDiff renders the rows as a component.

Fields

MaxEdits

Beyond this many line edits, the texts are shown as all removed and all added instead: the comparison would cost more than it tells for texts that have little in common.

public const int MaxEdits = 2000

Field Value

int

Methods

Compare(string?, string?)

The side-by-side rows that turn oldText into newText.

public static IReadOnlyList<TextDiffRow> Compare(string? oldText, string? newText)

Parameters

oldText string

The previous version. null or empty means no lines.

newText string

The new version. null or empty means no lines.

Returns

IReadOnlyList<TextDiffRow>