Support for Native AOT

Open
#689 0 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, docker

Research direction

Start by reproducing the Native AOT sample and inspect src/Docker.DotNet/JsonSerializer.cs, especially its JsonSerializerOptions setup. Compare the manual JsonSerializerContext and TrimMode requirements described in the issue, then define how completion will be verified for all serializable models without those application-level additions.

Written by the indexing model from the issue text.

Description

I was testing with a simple application with Native AOT and got problems:

using Docker.DotNet;
using Docker.DotNet.Models;
var client = new DockerClientConfiguration()
	.CreateClient();
var param = new ImagesListParameters
{
	All = true
};
var images = await client.Images.ListImagesAsync(param);

This sample only works if i add <TrimMode>partial</TrimMode> to my csproject, add this class:

namespace Docker.DotNet;
using System.Text.Json.Serialization;
using Models;
[JsonSerializable(typeof(ImagesListResponse[]))]
[JsonSerializable(typeof(ImagesListParameters[]))]
public partial class JsonSerializerContext :System.Text.Json.Serialization.JsonSerializerContext {}

And set the TypeInfoResolver on JsonSerializerOptions to JsonSerializerContext.Default.

It seems that all serializable models must be added to the JsonSerializerContext, are you planning to automate this?

Dominant language
C#
Stars
2.4k
Forks
416
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/Docker.DotNet

All issues in dotnet/Docker.DotNet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.