eventflow / EventFlow

Async/await first CQRS+ES and DDD framework for .NET
https://geteventflow.net
Other
2.39k stars 445 forks source link

A way to configure JsonSerializerSettings at JsonSerializer #966

Closed nazarovsa closed 1 year ago

nazarovsa commented 1 year ago

Hi, I'm enjoying EventFlow, but I faced a problem with event deserialization. I have field of interface type in my AggregateEvent. I wrote a JsonConverter for it, but I can't find a way to configure json settings inside JsonSerializer class. I tried next, but there is no effect: JsonSerializerSettings inside JsonSerializer still the same.

builder.Services.AddEventFlow(options =>
{
    options.ConfigureJson(jsonOptions =>
        {
            jsonOptions.Apply(JsonSettings.Instance);
            jsonOptions.AddConverter<CharacterJsonConverter>();
            return jsonOptions;
        })
        // Next registrations
});

Additionally, I noticed that JsonOptions.Apply do nothing. Is it expected behaviour?

public class JsonOptions : IJsonOptions
    {
        public void Apply(JsonSerializerSettings settings)
        {
        }

        public static JsonOptions New => new JsonOptions();
    }

Is there way to configure JsonSerializerSettings at JsonSerializer class?

rasmus commented 1 year ago

The default IJsonOptions implementation does nothing. You would simply register an alternative implementation that does something else.

It's properly something that could be cleaned up a bit for 1.x

github-actions[bot] commented 1 year ago

Hello there!

We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. We consider this issue to be stale and will be closing it within the next seven days.

If you still require assistance with this issue, please feel free to reopen it or create a new issue.

Thank you for your understanding and cooperation.

Best regards, EventFlow

github-actions[bot] commented 1 year ago

Hello there!

This issue has been closed due to inactivity for seven days. If you believe this issue still needs attention, please feel free to open a new issue or comment on this one to request its reopening.

Thank you for your contribution to this repository.

Best regards, EventFlow