Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept multiple JSON serialization contexts in DI #504

Open
mtmk opened this issue May 30, 2024 · 3 comments
Open

Accept multiple JSON serialization contexts in DI #504

mtmk opened this issue May 30, 2024 · 3 comments
Assignees

Comments

@mtmk
Copy link
Collaborator

mtmk commented May 30, 2024

Proposed change

public NatsBuilder AddJsonSerialization(params JsonSerializerContext[] contexts)
    => ConfigureOptions(opts =>
    {
        var jsonRegistry = new NatsJsonContextSerializerRegistry(contexts);
        return opts with { SerializerRegistry = jsonRegistry };
    });

...or collect them to add them in the end during build:

public NatsBuilder AddJsonSerialization(params JsonSerializerContext[] contexts)
    => _contexts.AddRange(contexts);

cc @rickdotnet

@rickdotnet
Copy link
Collaborator

I rushed this original implementation and missed that NatsJsonContextSerializerRegistry took in params.

If I pick this up, I'll probably opt for the first option unless someone has opinions against it.

@rickdotnet rickdotnet self-assigned this Jul 3, 2024
@rickdotnet
Copy link
Collaborator

@mtmk , should we wait to see where #530 goes? Or do you think it's worth getting this in sooner?

@mtmk
Copy link
Collaborator Author

mtmk commented Jul 6, 2024

@mtmk , should we wait to see where #530 goes? Or do you think it's worth getting this in sooner?

@rickdotnet yes good idea. There might be multiple issues and PRs. I might also create a project or milestone for these as well once we have consensus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants