Skip to content

.NET 8 and AOT compatibility #1395

Closed
Closed
@guillaume-chervet

Description

@guillaume-chervet

Describe the bug

Than you for your work ont this library about kubernetes :)

We would like to activate .NET 8 AOT on SlimFaas which is also an open source project.
Compilation work, but execution crash on that line : https://github.com/AxaFrance/SlimFaas/blob/5c5a1f39ae3b0e6bee8a8cdf27ec85f95607b404/src/SlimFaas/Kubernetes/KubernetesService.cs#L66

--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
at k8s.AbstractKubernetes.<IAppsV1Operations_ListNamespacedDeploymentWithHttpMessagesAsync>d__606`1.MoveNext() + 0x664

...

System.InvalidOperationException: JsonSerializerOptions instance must specify a TypeInfoResolver setting before being marked as read-only.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerOptionsNoTypeInfoResolverSpecified() + 0x27
at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() + 0x20
at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions, Type) + 0x2d
at System.Text.Json.JsonSerializer.GetTypeInfo[T](JsonSerializerOptions) + 0x2b
at System.Text.Json.JsonSerializer.Deserialize[TValue](Stream, JsonSerializerOptions) + 0x1f
at k8s.Kubernetes.<CreateResultAsync>d__46`1.MoveNext() + 0x249

The SlimFaas PullRequest : SlimPlanet/SlimFaas#23

Kubernetes C# SDK Client Version

 <PackageReference Include="KubernetesClient" Version="12.0.16" />

Dotnet Runtime Version
8.0.100-preview.7.23376.3

To Reproduce
Build an AOT program which use this function : https://github.com/AxaFrance/SlimFaas/blob/5c5a1f39ae3b0e6bee8a8cdf27ec85f95607b404/src/SlimFaas/Kubernetes/KubernetesService.cs#L66

Expected behavior
Does not crash once compile with AOT

### Tasks
- [ ] https://github.com/kubernetes-client/csharp/pull/1417

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions