Meziantou.Framework.CodeOwners
6.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Meziantou.Framework.CodeOwners --version 6.0.0
NuGet\Install-Package Meziantou.Framework.CodeOwners -Version 6.0.0
<PackageReference Include="Meziantou.Framework.CodeOwners" Version="6.0.0" />
<PackageVersion Include="Meziantou.Framework.CodeOwners" Version="6.0.0" />
<PackageReference Include="Meziantou.Framework.CodeOwners" />
paket add Meziantou.Framework.CodeOwners --version 6.0.0
#r "nuget: Meziantou.Framework.CodeOwners, 6.0.0"
#:package Meziantou.Framework.CodeOwners@6.0.0
#addin nuget:?package=Meziantou.Framework.CodeOwners&version=6.0.0
#tool nuget:?package=Meziantou.Framework.CodeOwners&version=6.0.0
Meziantou.Framework.CodeOwners
Meziantou.Framework.CodeOwners parses CODEOWNERS file. These files are common on GitHub and GitLab.
Parsing takes the dialect of the file, because the two hosts do not accept the same syntax: sections ([Name], ^[Name], [Name][2]) are a GitLab extension, and in the GitHub syntax a line starting with [ is a pattern, since [ opens a character class.
Each entry is one line of the file: a pattern and the owners it declares.
CodeOwnersFile file = CodeOwnersFile.Parse("* @user1 docs@example.com", CodeOwnersDialect.GitHub);
// file.Entries[0].Pattern: "*"
// file.Entries[0].Owners[0]: Type=Username, Name="user1"
// file.Entries[0].Owners[1]: Type=EmailAddress, Name="docs@example.com"
Entries are returned in file order, and CODEOWNERS resolution is last-match-wins, so the owners of a path are those of the last entry whose pattern matches it:
CodeOwnersEntry? owningEntry = file.Entries.LastOrDefault(entry => Matches(entry.Pattern, path));
IReadOnlyList<CodeOwner> owners = owningEntry?.Owners ?? [];
// An empty Owners list means the entry explicitly leaves the pattern unowned
Parse throws a CodeOwnersParseException when the file is invalid. The exception reports the first error and where it is:
try
{
CodeOwnersFile.Parse("[Section\n* @user1", CodeOwnersDialect.GitLab);
}
catch (CodeOwnersParseException ex)
{
// ex.Error.Kind: CodeOwnersParseErrorKind.UnterminatedSectionHeader
// ex.Error.LineNumber: 1
// ex.Error.LinePosition: 1
Console.WriteLine(ex.Message);
}
Use TryParse when an invalid file should not throw. An overload reports the same error without allocating an exception:
if (CodeOwnersFile.TryParse(content, CodeOwnersDialect.GitHub, out CodeOwnersFile? file, out CodeOwnersParseError error))
{
// ...
}
else
{
Console.WriteLine(error); // line 1, position 1: the section header is not terminated by ']'
}
A CodeOwnersFile only exists for a valid file: neither method hands back a partially parsed one. Entries, Owners and DefaultOwners are read-only views that cannot be cast back to a mutable list.
In the GitLab dialect an owner can also be a role, written @@developer, @@maintainer or @@owner (plural accepted). Anything else after @@ is an error, as is a @ inside a username.
CodeOwnersFile file = CodeOwnersFile.Parse("*.md @@maintainers", CodeOwnersDialect.GitLab);
// file.Entries[0].Owners[0]: Type=Role, Name="maintainers"
The CodeOwnersParser type is obsolete: its Parse method forwards to CodeOwnersFile using the GitLab dialect, and will be removed in a future major version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.ValueStringBuilder (>= 3.0.1)
-
net11.0
- Meziantou.Framework.ValueStringBuilder (>= 3.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.2 | 67 | 10/21/2026 |
| 7.0.1 | 6,362 | 9/13/2026 |
| 7.0.0 | 1,750 | 9/8/2026 |
| 6.0.1 | 123 | 9/6/2026 |
| 6.0.0 | 134 | 9/4/2026 |
| 5.0.2 | 209 | 9/3/2026 |
| 5.0.1 | 8,183 | 7/8/2026 |
| 5.0.0 | 581 | 7/5/2026 |
| 4.0.4 | 2,863 | 6/13/2026 |
| 4.0.3 | 1,043 | 5/23/2026 |
| 4.0.2 | 1,444 | 5/14/2026 |
| 4.0.1 | 309 | 5/11/2026 |
| 4.0.0 | 638 | 5/6/2026 |
| 3.0.18 | 1,930 | 4/25/2026 |
| 3.0.17 | 1,446 | 3/29/2026 |
| 3.0.16 | 20,898 | 3/15/2026 |
| 3.0.15 | 1,582 | 2/22/2026 |
| 3.0.14 | 3,233 | 1/18/2026 |
| 3.0.13 | 1,941 | 12/14/2025 |
| 3.0.12 | 12,678 | 11/16/2025 |