# OfficeDiffResult<T>

Edit script between two sequences produced by OfficeDiff.

Class 

`OfficeIMO.Diff`

**Namespace**

`OfficeIMO.Diff`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[OfficeDiffResult.cs:71](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L71)

**Modifiers**

sealed

Edit script between two sequences produced by [OfficeDiff](/api/core/officeimo-diff-officediff/).

## Inheritance

- object
- OfficeDiffResult<T>

## Usage

Explore 7 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 5

- Method [OfficeDiff.CompareCharacters](/api/core/officeimo-diff-officediff/#method-comparecharacters-string-string-officeimo-diff-officediffoptions-threading-cancellationtoken)
- Method [OfficeDiff.CompareLines](/api/core/officeimo-diff-officediff/#method-comparelines-string-string-officeimo-diff-officediffoptions-threading-cancellationtoken)
- Method [OfficeDiff.CompareTokens](/api/core/officeimo-diff-officediff/#method-comparetokens-collections-generic-ireadonlylist-officeimo-diff-officetexttoken-collections-generic-ireadonlylist-officeimo-diff-officetexttoken-officeimo-diff-officediffoptions-threading-cancellationtoken)
- Method [OfficeDiff.CompareWords](/api/core/officeimo-diff-officediff/#method-comparewords-string-string-officeimo-diff-officediffoptions-threading-cancellationtoken)
- Method [OfficeDiff.Compare``1](/api/core/officeimo-diff-officediff/#method-compare-collections-generic-ireadonlylist-collections-generic-ireadonlylist-collections-generic-iequalitycomparer-officeimo-diff-officediffoptions-threading-cancellationtoken)

### Accepted by parameters 2

- Method [OfficeChangeSet.FromTextDiff](/api/core/officeimo-diff-officechangeset/#method-fromtextdiff-officeimo-diff-officediffresult-officeimo-diff-officetexttoken-officeimo-diff-officechangesetoptions) parameter `diff`
- Method [OfficeUnifiedDiff.Format](/api/core/officeimo-diff-officeunifieddiff/#method-format-officeimo-diff-officediffresult-officeimo-diff-officetexttoken-string-string-int32) parameter `lineDiff`

## Type Parameters

**T**

Item type.

Filter members 

Show inherited

## Methods

`public IReadOnlyList<T?> Apply(IReadOnlyList<T?> source)` [#](#method-apply-collections-generic-ireadonlylist)

[OfficeDiffResult.cs:71](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L71)

Applies the edit script to source and returns the new sequence. Every kept and deleted item is checked against the item recorded in the script; kept positions return the recorded new item, so a comparer that ignores case or position still yields the new values.

Parameters

**source System.Collections.Generic.IReadOnlyList<T?> required**

Returns

`IReadOnlyList<T?>`

Exceptions

- `InvalidOperationException` – The source does not match the old sequence this script was computed from.

`public IReadOnlyList<OfficeDiffHunk> GetChangedRegions()` [#](#method-getchangedregions)

[OfficeDiffResult.cs:130](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L130)

Groups the edit script into changed regions: each region is a maximal run of deletions and insertions between unchanged items.

Returns

`IReadOnlyList<OfficeDiffHunk>`

`public IReadOnlyList<T?> Revert(IReadOnlyList<T?> target)` [#](#method-revert-collections-generic-ireadonlylist)

[OfficeDiffResult.cs:101](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L101)

Reverts the edit script on target and returns the old sequence.

Parameters

**target System.Collections.Generic.IReadOnlyList<T?> required**

Returns

`IReadOnlyList<T?>`

Exceptions

- `InvalidOperationException` – The target does not match the new sequence this script was computed from.

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public IReadOnlyList<T?> Old { get; }` [#](#property-old)

[OfficeDiffResult.cs:23](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L23)

Old sequence.

`public IReadOnlyList<T?> New { get; }` [#](#property-new)

[OfficeDiffResult.cs:26](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L26)

New sequence.

`public IReadOnlyList<OfficeDiffEdit> Edits { get; }` [#](#property-edits)

[OfficeDiffResult.cs:32](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L32)

Edit runs in order. Together they cover every old item and every new item exactly once; within each changed region the deletion comes before the insertion.

`public IEqualityComparer<T?> Comparer { get; }` [#](#property-comparer)

[OfficeDiffResult.cs:35](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L35)

Comparer used to match items.

`public OfficeDiffAlgorithm Algorithm { get; }` [#](#property-algorithm)

[OfficeDiffResult.cs:38](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L38)

Algorithm that produced the alignment.

`public bool LimitReached { get; }` [#](#property-limitreached)

[OfficeDiffResult.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L44)

True when a work, time or depth limit stopped the alignment early. The edit script is still complete and correct (applying it to [OfficeDiffResult<T>.Old](/api/core/officeimo-diff-officediffresult/) yields [OfficeDiffResult<T>.New](/api/core/officeimo-diff-officediffresult/)), but some unchanged items may be reported as deleted and reinserted.

`public long WorkUnits { get; }` [#](#property-workunits)

[OfficeDiffResult.cs:47](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L47)

Comparison steps spent on the alignment.

`public int EqualCount { get; }` [#](#property-equalcount)

[OfficeDiffResult.cs:50](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L50)

Number of old items that are unchanged.

`public int DeletedCount { get; }` [#](#property-deletedcount)

[OfficeDiffResult.cs:53](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L53)

Number of old items deleted.

`public int InsertedCount { get; }` [#](#property-insertedcount)

[OfficeDiffResult.cs:56](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L56)

Number of new items inserted.

`public int EditDistance { get; }` [#](#property-editdistance)

[OfficeDiffResult.cs:59](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L59)

Edit distance: deletions plus insertions.

`public bool AreEqual { get; }` [#](#property-areequal)

[OfficeDiffResult.cs:62](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeDiffResult.cs#L62)

True when the sequences are equal under [OfficeDiffResult<T>.Comparer](/api/core/officeimo-diff-officediffresult/).

<!-- PowerForge markdown artifact sha256:9889D73F3416EF784838AF118E3CC4CF94864C131ED641F5E00120B70F668AED -->
