Skip to content
ConsoleMonster
Class

ObjectDiff

ConsoleMonster.Changes

Namespace
ConsoleMonster.Changes
Assembly
ConsoleMonster
Modifiers
static

Compares objects and collections: objects are matched by key, then compared property by property (nested objects by path), giving added, removed and changed objects with counts. Show the result with ChangeView or ask before acting with ChangePreview.

Inheritance

  • object
  • ObjectDiff

Methods

Compare 2 overloads
public static ChangeSet Compare(object? before, object? after, DiffOptions? options = null) #

Compares two values: two collections item by item (matched by key), anything else as one object.

Parameters

before object? required
The old value.
after object? required
The new value.
options ConsoleMonster.Changes.DiffOptions? = null optional
Options, or null.

Returns

ChangeSet The change set.
public static ChangeSet Compare(IEnumerable<object?> before, IEnumerable<object?> after, DiffOptions? options = null) #

Compares two collections: items are matched by key and compared property by property.

Parameters

before System.Collections.Generic.IEnumerable<object?> required
The old items.
after System.Collections.Generic.IEnumerable<object?> required
The new items.
options ConsoleMonster.Changes.DiffOptions? = null optional
Options, or null.

Returns

ChangeSet The change set.
public static BaselineComparison CompareBaseline(IEnumerable<object?> objects, DiffOptions? options = null, IReadOnlyList<string>? names = null) #

Compares two or more objects as property rows against a reference column.

Parameters

objects System.Collections.Generic.IEnumerable<object?> required
Objects in column order; null represents an object with no properties.
options ConsoleMonster.Changes.DiffOptions? = null optional
Shared path, depth, normalization, equality and baseline selection options.
names System.Collections.Generic.IReadOnlyList<string>? = null optional
Explicit column names, or null to use the key selector and default key properties.

Returns

BaselineComparison The structured comparison for BaselineView.
public static IReadOnlyList<PropertyChange> CompareObjects(object? before, object? after, DiffOptions? options = null) #

The changed properties of two objects (nested objects by path, up to DiffOptions.Depth).

Parameters

before object? required
The old object.
after object? required
The new object.
options ConsoleMonster.Changes.DiffOptions? = null optional
Options, or null.

Returns

IReadOnlyList<PropertyChange> The changes.
public static string PairText(object? value, object? other) #

A value as display text next to the value it is compared with: when two different dates would read the same (they differ below a minute), the seconds are shown, so a change never looks like no change.

Parameters

value object? required
The value.
other object? required
The value on the other side.

Returns

string The text.
public static string Text(object? value) #

A value as display text: null as empty, collections as {a, b}.

Parameters

value object? required
The value.

Returns

string The text.