Skip to content

Using System.Text.Json Source Generator #1309

Closed

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

Activity

  1. tg123 commented on May 28, 2023

    @tg123
    Member

    it is so cool, it is worth to have those converters public

  2. tg123 commented on Jan 14, 2024

    @tg123
    Member

    merge into #1395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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