-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add SseFormatter #109832
base: main
Are you sure you want to change the base?
Add SseFormatter #109832
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
src/libraries/System.Net.ServerSentEvents/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
public static partial class SseFormatter | ||
{ | ||
public static System.Threading.Tasks.Task WriteAsync(System.Collections.Generic.IAsyncEnumerable<System.Net.ServerSentEvents.SseItem<string>> source, System.IO.Stream destination, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } | ||
public static System.Threading.Tasks.Task WriteAsync<T>(System.Collections.Generic.IAsyncEnumerable<System.Net.ServerSentEvents.SseItem<T>> source, System.IO.Stream destination, System.Action<System.Buffers.IBufferWriter<byte>, System.Net.ServerSentEvents.SseItem<T>> itemFormatter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ordering of IBufferWriter then SseItem looks wrong to me. We generally do source and then destination; the source here is the SseItem and the destination is the IBufferWriter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of how serializers typically order their parameters, e.g. JsonConverter.Write accepts writer first and value second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @bartonjs, @terrajobst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we intentionally flipped the order in the callback to be (source, destiantion).
Notably, your PR here does not match what was approved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notably, your PR here does not match what was approved.
Yep, this is exploring possible amendments in the callback. Another one is passing the wrapping SseItem<T>
instead of just T. Will notify fxdc once we're settled on the shape.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that we intentionally flipped the order in the callback to be (source, destiantion).
While technically the value is the source and the writer is the destination, this ordering is not what we commonly use in the context of serialization. For example:
- JsonConverter.Write(Utf8JsonWriter, T)
- JsonSerializer.SerializeAsync(Stream, T)
- DataContractSerializer.WriteObject(XmlWriter, object)
Given that the delegate does represent a serialization callback, I would suggest we use the order as presented in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://youtu.be/ehUiLj2KvCg?t=5583
It started as writer first, then got flipped. There was no objection. And, wow, I hate listening to myself.
If you want to change it, you can bring it back for discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping we could get this resolved quickly via email. If not, I will begrudgingly change this back to the order as originally approved.
src/libraries/System.Net.ServerSentEvents/src/System/Net/ServerSentEvents/SseItem.cs
Show resolved
Hide resolved
…s.resx Co-authored-by: Stephen Toub <[email protected]>
Fix #109294.