Table of Contents

Class LineDiffRenderer

Namespace
SnapshotAssertions
Assembly
SnapshotAssertions.dll

Renders a simple per-line comparison between two strings for use in assertion failure messages. Output uses unified-diff-style line prefixes (- for expected, + for actual) and is truncated to the first 20 differing lines so very large snapshots do not produce an overwhelming wall of text.

public static class LineDiffRenderer
Inheritance
LineDiffRenderer
Inherited Members

Remarks

The renderer is intentionally naive: lines are compared in lockstep by position, with no attempt at longest-common-subsequence alignment. For typical snapshot use (PublicApiGenerator output, rendered audit logs) this produces a useful diff. Consumers needing a well-aligned, insertion-aware diff should rely on the .expected.txt / .actual.txt file paths in the failure message and run their preferred external diff tool against the two files.

Fields

MaxDifferingLines

The maximum number of differing lines emitted before truncation. Matching (context) lines are not counted toward this limit.

public const int MaxDifferingLines = 20

Field Value

int

Methods

Render(string, string)

Renders a line-by-line diff between expected and actual.

public static string Render(string expected, string actual)

Parameters

expected string

The expected baseline content.

actual string

The actual content produced by the test.

Returns

string

A multi-line diff string, with each line prefixed by (context), - (expected only), or + (actual only). Truncated when the number of differing lines exceeds MaxDifferingLines.

Exceptions

ArgumentNullException

A required argument is null.