CodeOwnersEntry Class

Represents a single line of a CODEOWNERS file, associating a file pattern with its owners.

// Parse a CODEOWNERS file
var file = CodeOwnersFile.Parse("*.js @user1 @user2", CodeOwnersDialect.GitLab);
var entry = file.Entries[0];
Assert.Equal("*.js", entry.Pattern);
Assert.Equal(["@user1", "@user2"], entry.Owners.Select(owner => owner.ToString()));
public sealed class CodeOwnersEntry : IEquatable<CodeOwnersEntry>

Remarks

Entries are returned in the order they appear in the file. CODEOWNERS resolution is last-match-wins, so the last entry whose CodeOwnersEntry.Pattern matches a path owns it.

Implements

Properties

NameDescription
IsOptionalGets a value indicating whether this entry belongs to an optional section.
OwnersGets the owners of the pattern. Empty when the entry explicitly leaves the pattern unowned.
PatternGets the file pattern (e.g., "*.js", "/docs/*", or "*") that this entry applies to.
SectionGets the section this entry belongs to, or null if not part of a section.

Gets a value indicating whether this entry belongs to an optional section.

public bool IsOptional { get; }

Property value

bool

Gets the owners of the pattern. Empty when the entry explicitly leaves the pattern unowned.

public IReadOnlyList<CodeOwner> Owners { get; }

Gets the file pattern (e.g., "*.js", "/docs/*", or "*") that this entry applies to.

public string Pattern { get; }

Property value

string

Gets the section this entry belongs to, or null if not part of a section.

public CodeOwnersSection? Section { get; }

Property value

CodeOwnersSection?

Methods

NameDescription
Equals(CodeOwnersEntry?)
Equals(object?)
GetHashCode()
ToString()Returns the entry as written in a CODEOWNERS file of the dialect it was parsed with: the escaped pattern followed by the owners.

Equals overloads

Equals(CodeOwnersEntry?)

CodeOwnersEntry.cs
public bool Equals(CodeOwnersEntry? other)
Parameters
other CodeOwnersEntry?
Returns

bool

No documentation is available.

Equals(object?)

CodeOwnersEntry.cs
public override bool Equals(object? obj)
Parameters
obj object?
Returns

bool

No documentation is available.

GetHashCode()

CodeOwnersEntry.cs
public override int GetHashCode()

Returns

int

No documentation is available.

Returns the entry as written in a CODEOWNERS file of the dialect it was parsed with: the escaped pattern followed by the owners.

public override string ToString()

Returns

string

Remarks

The section header is not part of the entry: parse the line after CodeOwnersSection.ToString to read the entry back.

Operators

NameDescription
operator ==(CodeOwnersEntry?, CodeOwnersEntry?)
operator !=(CodeOwnersEntry?, CodeOwnersEntry?)

operator ==(CodeOwnersEntry?, CodeOwnersEntry?)

CodeOwnersEntry.cs
public static bool operator ==(CodeOwnersEntry? left, CodeOwnersEntry? right)

Parameters

left CodeOwnersEntry?
right CodeOwnersEntry?

Returns

bool

No documentation is available.

operator !=(CodeOwnersEntry?, CodeOwnersEntry?)

CodeOwnersEntry.cs
public static bool operator !=(CodeOwnersEntry? left, CodeOwnersEntry? right)

Parameters

left CodeOwnersEntry?
right CodeOwnersEntry?

Returns

bool

No documentation is available.