# OfficeUnifiedDiff

Writes line diffs in the unified format read by patch and git apply.

Class 

`OfficeIMO.Diff`

**Namespace**

`OfficeIMO.Diff`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[OfficeUnifiedDiff.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeUnifiedDiff.cs#L18)

**Modifiers**

static

Writes line diffs in the unified format read by patch and git apply.

## Inheritance

- object
- OfficeUnifiedDiff

Filter members 

Show inherited

## Methods

`public static string Create(string? oldText, string? newText, string oldName = "a", string newName = "b", int contextLines = 3, OfficeDiffOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-create-string-string-string-string-int32-officeimo-diff-officediffoptions-threading-cancellationtoken)

[OfficeUnifiedDiff.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeUnifiedDiff.cs#L18)

Compares two texts line by line and writes a unified diff. Returns an empty string when the texts are equal.

Parameters

**oldText string? required**

Old text.

**newText string? required**

New text.

**oldName string = "a" optional**

Name on the --- header line.

**newName string = "b" optional**

Name on the +++ header line.

**contextLines int = 3 optional**

Unchanged lines shown around each change.

**options OfficeIMO.Diff.OfficeDiffOptions? = null optional**

Diff settings.

**cancellationToken System.Threading.CancellationToken = default optional**

Cancels the alignment.

Returns

`string`

`public static string Format(OfficeDiffResult<OfficeTextToken> lineDiff, string oldName = "a", string newName = "b", int contextLines = 3)` [#](#method-format-officeimo-diff-officediffresult-officeimo-diff-officetexttoken-string-string-int32)

[OfficeUnifiedDiff.cs:22](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/Diff/OfficeUnifiedDiff.cs#L22)

Writes a unified diff for a line diff produced by [OfficeDiff.CompareLines](/api/core/officeimo-diff-officediff/).

Parameters

**lineDiff OfficeIMO.Diff.OfficeDiffResult<OfficeIMO.Diff.OfficeTextToken> required**

**oldName string = "a" optional**

**newName string = "b" optional**

**contextLines int = 3 optional**

Returns

`string`

## 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?`

<!-- PowerForge markdown artifact sha256:B0E8580D7AACB5E470BC148371A2CB2579447FB1086553247463304A3BBF6DD2 -->
