Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Native AOT #689

Open
JuanCalle1606 opened this issue Nov 4, 2024 · 0 comments
Open

Support for Native AOT #689

JuanCalle1606 opened this issue Nov 4, 2024 · 0 comments

Comments

@JuanCalle1606
Copy link

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?

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

No branches or pull requests

1 participant