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

Use SerializeAsync method in JsonCoreSerializer class #387

Open
ArminShoeibi opened this issue Mar 23, 2023 · 0 comments
Open

Use SerializeAsync method in JsonCoreSerializer class #387

ArminShoeibi opened this issue Mar 23, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ArminShoeibi
Copy link

Is your request related to a problem you have?

Hello folks

Here in this method

public Task SerializeAsync(object message, Stream output, ISerializerContext context)

We can change the code from

        public Task SerializeAsync(object message, Stream output, ISerializerContext context)
        {
            using var writer = new Utf8JsonWriter(output);

            JsonSerializer.Serialize(writer, message, this.options);

            return Task.CompletedTask;
        }

to

        public async Task SerializeAsync(object message, Stream output, ISerializerContext context)
        {
            await JsonSerializer.SerializeAsync(output, message, this.options)  
                                .ConfigureAwait(false);
        }

and in the background it uses Utf8Writer

Describe the solution you'd like

preferred way:

        public async Task SerializeAsync(object message, Stream output, ISerializerContext context)
        {
            await JsonSerializer.SerializeAsync(output, message, this.options)  
                                .ConfigureAwait(false);
        }

Are you able to help bring it to life and contribute with a Pull Request?

Yes

Additional context

No response

@ArminShoeibi ArminShoeibi added the enhancement New feature or request label Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants