Skip to content

Using System.Text.Json Source Generator #1309

Closed
@IvanJosipovic

Description

@IvanJosipovic

I'm playing with utilizing the Source Generator approach in the Json Serializer in order to optimize performance of informers.

Benefits of this approach:
image

See these two docs:

Unfortunately, I've hit a snag due to the existing Json converters being internal.

image

Options:

  1. Make existing converters public
  2. Add Source Generation to this library
    1. It appears fairly simple to implement
    2.   KubernetesJson.AddJsonOptions(x => x.TypeInfoResolver = JsonTypeInfoResolver.Combine(SourceGenerationContext.Default, JsonSerializerOptions.Default.TypeInfoResolver));
      
        [JsonSerializable(typeof(V1Node))]
        [JsonSerializable(typeof(V1Namespace))]
        .. add all other types
        internal partial class SourceGenerationContext : JsonSerializerContext
        {
        }
      

Thoughts?

### 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