AOT Compatible (Again)#378
Conversation
There was a problem hiding this comment.
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
OrasJsonSerializerContextand updates JSON (de)serialization call sites to use generatedJsonTypeInfo. - 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. |
|
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:
Before we can merge, could you fix the DCO sign-off? All three commits are missing the git rebase --signoff HEAD~3
git push --force-with-leaseThis will add 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. |
Signed-off-by: SMAH1 <integral22003@yahoo.com>
Signed-off-by: SMAH1 <integral22003@yahoo.com>
Signed-off-by: SMAH1 <integral22003@yahoo.com>
|
Hi @cshung |
|
@SMAH1 thank you for your contributions. Could you please rebase and resolve merge conflicts? |
Codecov Report❌ Patch coverage is ❌ 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. 🚀 New features to boost your workflow:
|
|
Resolving conflict is very difficult. |
What this PR does / why we need it
Use in AOT project
Please check the following list