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
| Name | Description |
|---|---|
| DefaultOwners | Gets the owners used by the patterns of this section that do not declare any owner. |
| HasDefaultOwners | Gets a value indicating whether this section has default owners defined. |
| IsMandatory | Gets a value indicating whether the approval of this section's owners is required. |
| IsOptional | Gets a value indicating whether this section is optional, meaning its owners are requested for review but their approval is not required. |
| Name | Gets the name of the section. |
| RequiredReviewerCount | Gets the number of reviewers declared by the section header, or 1 when the header does not declare one. |
DefaultOwners
CodeOwnersSection.csGets the owners used by the patterns of this section that do not declare any owner.
public IReadOnlyList<CodeOwner> DefaultOwners { get; }Property value
HasDefaultOwners
CodeOwnersSection.csIsMandatory
CodeOwnersSection.csIsOptional
CodeOwnersSection.csRequiredReviewerCount
CodeOwnersSection.csGets the number of reviewers declared by the section header, or 1 when the header does not declare one.
public int RequiredReviewerCount { get; }Property value
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
| Name | Description |
|---|---|
| Equals(CodeOwnersSection?) | |
| Equals(object?) | |
| GetHashCode() | |
| ToString() | Returns the section header as written in a CODEOWNERS file. |
Equals overloads
Equals(CodeOwnersSection?)
CodeOwnersSection.cspublic bool Equals(CodeOwnersSection? other)No documentation is available.
Equals(object?)
CodeOwnersSection.csGetHashCode()
CodeOwnersSection.csToString()
CodeOwnersSection.csOperators
| Name | Description |
|---|---|
| operator ==(CodeOwnersSection?, CodeOwnersSection?) | |
| operator !=(CodeOwnersSection?, CodeOwnersSection?) |
operator ==(CodeOwnersSection?, CodeOwnersSection?)
CodeOwnersSection.cspublic static bool operator ==(CodeOwnersSection? left, CodeOwnersSection? right)No documentation is available.
operator !=(CodeOwnersSection?, CodeOwnersSection?)
CodeOwnersSection.cspublic static bool operator !=(CodeOwnersSection? left, CodeOwnersSection? right)No documentation is available.