CodeOwnersSection Class

Represents a section in a CODEOWNERS file, which groups patterns and defines review requirements.

var content = """
    [Backend][2] @backend-team
    *.cs @csharp-owner

    ^[Optional]
    docs/* @docs-owner
    """;
var file = CodeOwnersFile.Parse(content, CodeOwnersDialect.GitLab);

var backend = file.Entries[0].Section!;
Assert.Equal("Backend", backend.Name);
Assert.Equal(2, backend.RequiredReviewerCount);

var optional = file.Entries[1].Section!;
Assert.Equal("Optional", optional.Name);
Assert.True(optional.IsOptional);
public sealed class CodeOwnersSection : IEquatable<CodeOwnersSection>
Implements

Properties

NameDescription
DefaultOwnersGets the owners used by the patterns of this section that do not declare any owner.
HasDefaultOwnersGets a value indicating whether this section has default owners defined.
IsMandatoryGets a value indicating whether the approval of this section's owners is required.
IsOptionalGets a value indicating whether this section is optional, meaning its owners are requested for review but their approval is not required.
NameGets the name of the section.
RequiredReviewerCountGets the number of reviewers declared by the section header, or 1 when the header does not declare one.

Gets the owners used by the patterns of this section that do not declare any owner.

public IReadOnlyList<CodeOwner> DefaultOwners { get; }

HasDefaultOwners

CodeOwnersSection.cs

Gets a value indicating whether this section has default owners defined.

public bool HasDefaultOwners { get; }

Property value

bool

Gets a value indicating whether the approval of this section's owners is required.

public bool IsMandatory { get; }

Property value

bool

Gets a value indicating whether this section is optional, meaning its owners are requested for review but their approval is not required.

public bool IsOptional { get; }

Property value

bool

Gets the name of the section.

public string Name { get; }

Property value

string

RequiredReviewerCount

CodeOwnersSection.cs

Gets the number of reviewers declared by the section header, or 1 when the header does not declare one.

public int RequiredReviewerCount { get; }

Property value

int

Remarks

The value is the one written in the file even when CodeOwnersSection.IsOptional is true, in which case no approval is required regardless of the count.

Methods

NameDescription
Equals(CodeOwnersSection?)
Equals(object?)
GetHashCode()
ToString()Returns the section header as written in a CODEOWNERS file.

Equals overloads

Equals(CodeOwnersSection?)

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

bool

No documentation is available.

Equals(object?)

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

bool

No documentation is available.

public override int GetHashCode()

Returns

int

No documentation is available.

Returns the section header as written in a CODEOWNERS file.

public override string ToString()

Returns

string

Operators

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

operator ==(CodeOwnersSection?, CodeOwnersSection?)

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

Parameters

left CodeOwnersSection?
right CodeOwnersSection?

Returns

bool

No documentation is available.

operator !=(CodeOwnersSection?, CodeOwnersSection?)

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

Parameters

left CodeOwnersSection?
right CodeOwnersSection?

Returns

bool

No documentation is available.