Skip to content

AOT Compatible (Again)#378

Closed
SMAH1 wants to merge 3 commits into
oras-project:mainfrom
SMAH1:AotCompatible2
Closed

AOT Compatible (Again)#378
SMAH1 wants to merge 3 commits into
oras-project:mainfrom
SMAH1:AotCompatible2

Conversation

@SMAH1

@SMAH1 SMAH1 commented May 2, 2026

Copy link
Copy Markdown

What this PR does / why we need it

Use in AOT project

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?

@SMAH1 SMAH1 requested a review from sajayantony as a code owner May 2, 2026 16:49
Copilot AI review requested due to automatic review settings May 2, 2026 16:49
@SMAH1 SMAH1 requested review from Wwwsylvia and shizhMSFT as code owners May 2, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ORAS .NET’s JSON serialization patterns to be compatible with NativeAOT scenarios by switching from reflection-based System.Text.Json APIs to source-generated metadata and marking the library as AOT-compatible.

Changes:

  • Introduces OrasJsonSerializerContext and updates JSON (de)serialization call sites to use generated JsonTypeInfo.
  • Moves small JSON DTOs (TagList, RepositoryList, ErrorResponse) out of method/nested scopes so they can be included in source generation.
  • Sets <IsAotCompatible>true</IsAotCompatible> on the main library project and adjusts affected tests to reference the relocated DTO types.

Reviewed changes

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

Show a summary per file
File Description
tests/OrasProject.Oras.Tests/Registry/Remote/RepositoryTest.cs Updates tag-list DTO references to the new top-level TagList.
tests/OrasProject.Oras.Tests/Registry/Remote/RegistryTest.cs Updates repository-list DTO references to the new top-level RepositoryList.
src/OrasProject.Oras/Registry/Remote/TagList.cs Adds a dedicated DTO type for /tags/list JSON payloads for source-gen.
src/OrasProject.Oras/Registry/Remote/RepositoryList.cs Adds a dedicated DTO type for /_catalog JSON payloads for source-gen.
src/OrasProject.Oras/Registry/Remote/Repository.cs Switches JSON (de)serialization to OrasJsonSerializerContext and removes nested DTO.
src/OrasProject.Oras/Registry/Remote/Registry.cs Switches JSON deserialization to OrasJsonSerializerContext and removes nested DTO.
src/OrasProject.Oras/Registry/Remote/ManifestStore.cs Switches manifest/index deserialization to source-generated metadata.
src/OrasProject.Oras/Registry/Remote/Exceptions/ResponseException.cs Switches error response deserialization to source-generated metadata and relocates DTO.
src/OrasProject.Oras/Registry/Remote/Error.cs Switches detail JSON serialization to source-generated metadata.
src/OrasProject.Oras/Packer.cs Switches manifest serialization to source-generated metadata and narrows helper signature.
src/OrasProject.Oras/Oci/Index.cs Switches index serialization to source-generated metadata.
src/OrasProject.Oras/Content/FetchableExtensions.cs Switches manifest/index deserialization to source-generated metadata.
src/OrasProject.Oras/OrasProject.Oras.csproj Marks the package as AOT-compatible.
src/OrasProject.Oras/OrasJsonSerializerContext.cs Adds the System.Text.Json source-generation context and registers required types.

@cshung

cshung commented May 11, 2026

Copy link
Copy Markdown
Contributor

Hi @SMAH1, thanks for this contribution — Native AOT support is a great addition to the library!

We did some local benchmarking with a test app that exercises manifest/index round-trips and a real registry pull from MCR, and the results are compelling:

AOT JIT
Startup 20ms 150ms
Memory ~20 MB ~43 MB

Before we can merge, could you fix the DCO sign-off? All three commits are missing the Signed-off-by trailer. You can fix this by rebasing with --signoff:

git rebase --signoff HEAD~3
git push --force-with-lease

This will add Signed-off-by: Your Name <your-email> to each commit.

We also have some follow-up patches we're working on that add CI validation for AOT compatibility — both a lightweight analyzer check and an end-to-end AOT test app that publishes a native binary and runs it. We'll coordinate those once the DCO is sorted out.

SMAH1 added 3 commits May 17, 2026 07:33
Signed-off-by: SMAH1 <integral22003@yahoo.com>
Signed-off-by: SMAH1 <integral22003@yahoo.com>
Signed-off-by: SMAH1 <integral22003@yahoo.com>
@SMAH1 SMAH1 force-pushed the AotCompatible2 branch from 7543cc9 to fc830b4 Compare May 17, 2026 04:04
@SMAH1 SMAH1 requested a review from akashsinghal as a code owner May 17, 2026 04:04
@SMAH1

SMAH1 commented May 17, 2026

Copy link
Copy Markdown
Author

Hi @cshung
I added the Signed-off-by.

@akashsinghal

Copy link
Copy Markdown
Collaborator

@SMAH1 thank you for your contributions. Could you please rebase and resolve merge conflicts?

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.72%. Comparing base (403c861) to head (fc830b4).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/OrasProject.Oras/Registry/Remote/Repository.cs 16.66% 3 Missing and 2 partials ⚠️
...rc/OrasProject.Oras/Content/FetchableExtensions.cs 0.00% 0 Missing and 2 partials ⚠️
.../OrasProject.Oras/Registry/Remote/ManifestStore.cs 50.00% 0 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (55.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #378      +/-   ##
==========================================
- Coverage   91.78%   91.72%   -0.07%     
==========================================
  Files          64       66       +2     
  Lines        2752     2754       +2     
  Branches      365      365              
==========================================
  Hits         2526     2526              
- Misses        138      140       +2     
  Partials       88       88              

☔ 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.

@SMAH1 SMAH1 mentioned this pull request May 29, 2026
4 tasks
@SMAH1

SMAH1 commented May 29, 2026

Copy link
Copy Markdown
Author

Resolving conflict is very difficult.
I close this PR and open another one from new base (#389).

@SMAH1 SMAH1 closed this May 29, 2026
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.

4 participants