Skip to content

How to extend the serializer in the latest version? #8394

@gpetrou

Description

@gpetrou

Once again there are breaking changes in a patch version.
Before the latest version, we had the following class:

internal class ExtendedSystemTextJsonSerializer : SystemTextJsonSerializer
{
    public ExtendedSystemTextJsonSerializer(IElasticsearchClientSettings elasticsearchClientSettings)
        : base(elasticsearchClientSettings)
    {
        JsonSerializerOptions options = DefaultSourceSerializer.CreateDefaultJsonSerializerOptions(includeDefaultConverters: true);

        options.Converters.Add(new ObjectConverter());

        Options = DefaultSourceSerializer.AddDefaultConverters(options);
    }

    protected JsonSerializerOptions Options { get; set; }

    protected override JsonSerializerOptions CreateJsonSerializerOptions() => Options;
}

We were calling it as in the following code:

ElasticsearchClientSettings elasticsearchClientSettings = new(
    nodePool,
    sourceSerializer: (defaultSerializer, settings) =>
        new ExtendedSystemTextJsonSerializer(settings));

How is this supposed to be transformed now in the latest version? We do not need the IElasticsearchClientSettings anymore?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions