dotnet / dotnet/Docker.DotNet

Support for Native AOT

Open
#689 0 comments 9 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.4k
Forks
416
PR merge metrics
No merged PRs in 30d

Description

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

```csharp
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 `partial` to my csproject, add this class:

```csharp
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`](https://github.com/dotnet/Docker.DotNet/blob/c0f44a7000221a7bc1ced1154939e19caeea067a/src/Docker.DotNet/JsonSerializer.cs#L29) to `JsonSerializerContext.Default`.

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.