Skip to content

feat: add OCI Annotations constants#351

Open
wangxiaoxuan273 wants to merge 1 commit intooras-project:mainfrom
wangxiaoxuan273:feat/oci-annotations
Open

feat: add OCI Annotations constants#351
wangxiaoxuan273 wants to merge 1 commit intooras-project:mainfrom
wangxiaoxuan273:feat/oci-annotations

Conversation

@wangxiaoxuan273
Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 commented Feb 27, 2026

What this PR does / why we need it

Adds standard OCI annotation key constants per the OCI Image Spec v1.1.1 annotations.

Includes a test file that validates all constant values.

Which issue(s) this PR resolves / fixes

Part of the File Store implementation split (issue 1 of 10).
Related: #328, #37

Please check the following list

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.76%. Comparing base (5953fb1) to head (7e54d61).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #351   +/-   ##
=======================================
  Coverage   91.76%   91.76%           
=======================================
  Files          64       64           
  Lines        2755     2755           
  Branches      364      364           
=======================================
  Hits         2528     2528           
  Misses        138      138           
  Partials       89       89           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new public constants surface for standard OCI image annotation keys (per OCI Image Spec v1.1.1), along with unit tests to prevent accidental value drift. This fits into the OrasProject.Oras.Oci model/constants area similarly to existing Oci.MediaType.

Changes:

  • Introduces OrasProject.Oras.Oci.Annotations with constants for standard OCI annotation keys.
  • Adds AnnotationsTest to assert all constants match the spec-defined strings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/OrasProject.Oras/Oci/Annotations.cs New public constants class exposing OCI annotation keys with XML docs + spec link.
tests/OrasProject.Oras.Tests/Oci/AnnotationsTest.cs Unit test validating all annotation constant values.

Copilot AI review requested due to automatic review settings February 27, 2026 07:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

- Remove 'Annotation' prefix from XML doc names to match actual constant names
- Put const assignments on single lines per codebase style

Signed-off-by: Xiaoxuan Wang <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@akashsinghal
Copy link
Collaborator

Caution

This review was generated by Copilot using Claude Opus 4.6, mimicking the review style of shizhMSFT. This is not the real shizhMSFT.

Review of PR #351

Verified all 14 constants match OCI Image Spec v1.1.1 annotations.md and specs-go/v1/annotations.go exactly. Clean, spec-compliant, well-tested. Three observations:

1. Url should be URL (Annotations.cs:37)

The Go spec uses AnnotationURL (uppercase acronym). The .NET naming convention for acronyms of 2 letters is all-caps: IO, UI, DB — and URL. See .NET naming guidelines for acronyms. UrlURL. This is a public API name; fix it before it ships.

2. XML docs should link spec sections directly

The class-level doc links to the annotations page, which is good. But individual constant docs could benefit from noting which spec section defines them — especially RefName which has specific character-set and grammar constraints (alphanum ("/" component)*). Developers will not read your code but read your documentation before invoking the API. Consider adding at minimum a note on RefName's character-set constraint and on Created's RFC 3339 format requirement.

3. nit: Test asserts each value individually but could use [Theory] / [InlineData]

14 assertions in a single [Fact] method. If assertion #3 fails, assertions #4-14 don't run. A [Theory] with [InlineData] would give per-constant failure granularity. Same coverage, better diagnostics:

[Theory]
[InlineData(nameof(Annotations.Created), "org.opencontainers.image.created")]
[InlineData(nameof(Annotations.Authors), "org.opencontainers.image.authors")]
// ...
public void OciAnnotation_HasCorrectValue(string name, string expected)
{
    var field = typeof(Annotations).GetField(name);
    Assert.Equal(expected, field!.GetValue(null));
}

Otherwise SGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants