UnifiedDiffHunk Class

A hunk of a unified diff: a group of changes with their lines of context, introduced by an @@ line.

public sealed class UnifiedDiffHunk

Properties

NameDescription
LinesGets the lines of the hunk, in order.
NewLineCountGets the number of lines of the new text that the hunk covers: its context and inserted lines.
NewStartGets the 1-based number of the first line of the hunk in the new text. When UnifiedDiffHunk.NewLineCount is 0, it is the number of the line after which the lines were deleted.
OldLineCountGets the number of lines of the old text that the hunk covers: its context and deleted lines.
OldStartGets the 1-based number of the first line of the hunk in the old text. When UnifiedDiffHunk.OldLineCount is 0, it is the number of the line after which the lines are inserted, and 0 inserts them at the start of the text.
SectionHeadingGets the text written after the closing @@, such as the name of the function git diff writes, or null when there is none.

Gets the lines of the hunk, in order.

public IReadOnlyList<UnifiedDiffLine> Lines { get; }

NewLineCount

UnifiedDiffHunk.cs

Gets the number of lines of the new text that the hunk covers: its context and inserted lines.

public int NewLineCount { get; }

Property value

int

Gets the 1-based number of the first line of the hunk in the new text. When UnifiedDiffHunk.NewLineCount is 0, it is the number of the line after which the lines were deleted.

public int NewStart { get; }

Property value

int

OldLineCount

UnifiedDiffHunk.cs

Gets the number of lines of the old text that the hunk covers: its context and deleted lines.

public int OldLineCount { get; }

Property value

int

Gets the 1-based number of the first line of the hunk in the old text. When UnifiedDiffHunk.OldLineCount is 0, it is the number of the line after which the lines are inserted, and 0 inserts them at the start of the text.

public int OldStart { get; }

Property value

int

SectionHeading

UnifiedDiffHunk.cs

Gets the text written after the closing @@, such as the name of the function git diff writes, or null when there is none.

public string? SectionHeading { get; }

Property value

string?

Methods

NameDescription
ToString()Returns the hunk in the unified format: its @@ line followed by its lines.

Returns the hunk in the unified format: its @@ line followed by its lines.

public override string ToString()

Returns

string