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

Fixed serialization problem in PublishModel/PublishHeaders examples #296

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

robibobi
Copy link
Contributor

Currently the example projects Example.Core.PublishModel, Example.Core.SubscribeModel, Example.Core.PublishHeaders and Example.Core.SubscribeHeaders are not working because the default serializer can not handle the custom Bar type. To make the programs work, we need to provide a serializer for that type.

To achieve this, i added a project reference to Nats.Client.Serializers.Json and configured the NatsJsonSerializerRegistry as SerializerRegistry in the mentioned projects.

The same could be achieved by using the AOT ready NatsJsonContextSerializer but with we would need to create a custom JsonSerializerContext for the Bar type in every project. To keep the required code as small as possible, i chose the reflection based serializer.

…l/Header examples.

- Added the reflection based JsonSerializer as default serializer. This way the Bar object can be (de)serialized and the examples work.
Copy link
Collaborator

@mtmk mtmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you @robibobi

@mtmk mtmk merged commit 31dc087 into nats-io:main Dec 21, 2023
9 checks passed
@mtmk mtmk mentioned this pull request Jan 5, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants